public void RemoveFromNeighborhood(WorldDataChunk chunk) { if (chunk != null) { chunk.Neighbors.Remove(this); Neighbors.Remove(chunk); } }
public static bool ChunkCanBeRemoved(int x, int z) { var key = WorldDataChunk.GetKey(x, z); return (RequestedChunks.ContainsKey(key) || ChunksBeingGenerated.ContainsKey(key) || GeneratedChunks.ContainsKey(key)); }
internal static string GetKey(Vector3 position) { int x = 0; int z = 0; WorldToChunkIndices(position, ref x, ref z); return(WorldDataChunk.GetKey(x, z)); }
private void MakeNeighbors(WorldDataChunk WorldDataChunk1, WorldDataChunk WorldDataChunk2) { if (WorldDataChunk1 == null || WorldDataChunk2 == null) { return; } WorldDataChunk1.Neighbors.Add(WorldDataChunk2); WorldDataChunk2.Neighbors.Add(WorldDataChunk1); }
private void Update() { ChunkCache.TidyUp(); var currentPositionChunkKey = WorldDataChunk.GetKey(Position); if (currentPositionChunkKey != previousPositionChunkKey) { ChunkCache.Update(Position, Radius); previousPositionChunkKey = currentPositionChunkKey; } }
private IEnumerator InitializeCoroutine() { do { var chunkKey = WorldDataChunk.GetKey(Position); if (ChunkCache.IsChunkGenerated(chunkKey)) { previousPositionChunkKey = chunkKey; //WorldManager.Instance.ChunkIsReady = true; IsReady break; } yield return(null); } while (true); }
internal static IList <string> GetChunkKeysInRadius(string chunkKeyAtOrigin, int radius) { var chunkAtOrigin = ChunkCache.GetGeneratedChunk(chunkKeyAtOrigin); var result = new List <string>(); for (var zCircle = -radius; zCircle <= radius; zCircle++) { for (var xCircle = -radius; xCircle <= radius; xCircle++) { if (xCircle * xCircle + zCircle * zCircle < radius * radius) { result.Add(WorldDataChunk.GetKey(chunkAtOrigin.X + xCircle, chunkAtOrigin.Z + zCircle)); } } } return(result); }
public static void RemoveChunk(int x, int z) { ChunksToRemove.Add(WorldDataChunk.GetKey(x, z)); CompleteDeferredRemoves(); }
public static void AddNewChunk(WorldDataChunk chunk) { RequestedChunks.Add(chunk.Key, chunk); GenerateMapsForAvailableChunks(); }
internal static IList <string> GetChunkKeysInRadius(Vector3 worldPosition, int radius) { return(GetChunkKeysInRadius(WorldDataChunk.GetKey(worldPosition), radius)); }
internal static IList <string> GetChunkKeysInRadius(int x, int z, int radius) { return(GetChunkKeysInRadius(WorldDataChunk.GetKey(x, z), radius)); }
internal static bool IsChunkGenerated(Vector3 worldPosition) { return(IsChunkGenerated(WorldDataChunk.GetKey(worldPosition))); }
internal static bool IsChunkGenerated(int x, int z) { return(IsChunkGenerated(WorldDataChunk.GetKey(x, z))); }
internal static WorldDataChunk GetGeneratedChunk(Vector3 worldPosition) { return(GetGeneratedChunk(WorldDataChunk.GetKey(worldPosition))); }
internal static WorldDataChunk GetGeneratedChunk(int x, int z) { return(GetGeneratedChunk(WorldDataChunk.GetKey(x, z))); }
public WorldDataChunkContent(WorldDataChunk WorldDataChunk) { this.WorldDataChunk = WorldDataChunk; gameObjectFactory = new GameObjectFactory(this); }