public Dictionary <Vec2i, ChunkData> GenerateAllSettlementChunks(SettlementBuilder setBuild, Settlement set) { Vec2i baseChunk = new Vec2i(setBuild.BaseCoord.x / World.ChunkSize, setBuild.BaseCoord.z / World.ChunkSize); Dictionary <Vec2i, ChunkData> setChunks = new Dictionary <Vec2i, ChunkData>(); int setSizeChunks = setBuild.TileSize / World.ChunkSize; for (int x = 0; x < setSizeChunks; x++) { for (int z = 0; z < setSizeChunks; z++) { ChunkBase cb = GameGenerator.TerrainGenerator.ChunkBases[baseChunk.x + x, baseChunk.z + z]; ChunkData cd = null; if (cb.RiverNode != null || cb.Lake != null) { cd = GameGenerator.ChunkGenerator.GenerateChunk(baseChunk.x + x, baseChunk.z + z); } else { int[,] cTiles = new int[World.ChunkSize, World.ChunkSize]; Dictionary <int, WorldObjectData> cObj = new Dictionary <int, WorldObjectData>(); for (int x_ = 0; x_ < World.ChunkSize; x_++) { for (int z_ = 0; z_ < World.ChunkSize; z_++) { Tile st = setBuild.Tiles[x * World.ChunkSize + x_, z *World.ChunkSize + z_]; cTiles[x_, z_] = st == null ? Tile.GRASS.ID : st.ID; cObj[WorldObject.ObjectPositionHash(x_, z_)] = setBuild.SettlementObjects[x * World.ChunkSize + x_, z *World.ChunkSize + z_]; if (setBuild.SettlementObjects[x * World.ChunkSize + x_, z *World.ChunkSize + z_] != null) { setBuild.SettlementObjects[x * World.ChunkSize + x_, z *World.ChunkSize + z_].SetPosition(new Vec2i(baseChunk.x + x + x_, baseChunk.z + z + z_)); } } } cd = new ChunkData(baseChunk.x + x, baseChunk.z + z, cTiles, true, cObj); } cd.SetSettlement(set); setChunks.Add(new Vec2i(cd.X, cd.Z), cd); } } set.AfterApplyToWorld(); return(setChunks); }