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); }
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); }
private static void OnGenericWork(ref SGenericWorkItem item) { ChunkStateManagerServer chunk = item.Chunk; item.Action(); OnGenericWorkDone(chunk); }
private static void OnGenerateData(ChunkStateManagerServer stateManager) { Chunk chunk = stateManager.chunk; chunk.world.terrainGen.GenerateTerrain(chunk); OnGenerateDataDone(stateManager); }
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); }
private static void OnSaveDataDone(ChunkStateManagerServer stateManager) { stateManager.m_stateExternal = ChunkStateExternal.Saved; stateManager.m_completedStates = stateManager.m_completedStates.Set(CurrStateSaveData); stateManager.m_taskRunning = false; }
private static void OnSaveData(ChunkStateManagerServer stateManager) { Serialization.Serialization.SaveChunk(stateManager.chunk); OnSaveDataDone(stateManager); }
private static void OnLoadDataDone(ChunkStateManagerServer stateManager) { stateManager.m_completedStates = stateManager.m_completedStates.Set(CurrStateLoadData); stateManager.m_nextState = NextStateLoadData; stateManager.m_taskRunning = false; }
public static void OnGenerateDataOverNetworkDone(ChunkStateManagerServer stateManager) { OnGenerateDataDone(stateManager); OnLoadDataDone(stateManager); }
private static void OnGenericWorkDone(ChunkStateManagerServer chunk) { chunk.m_completedStates = chunk.m_completedStates.Set(CurrStateGenericWork); chunk.m_nextState = NextStateGenericWork; chunk.m_taskRunning = false; }
public SGenericWorkItem(ChunkStateManagerServer chunk, Action action) { Chunk = chunk; Action = action; }