/// <summary> /// 刷新触发器 /// </summary> /// <param name="detector">触发器</param> public void RefreshDetector(IDetector detector) { if (!m_IsInitialized) { return; } m_RefreshTime += Time.deltaTime; //达到刷新时间才刷新,避免区域更新频繁 if (m_RefreshTime > m_MaxRefreshTime) { m_OldRefreshPosition = detector.Position; m_RefreshTime = 0; m_CurrentDetector = detector; //进行触发检测 m_QuadTree.Trigger(detector, m_TriggerHandle); //标记超出区域的物体 MarkOutofBoundsObjs(); //m_IsInitLoadComplete = true; } if (m_PreDestroyObjectQueue != null && m_PreDestroyObjectQueue.Count > m_MinCreateCount) { m_DestroyRefreshTime += Time.deltaTime; if (m_DestroyRefreshTime > m_MaxDestroyTime) { // m_OldDestroyRefreshPosition = detector.Position; m_DestroyRefreshTime = 0; //删除超出区域的物体 DestroyOutOfBoundsObjs(); } } }
/// <summary> /// Refresh detector /// </summary> /// <param name="detector">the detector</param> public void RefreshDetector(IDetector detector) { if (!m_IsInitialized) { return; } // only when the position changes, it refreshes if (m_OldRefreshPosition != detector.Position) { m_RefreshTime += Time.deltaTime; //Also the refresh interval needs to be reached too if (m_RefreshTime > m_MaxRefreshTime) { m_OldRefreshPosition = detector.Position; m_RefreshTime = 0; m_CurrentDetector = detector; // detect this character bounding box with the nodes in quadtree m_QuadTree.Trigger(detector, m_TriggerHandle); //mark the out of bound objects MarkOutofBoundsObjs(); } if (m_PreDestroyObjectQueue != null) //if (m_PreDestroyObjectList != null && m_PreDestroyObjectList.Count >= m_MaxCreateCount) { m_DestroyRefreshTime += Time.deltaTime; if (m_DestroyRefreshTime > m_MaxDestroyTime) { m_OldDestroyRefreshPosition = detector.Position; m_DestroyRefreshTime = 0; //Delete out of bound objects DestroyOutOfBoundsObjs(); } } } }