From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/NavMesh/NavMeshLayers.h | 63 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Runtime/NavMesh/NavMeshLayers.h (limited to 'Runtime/NavMesh/NavMeshLayers.h') diff --git a/Runtime/NavMesh/NavMeshLayers.h b/Runtime/NavMesh/NavMeshLayers.h new file mode 100644 index 0000000..0c4085f --- /dev/null +++ b/Runtime/NavMesh/NavMeshLayers.h @@ -0,0 +1,63 @@ +#ifndef NAVMESH_LAYERS_H +#define NAVMESH_LAYERS_H + +#include "Runtime/BaseClasses/GameManager.h" + + + + +class NavMeshLayers : public GlobalGameManager +{ +public: + struct NavMeshLayerData + { + DECLARE_SERIALIZE (NavMeshLayerData) + enum + { + kEditNone = 0, + kEditName = 1, + kEditCost = 2 + }; + + UnityStr name; + float cost; + int editType; + }; + + enum BuiltinNavMeshLayers + { + kDefaultLayer = 0, + kNotWalkable = 1, + kJumpLayer = 2 + }; + + NavMeshLayers (MemLabelId& label, ObjectCreationMode mode); + // ~NavMeshLayers (); declared-by-macro + + REGISTER_DERIVED_CLASS (NavMeshLayers, GlobalGameManager) + DECLARE_OBJECT_SERIALIZE (NavMeshLayers) + + virtual void Reset (); + virtual void AwakeFromLoad (AwakeFromLoadMode awakeMode); + virtual void CheckConsistency (); + + void SetLayerCost (unsigned int index, float cost); + float GetLayerCost (unsigned int index) const; + int GetNavMeshLayerFromName (const UnityStr& layerName) const; + std::vector NavMeshLayerNames () const; + + enum + { + kBuiltinLayerCount = 3, + kLayerCount = 32 + }; + + static const char* s_WarningCostLessThanOne; +private: + + NavMeshLayerData m_Layers[kLayerCount]; +}; + +NavMeshLayers& GetNavMeshLayers (); + +#endif -- cgit v1.1-26-g67d0