public void CleanupOBChunks()
    {
        IntVector3        cursorPos    = IntVector3.Zero;
        IntVector3        viewBound    = IntVector3.Zero;
        List <IntVector3> vecToDispose = new List <IntVector3>();

        foreach (IntVector3 key in _chunks.Keys)
        {
            if (Mathf.Abs(key.x - cursorPos.x) > viewBound.x ||
                Mathf.Abs(key.y - cursorPos.y) > viewBound.y ||
                Mathf.Abs(key.z - cursorPos.z) > viewBound.z)
            {
                vecToDispose.Add(key);
            }
        }
        for (int i = 0; i < vecToDispose.Count; i++)
        {
            IntVector3   vec = vecToDispose[i];
            B45ChunkData cd  = _chunks[vec];
            if (cd != null)
            {
                cd.ClearMem();
                cd.DestroyChunkGO();
            }
        }
    }
Esempio n. 2
0
    void deferredRemoval()
    {
        for (int i = deferredRemoveList.Count - 1; i >= 0; i--)
        {
            B45ChunkData cd = deferredRemoveList[i];
            cd.bp();
//			if(colliderMan.isColliderBeingRebuilt(cd.ChunkPos.XYZ)){
//				Debug.LogError("the replacement collider is not done rebuilding.");
//			}
            if (cd != null && cd.isInQueue == false && colliderMan.isColliderBeingRebuilt(cd.ChunkPos.XYZ) == false)
            {
                cd.bp();
                if (_chunks.Remove(new IntVector4(cd.ChunkPos.XYZ, 0)) == false)
                {
                    Debug.LogError("a chunk can not be removed from the dictionary");
                }
                cd.ClearMem();
                cd.DestroyChunkGO();
                deferredRemoveList.RemoveAt(i);
            }
        }
    }