Esempio n. 1
0
 //Async version
 private void _UnPack(IntVector3 chunkPos, Action <Chunk> callback)
 {
     Busy         = true;
     OnChunksDone = callback;
     if (vGenConfig.IsSerializedDataValid)
     {
         Debug.Log("will read chunk: " + chunkPos);
         SerializedChunk.ReadAsync(chunkPos, (SerializedChunk serChunk) =>
         {
             if (serChunk != null)
             {
                 Debug.Log("serchunk not null");
                 Chunk result = Chunk.FromSerializedChunk(serChunk, CreateMapDisplay(chunkPos));
                 chunksDone(result);
                 return;
             }
             chunksDone(null);
         });
     }
     else
     {
         Debug.Log("ser data not valid");
         chunksDone(null);
     }
 }
Esempio n. 2
0
        //public bool FromGenData(ChunkGenData data, Action<Chunk> callback)
        //{
        //    if(Busy) { return false; }

        //}

        #endregion

        private void _forge(IntVector3 chunkPos, Action <Chunk> callback)
        {
            Busy         = true;
            OnChunksDone = callback;

            if (vGenConfig.IsSerializedDataValid)
            {
                SerializedChunk.ReadAsync(chunkPos, (SerializedChunk serChunk) =>
                {
                    if (serChunk != null)
                    {
                        Chunk result = Chunk.FromSerializedChunk(serChunk, CreateMapDisplay(chunkPos));
                        chunksDone(result);
                        return;
                    }

                    Debug.Log("got back null from read");
                    computeChunk(chunkPos);
                });
            }
            else
            {
                Debug.Log("ser data invalid");
                computeChunk(chunkPos);
            }
        }