/// <summary> /// Takes a WorldDataMessage and reinitialize the WorldManager to work with the given options /// </summary> /// <param name="message">The WorldDataMessage to use for configuring</param> public void ApplyWorldInitData(WorldDataMessage message) { WorldOptions.ChunkSize = message.ChunkSize; WorldOptions.WorldChunkWidth = message.WorldChunkWidth; WorldOptions.WorldChunkHeight = message.WorldChunkHeight; WorldOptions.WorldScale = message.WorldScale; //This may be a different size now ChunkMap = new Chunk[WorldOptions.WorldChunkWidth, WorldOptions.WorldChunkHeight]; for (int y = 0; y < WorldOptions.WorldChunkHeight; y++) { for (int x = 0; x < WorldOptions.WorldChunkWidth; x++) { ChunkMap[x, y] = new Chunk(WorldOptions.ChunkSize, x, y, WorldOptions.WorldScale) { ChunkKey = message.ChunkMapIds[x, y], ChunkX = x, ChunkY = y } } } ; MapChunksToIndex(); }
void HandleMessage(WorldDataMessage msg) { m_world = new World(msg.WorldData, this.PlayerID); m_reportHandler = new ReportHandler(m_world); m_changeHandler = new ChangeHandler(m_world); }
/// <summary> /// Gets any initial data that a new connected player should have to initialize there world /// </summary> /// <returns>A DataMessage containing world meta information</returns> public WorldDataMessage GetInitWorldData() { WorldDataMessage worldData = new WorldDataMessage { ChunkSize = WorldOptions.ChunkSize, WorldChunkWidth = WorldOptions.WorldChunkWidth, WorldChunkHeight = WorldOptions.WorldChunkHeight, WorldScale = WorldOptions.WorldScale, ChunkMapIds = new string[WorldOptions.WorldChunkWidth, WorldOptions.WorldChunkHeight] }; for (int y = 0; y < WorldOptions.WorldChunkHeight; y++) { for (int x = 0; x < WorldOptions.WorldChunkWidth; x++) { worldData.ChunkMapIds[x, y] = ChunkMap[x, y].ChunkKey; } } return(worldData); }