summaryrefslogtreecommitdiff
path: root/Runtime/NavMesh/NavMeshSettings.h
blob: 6c1b6cadeef5bf6ece99ed82ffaef1a9e4db6a2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once

#include "Runtime/BaseClasses/GameManager.h"
#include "Runtime/Utilities/dynamic_array.h"
#include "Runtime/NavMesh/NavMeshTypes.h"
#if UNITY_EDITOR
#include "Editor/Src/NavMesh/NavMeshBuildSettings.h"
#endif

class NavMesh;
class dtNavMesh;

class NavMeshSettings : public LevelGameManager
{
public:

	REGISTER_DERIVED_CLASS (NavMeshSettings, LevelGameManager);
	DECLARE_OBJECT_SERIALIZE (NavMeshSettings);

	NavMeshSettings (MemLabelId& label, ObjectCreationMode mode);

	virtual void		AwakeFromLoad (AwakeFromLoadMode mode);
	virtual void		Reset ();

	inline void			SetNavMesh (NavMesh* navMesh);
	inline NavMesh*		GetNavMesh ();

	bool				SetOffMeshPolyInstanceID (dtPolyRef ref, int instanceID);
	void                SetOffMeshPolyCostOverride (dtPolyRef ref, float costOverride);
	void				SetOffMeshPolyAccess (dtPolyRef ref, bool access);


	#if UNITY_EDITOR
	inline NavMeshBuildSettings& GetNavMeshBuildSettings ();
	#endif

	static void InitializeClass ();
	static void CleanupClass ();

	dtNavMesh* GetInternalNavMesh ();
private:

#if UNITY_EDITOR
	NavMeshBuildSettings m_BuildSettings;
#endif

	PPtr<NavMesh> m_NavMesh;
};

inline void NavMeshSettings::SetNavMesh (NavMesh* navMesh)
{
	m_NavMesh = navMesh;
	SetDirty ();
}

inline NavMesh* NavMeshSettings::GetNavMesh ()
{
	return m_NavMesh;
}

#if UNITY_EDITOR
inline NavMeshBuildSettings& NavMeshSettings::GetNavMeshBuildSettings ()
{
	return m_BuildSettings;
}
#endif

NavMeshSettings& GetNavMeshSettings ();