// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #include "NavMeshData.h" #include "NavigationTypes.h" #include "Engine/Content/AssetReference.h" #include "Engine/Content/Assets/RawDataAsset.h" #include "Engine/Level/Actor.h" class NavMeshBoundsVolume; class NavMeshRuntime; /// /// The navigation mesh actor that holds a navigation data for a scene. /// API_CLASS() class FLAXENGINE_API NavMesh : public Actor { DECLARE_SCENE_OBJECT(NavMesh); public: /// /// The flag used to mark that navigation data has been modified since load. Used to save runtime data to the file on scene serialization. /// bool IsDataDirty; /// /// The navmesh tiles data. /// NavMeshData Data; /// /// The cached navmesh data asset. /// AssetReference DataAsset; #if USE_EDITOR /// /// If checked, the navmesh will be drawn in debug view when showing navigation data. /// API_FIELD(Attributes="EditorOrder(1), EditorDisplay(\"Nav Mesh\")") bool ShowDebugDraw = true; #endif /// /// The navigation mesh properties. /// API_FIELD(Attributes="EditorOrder(10), EditorDisplay(\"Nav Mesh\")") NavMeshProperties Properties; public: /// /// Saves the nav mesh tiles data to the asset. Supported only in builds with assets saving enabled (eg. editor) and not during gameplay (eg. design time). /// void SaveNavMesh(); /// /// Clears the data. /// void ClearData(); /// /// Gets the navmesh runtime object that matches with properties. /// API_FUNCTION() NavMeshRuntime* GetRuntime(bool createIfMissing = true) const; private: void AddTiles(); void RemoveTiles(); void OnDataAssetLoaded(); public: // [Actor] void Serialize(SerializeStream& stream, const void* otherObj) override; void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override; protected: // [Actor] void OnEnable() override; void OnDisable() override; };