/// <summary> /// Clears chunk state before returning it to the pool. This method is called when this chunk is reused. /// </summary> public void PrepareForReuse(byte light) { isAboveSurface = false; needsMeshRebuild = false; isPopulated = false; inqueue = false; modified = false; renderState = ChunkRenderState.Pending; allowTrees = true; lightmapSignature = -1; frustumCheckIteration = 0; navMesh = null; navMeshSourceIndex = -1; inconclusiveNeighbours = 0; renderingFrame = -1; if (lightSources != null) { lightSources.Clear(); } if (placeholders != null) { int count = placeholders.Count; for (int k = 0; k < count; k++) { VoxelPlaceholder placeholder = placeholders [k]; if (placeholder != null && placeholder.gameObject != null) { DestroyImmediate(placeholder.gameObject); } } placeholders.Clear(); } if (items != null) { for (int k = 0; k < items.count; k++) { Item item = items.values [k]; if (item != null && item.gameObject != null) { DestroyImmediate(item.gameObject); } } items.Clear(); } if (_left != null) { _left.right = null; _left = null; } if (_right != null) { _right.left = null; _right = null; } if (_forward != null) { _forward.back = null; _forward = null; } if (_back != null) { _back.forward = null; _back = null; } if (_top != null) { _top.bottom = null; _top = null; } if (_bottom != null) { _bottom.top = null; _bottom = null; } ClearVoxels(light); mr.enabled = false; }
/// <summary> /// Clears chunk state before returning it to the pool. This method is called when this chunk is reused. /// </summary> public void PrepareForReuse(byte light) { isAboveSurface = false; needsMeshRebuild = false; isPopulated = false; inqueue = false; modified = false; renderState = ChunkRenderState.Pending; allowTrees = true; lightmapSignature = -1; frustumCheckIteration = 0; navMesh = null; navMeshSourceIndex = -1; inconclusiveNeighbours = 0; renderingFrame = -1; visibleDistanceStatus = ChunkVisibleDistanceStatus.Unknown; lightmapIsClear = false; if (items != null) { for (int k = 0; k < items.count; k++) { Item item = items.values [k]; if (item != null && item.gameObject != null) { DestroyImmediate(item.gameObject); } } items.Clear(); } if (_left != null) { _left.right = null; _left = null; } if (_right != null) { _right.left = null; _right = null; } if (_forward != null) { _forward.back = null; _forward = null; } if (_back != null) { _back.forward = null; _back = null; } if (_top != null) { _top.bottom = null; _top = null; } if (_bottom != null) { _bottom.top = null; _bottom = null; } ClearVoxels(light); mr.enabled = false; if (mc != null) { mc.enabled = false; } gameObject.SetActive(true); }