// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once
#include "NavMeshData.h"
#include "Engine/Content/AssetReference.h"
#include "Engine/Content/Assets/RawDataAsset.h"
class Scene;
class NavMeshBoundsVolume;
///
/// Scene object navigation data.
///
class NavigationScene
{
friend Scene;
public:
///
/// Initializes a new instance of the class.
///
/// The scene.
NavigationScene(Scene* scene);
public:
///
/// The parent scene.
///
Scene* Scene;
///
/// 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;
public:
///
/// The list of registered navigation bounds volumes (in the scene).
///
Array Volumes;
///
/// Gets the total navigation volumes bounds.
///
/// The navmesh bounds.
BoundingBox GetNavigationBounds();
///
/// Finds the navigation volume bounds that have intersection with the given world-space bounding box.
///
/// The bounds.
/// The intersecting volume or null if none found.
NavMeshBoundsVolume* FindNavigationBoundsOverlap(const BoundingBox& bounds);
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()
{
if (Data.Tiles.HasItems())
{
IsDataDirty = true;
Data.TileSize = 0.0f;
Data.Tiles.Resize(0);
}
}
protected:
void OnEnable();
void OnDisable();
void OnDataAssetLoaded();
};