コード例 #1
0
        //public int _threadFinishedCount = 0;
        // int _mSIdx;//main thread start idx in _allAgents
        //  int _mEIdx;//main thread end idx in _allAgents
        public PathFindingManager(FP scale)
        {
            _tasks       = new List <AgentsTask>();
            _flowManager = new FlowFieldManager();
            int taskCount = 0;

            //     _destroyed = false;
#if MULTI_THREAD
            int cps;
            ThreadPool.GetMinThreads(out taskCount, out cps);
            //#if UNITY_EDITOR
            UnityEngine.Debug.LogError("thread count______:" + taskCount);
            //#endif
            taskCount = 2;
#endif
            //  _taskEvents = new ManualResetEvent[taskCount];
            _pathManagers = new PathManager[taskCount + 1];
            int i = 0;
            for (i = 0; i < taskCount; i++)
            {
                AgentsTask task = AgentsTask.Create(i, this);
                _tasks.Add(task);
                // _taskEvents[i] = task._finished;
                _pathManagers[i] = new PathManager();
            }
            _pathManagers[i] = new PathManager();
#if USING_DYNAMIC_TREE
            _dynamicTree = new DynamicTree <PathFindingAgentBehaviour>();
            _dynamicTree.c_aabbExtension *= scale;
#endif
        }
コード例 #2
0
        public void OnDestroy()
        {
#if !USING_DYNAMIC_TREE
            _dicQdTree.Clear();
            _agents.Clear();
#else
            if (_dynamicTree != null)
            {
                _dynamicTree.Destroy();
            }
            _dynamicTree = null;
#endif

            TerminateThread();
            // _destroyed = true;
            // _allAgents.Clear();
            _hsSpecPos.Clear();
            _flowManager   = null;
            _allAgentCount = 0;
            //  _mSIdx = 0;
            // _mEIdx = 0;
            _deltaTime    = CurTime = 0;
            _pathManagers = null;
            //  _taskEvents = null;
            if (_tasks != null)
            {
                int count = _tasks.Count;
                for (int i = 0; i < count; i++)
                {
                    _tasks[i].terminate = true;
                }
                _tasks.Clear();
            }
            _updateIdx             = 0;
            _eCurrentAgentLoopStep = EAgentLoopStep.max;
        }