internal bool AddAgent(CrowdMoveAgent agent) { if (m_IsAppQuit || agent == null || m_Mgr == null) { return(false); } var param = agent.GetParams(); var pt = agent.transform.position; NavmeshPoint pp; Vector3 extends = agent.Extends; if (!NavMeshMap.GetNavmeshPoint(pt, extends, out pp, agent.GetFilter())) { return(false); } agent.transform.position = pp.point; CrowdAgent a = m_Mgr.AddAgent(pp.point, param); agent._SetAgent(a); agent._SetId(NewGlobalId()); var node = agent.ListNode; var list = node.List; if (list != m_AgentList) { if (list != null) { list.Remove(node); } m_AgentList.AddLast(node); } return(true); }
void Awake() { if (m_Map == null) { m_Map = this; } }
public static NavMeshMap GetInstance() { if (m_Map == null) { GameObject gameObj = new GameObject("NavMeshMap", typeof(NavMeshMap)); m_Map = gameObj.GetComponent <NavMeshMap>(); } return(m_Map); }
void OnDestroy() { if (m_DefaultFilter != null) { m_DefaultFilter.RequestDisposal(); m_DefaultFilter = null; } Clear(); m_Map = null; }
private bool Follow(Vector3 pos) { if (!IsInited || !NavMeshMap.IsVaild) { return(false); } NavmeshPoint pt; if (!NavMeshMap.GetNavmeshPoint(pos, this.Extends, out pt, GetFilter())) { return(false); } return(Follow(pt)); }
void Update() { if (m_Mgr != null) { float delta = Time.unscaledDeltaTime; m_Mgr.Update(delta); } else { if (NavMeshMap.IsVaild) { var mesh = NavMeshMap.GetNavMesh(); if (mesh != null) { this._Init(mesh); } } } }
public static bool LoadMap(byte[] buffer) { NavMeshMap map = GetInstance(); return(map.LoadMapFromBuffer(buffer)); }