Example #1
0
 public void RemoveFromNeighborhood(WorldDataChunk chunk)
 {
     if (chunk != null)
     {
         chunk.Neighbors.Remove(this);
         Neighbors.Remove(chunk);
     }
 }
Example #2
0
        public static bool ChunkCanBeRemoved(int x, int z)
        {
            var key = WorldDataChunk.GetKey(x, z);

            return
                (RequestedChunks.ContainsKey(key) ||
                 ChunksBeingGenerated.ContainsKey(key) ||
                 GeneratedChunks.ContainsKey(key));
        }
Example #3
0
        internal static string GetKey(Vector3 position)
        {
            int x = 0;
            int z = 0;

            WorldToChunkIndices(position, ref x, ref z);

            return(WorldDataChunk.GetKey(x, z));
        }
Example #4
0
        private void MakeNeighbors(WorldDataChunk WorldDataChunk1, WorldDataChunk WorldDataChunk2)
        {
            if (WorldDataChunk1 == null || WorldDataChunk2 == null)
            {
                return;
            }

            WorldDataChunk1.Neighbors.Add(WorldDataChunk2);
            WorldDataChunk2.Neighbors.Add(WorldDataChunk1);
        }
Example #5
0
        private void Update()
        {
            ChunkCache.TidyUp();
            var currentPositionChunkKey = WorldDataChunk.GetKey(Position);

            if (currentPositionChunkKey != previousPositionChunkKey)
            {
                ChunkCache.Update(Position, Radius);
                previousPositionChunkKey = currentPositionChunkKey;
            }
        }
Example #6
0
 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);
 }
Example #7
0
        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);
        }
Example #8
0
 public static void RemoveChunk(int x, int z)
 {
     ChunksToRemove.Add(WorldDataChunk.GetKey(x, z));
     CompleteDeferredRemoves();
 }
Example #9
0
 public static void AddNewChunk(WorldDataChunk chunk)
 {
     RequestedChunks.Add(chunk.Key, chunk);
     GenerateMapsForAvailableChunks();
 }
Example #10
0
 internal static IList <string> GetChunkKeysInRadius(Vector3 worldPosition, int radius)
 {
     return(GetChunkKeysInRadius(WorldDataChunk.GetKey(worldPosition), radius));
 }
Example #11
0
 internal static IList <string> GetChunkKeysInRadius(int x, int z, int radius)
 {
     return(GetChunkKeysInRadius(WorldDataChunk.GetKey(x, z), radius));
 }
Example #12
0
 internal static bool IsChunkGenerated(Vector3 worldPosition)
 {
     return(IsChunkGenerated(WorldDataChunk.GetKey(worldPosition)));
 }
Example #13
0
 internal static bool IsChunkGenerated(int x, int z)
 {
     return(IsChunkGenerated(WorldDataChunk.GetKey(x, z)));
 }
Example #14
0
 internal static WorldDataChunk GetGeneratedChunk(Vector3 worldPosition)
 {
     return(GetGeneratedChunk(WorldDataChunk.GetKey(worldPosition)));
 }
Example #15
0
 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);
 }