/// <summary>
 /// Returns the cached chunk defined by the parameters. Requests a new chunk if
 /// it is not in the chache.
 ///</summary>
 ///<param name="x">The x position in chunk cooridnates.</param>
 ///<param name="z">The z position in chunk cooridnates.</param>
 ///<param name="sizeX">The x size of the chunk.</param>
 ///<param name="sizeZ">The z size of the chunk.</param>
 ///<param name="seed">The seed for the chunk.</param>
 ///<returns>The cached or requested chunk.</returns>
 private Code.Chunk.Chunk GetChunk(int x, int z, int sizeX, int sizeZ, float seed)
 {
     Code.Chunk.Chunk chunk = GetCachedChunk(x, z);
     if (chunk == null)
     {
         chunk = RequestChunk(x, z, sizeX, sizeZ, seed);
         if (chunk != null)
         {
             chunk.Init(GetChunkContainer().transform);
             _chunks.Add(chunk);
         }
     }
     return(chunk);
 }
Beispiel #2
0
 public override Code.Chunk.Chunk GetChunk(OutputSocket outSocket, Request request)
 {
     Code.Chunk.Chunk chunk = new Code.Chunk.Chunk((int)request.X, (int)request.Z, (int)request.SizeX, (int)request.SizeZ, request.Seed);
     for (int i = 0; i < Sockets.Count; i++)
     {
         if (Sockets[i].IsInput() && Sockets[i].IsConnected())
         {
             InputSocket inputSocket   = Sockets[i] as InputSocket;
             Node        connectedNode = inputSocket.Edge.GetOtherSocket(inputSocket).Parent;
             if (inputSocket.Type == typeof(ILandscapeConnection))
             {
                 chunk.AddLandscape((LandscapeNode)connectedNode);
             }
             if (inputSocket.Type == typeof(IEntitiesConnection))
             {
                 chunk.AddEntities((EntitiesNode)connectedNode);
             }
         }
     }
     return(chunk);
 }