예제 #1
0
        private bool LoadData()
        {
            /*Assert.IsTrue(
             *  m_completedStates.Check(ChunkState.Generate),
             *  string.Format(
             *      "[{0},{1},{2}] - LoadData set sooner than Generate completed. Pending:{3}, Completed:{4}", pos.x,
             *      pos.y, pos.z, m_pendingStates, m_completedStates)
             *  );*/
            if (!m_completedStates.Check(ChunkState.Generate))
            {
                return(true);
            }

            m_pendingStates       = m_pendingStates.Reset(CurrStateLoadData);
            m_completedStates     = m_completedStates.Reset(CurrStateLoadData);
            m_completedStatesSafe = m_completedStates;

            m_taskRunning = true;
            IOPoolManager.Add(
                new TaskPoolItem(
                    arg =>
            {
                ChunkStateManagerServer stateManager = (ChunkStateManagerServer)arg;
                OnLoadData(stateManager);
            },
                    this)
                );

            return(true);
        }
예제 #2
0
        private bool SaveData()
        {
            // We need to wait until chunk is generated and data finalized
            if (!m_completedStates.Check(ChunkState.Generate) || !m_completedStates.Check(ChunkState.LoadData))
            {
                return(true);
            }

            m_pendingStates       = m_pendingStates.Reset(CurrStateSaveData);
            m_completedStates     = m_completedStates.Reset(CurrStateSaveData);
            m_completedStatesSafe = m_completedStates;

            m_taskRunning = true;
            IOPoolManager.Add(
                new TaskPoolItem(
                    arg =>
            {
                ChunkStateManagerServer stateManager = (ChunkStateManagerServer)arg;
                OnSaveData(stateManager);
            },
                    this)
                );

            return(true);
        }
예제 #3
0
        private static void OnGenericWork(ref SGenericWorkItem item)
        {
            ChunkStateManagerServer chunk = item.Chunk;

            item.Action();
            OnGenericWorkDone(chunk);
        }
예제 #4
0
        private static void OnGenerateData(ChunkStateManagerServer stateManager)
        {
            Chunk chunk = stateManager.chunk;

            chunk.world.terrainGen.GenerateTerrain(chunk);

            OnGenerateDataDone(stateManager);
        }
예제 #5
0
        private bool GenerateData()
        {
            m_pendingStates       = m_pendingStates.Reset(CurrStateGenerateData);
            m_completedStates     = m_completedStates.Reset(CurrStateGenerateData | CurrStateLoadData);
            m_completedStatesSafe = m_completedStates;

            m_taskRunning = true;

            // Let server generate chunk data
            WorkPoolManager.Add(
                new ThreadPoolItem(
                    chunk.ThreadID,
                    arg =>
            {
                ChunkStateManagerServer stateManager = (ChunkStateManagerServer)arg;
                OnGenerateData(stateManager);
            },
                    this)
                );

            return(true);
        }
예제 #6
0
 private static void OnSaveDataDone(ChunkStateManagerServer stateManager)
 {
     stateManager.m_stateExternal   = ChunkStateExternal.Saved;
     stateManager.m_completedStates = stateManager.m_completedStates.Set(CurrStateSaveData);
     stateManager.m_taskRunning     = false;
 }
예제 #7
0
        private static void OnSaveData(ChunkStateManagerServer stateManager)
        {
            Serialization.Serialization.SaveChunk(stateManager.chunk);

            OnSaveDataDone(stateManager);
        }
예제 #8
0
 private static void OnLoadDataDone(ChunkStateManagerServer stateManager)
 {
     stateManager.m_completedStates = stateManager.m_completedStates.Set(CurrStateLoadData);
     stateManager.m_nextState       = NextStateLoadData;
     stateManager.m_taskRunning     = false;
 }
예제 #9
0
 public static void OnGenerateDataOverNetworkDone(ChunkStateManagerServer stateManager)
 {
     OnGenerateDataDone(stateManager);
     OnLoadDataDone(stateManager);
 }
예제 #10
0
 private static void OnGenericWorkDone(ChunkStateManagerServer chunk)
 {
     chunk.m_completedStates = chunk.m_completedStates.Set(CurrStateGenericWork);
     chunk.m_nextState       = NextStateGenericWork;
     chunk.m_taskRunning     = false;
 }
예제 #11
0
 public SGenericWorkItem(ChunkStateManagerServer chunk, Action action)
 {
     Chunk  = chunk;
     Action = action;
 }