public void Reposition(RemoteFortressReader.BlockList input) { int diff_x = input.map_x - map_coords.x; int diff_y = input.map_y - map_coords.y; coordinates.x += (diff_x * 3); coordinates.y += (diff_y * 3); map_coords.x = input.map_x; map_coords.y = input.map_y; SetUnityPosition(); }
public float GetLongitudeFromWorld(RemoteFortressReader.WorldMap world) { float tude = Mathf.InverseLerp(0, world.world_height, world.center_y); switch (world.world_poles) { case RemoteFortressReader.WorldPoles.NO_POLES: return 0; case RemoteFortressReader.WorldPoles.NORTH_POLE: tude = (1-tude) * 90; break; case RemoteFortressReader.WorldPoles.SOUTH_POLE: tude = tude * 90; break; case RemoteFortressReader.WorldPoles.BOTH_POLES: tude = ((tude * 2) - 1) * -180; break; default: return 0; } return tude; }
public void StoreTiles(RemoteFortressReader.MapBlock block) { bool setTiles = block.tiles.Count > 0; bool setLiquids = block.water.Count > 0 || block.magma.Count > 0; if (!setTiles && !setLiquids) return; for (int xx = 0; xx < 16; xx++) for (int yy = 0; yy < 16; yy++) { DFCoord worldCoord = new DFCoord(block.map_x + xx, block.map_y + yy, block.map_z); DFCoord localCoord = WorldToLocalSpace(worldCoord); int netIndex = xx + (yy * 16); tilesPresent[PresentIndex(localCoord.x, localCoord.y, localCoord.z)] = true; if (setTiles) { tiles[localCoord.x, localCoord.y, localCoord.z].tileType = block.tiles[netIndex]; tiles[localCoord.x, localCoord.y, localCoord.z].material = block.materials[netIndex]; tiles[localCoord.x, localCoord.y, localCoord.z].base_material = block.base_materials[netIndex]; tiles[localCoord.x, localCoord.y, localCoord.z].layer_material = block.layer_materials[netIndex]; tiles[localCoord.x, localCoord.y, localCoord.z].vein_material = block.vein_materials[netIndex]; tiles[localCoord.x, localCoord.y, localCoord.z].construction_item = block.construction_items[netIndex]; } if (setLiquids) { tiles[localCoord.x, localCoord.y, localCoord.z].waterLevel = block.water[netIndex]; tiles[localCoord.x, localCoord.y, localCoord.z].magmaLevel = block.magma[netIndex]; } } }
public void StoreTiles(RemoteFortressReader.MapBlock block, out bool setTiles, out bool setLiquids, out bool setSpatters) { setTiles = block.tiles.Count > 0; setLiquids = block.water.Count > 0 || block.magma.Count > 0; setSpatters = block.spatterPile.Count > 0; if (!setTiles && !setLiquids) return; for (int xx = 0; xx < 16; xx++) for (int yy = 0; yy < 16; yy++) { DFCoord worldCoord = new DFCoord(block.map_x + xx, block.map_y + yy, block.map_z); if (!InSliceBounds(worldCoord)) { Debug.LogError(worldCoord + " is out of bounds for " + MapSize); return; } int netIndex = xx + (yy * 16); if (this[worldCoord] == null) this[worldCoord] = new Tile(this, worldCoord); if (block.tiles.Count > 0) { this[worldCoord].tileType = block.tiles[netIndex]; this[worldCoord].material = block.materials[netIndex]; this[worldCoord].base_material = block.base_materials[netIndex]; this[worldCoord].layer_material = block.layer_materials[netIndex]; this[worldCoord].vein_material = block.vein_materials[netIndex]; if (block.construction_items != null && block.construction_items.Count > netIndex) this[worldCoord].construction_item = block.construction_items[netIndex]; else this[worldCoord].construction_item = new MatPairStruct(-1, -1); if (block.tree_percent != null && block.tree_percent.Count > netIndex) { this[worldCoord].trunkPercent = (byte)block.tree_percent[netIndex]; this[worldCoord].positionOnTree = new DFCoord(block.tree_x[netIndex], block.tree_y[netIndex], block.tree_z[netIndex]); } else { this[worldCoord].trunkPercent = 0; this[worldCoord].positionOnTree = new DFCoord(0,0,0); } } if (setLiquids) { this[worldCoord].waterLevel = block.water[netIndex]; this[worldCoord].magmaLevel = block.magma[netIndex]; if (this[worldCoord].Hidden != block.hidden[netIndex]) { this[worldCoord].Hidden = block.hidden[netIndex]; setTiles = true; } if (block.tile_dig_designation != null && block.tile_dig_designation.Count > netIndex) { if (this[worldCoord].digDesignation != block.tile_dig_designation[netIndex]) { this[worldCoord].digDesignation = block.tile_dig_designation[netIndex]; setTiles = true; } } } if(setSpatters) { this[worldCoord].spatters = block.spatterPile[netIndex].spatters; } } foreach (var building in block.buildings) { if (building.building_type.building_type == 30) continue; // We won't do civzones right now. for (int xx = building.pos_x_min; xx <= building.pos_x_max; xx++) for (int yy = building.pos_y_min; yy <= building.pos_y_max; yy++) { if((building.building_type.building_type == 29) && building.room != null && building.room.extents.Count > 0) { int buildingLocalX = xx - building.room.pos_x; int buildingLocalY = yy - building.room.pos_y; if (building.room.extents[buildingLocalY * building.room.width + buildingLocalX] == 0) continue; } DFCoord worldCoord = new DFCoord(xx,yy, block.map_z); DFCoord2d buildingLocalCoord = GetRotatedLocalCoord(worldCoord, building);// = new DFCoord2d(xx - building.pos_x_min, yy - building.pos_y_min); if (!InSliceBounds(worldCoord)) { Debug.LogError(worldCoord + " is out of bounds for " + MapSize); continue; } if (this[worldCoord] == null) this[worldCoord] = new Tile(this, worldCoord); this[worldCoord].buildingType = building.building_type; this[worldCoord].buildingMaterial = building.material; this[worldCoord].buildingLocalPos = buildingLocalCoord; this[worldCoord].buildingDirection = building.direction; } } }
public void SetAllTiles(RemoteFortressReader.MapBlock DFBlock, RemoteFortressReader.BlockList blockList, RemoteFortressReader.TiletypeList tiletypeList) { if (DFBlock.tiles.Count != terrain.Length) { Debug.LogError("Map Block has " + DFBlock.tiles.Count + " tiles, should be " + terrain.Length); } for (int i = 0; i < DFBlock.tiles.Count; i++) { terrain[i] = tiletypeList.tiletype_list[DFBlock.tiles[i]].shape; colors[i] = Color.white; } SetOpenness(); coordinates.x = DFBlock.map_x; coordinates.y = DFBlock.map_y; coordinates.z = DFBlock.map_z; map_coords.x = blockList.map_x; map_coords.y = blockList.map_y; SetUnityPosition(); }
public void StoreTiles(RemoteFortressReader.MapBlock block, out bool setTiles, out bool setLiquids) { setTiles = block.tiles.Count > 0; setLiquids = block.water.Count > 0 || block.magma.Count > 0; if (!setTiles && !setLiquids) return; for (int xx = 0; xx < 16; xx++) for (int yy = 0; yy < 16; yy++) { DFCoord worldCoord = new DFCoord(block.map_x + xx, block.map_y + yy, block.map_z); DFCoord localCoord = WorldToLocalSpace(worldCoord); if (!InSliceBoundsLocal(localCoord)) { Debug.LogError(worldCoord + " is out of bounds for " + MapSize); return; } int netIndex = xx + (yy * 16); if (tiles[localCoord.x, localCoord.y, localCoord.z] == null) tiles[localCoord.x, localCoord.y, localCoord.z] = new Tile(this, localCoord); if (block.tiles.Count > 0) { tiles[localCoord.x, localCoord.y, localCoord.z].tileType = block.tiles[netIndex]; tiles[localCoord.x, localCoord.y, localCoord.z].material = block.materials[netIndex]; tiles[localCoord.x, localCoord.y, localCoord.z].base_material = block.base_materials[netIndex]; tiles[localCoord.x, localCoord.y, localCoord.z].layer_material = block.layer_materials[netIndex]; tiles[localCoord.x, localCoord.y, localCoord.z].vein_material = block.vein_materials[netIndex]; if (block.construction_items != null && block.construction_items.Count > netIndex) tiles[localCoord.x, localCoord.y, localCoord.z].construction_item = block.construction_items[netIndex]; else tiles[localCoord.x, localCoord.y, localCoord.z].construction_item = new MatPairStruct(-1, -1); } if (setLiquids) { tiles[localCoord.x, localCoord.y, localCoord.z].waterLevel = block.water[netIndex]; tiles[localCoord.x, localCoord.y, localCoord.z].magmaLevel = block.magma[netIndex]; if (tiles[localCoord.x, localCoord.y, localCoord.z].hidden != block.hidden[netIndex]) { tiles[localCoord.x, localCoord.y, localCoord.z].hidden = false;// = block.hidden[netIndex]; //feature held off untill later. //setTiles = true; } } } foreach (var building in block.buildings) { if (building.building_type.building_type == 30) continue; // We won't do civzones right now. for (int xx = building.pos_x_min; xx <= building.pos_x_max; xx++) for (int yy = building.pos_y_min; yy <= building.pos_y_max; yy++) { if((building.building_type.building_type == 29) && building.room != null && building.room.extents.Count > 0) { int buildingLocalX = xx - building.room.pos_x; int buildingLocalY = yy - building.room.pos_y; if (building.room.extents[buildingLocalY * building.room.width + buildingLocalX] == 0) continue; } DFCoord worldCoord = new DFCoord(xx,yy, block.map_z); DFCoord localCoord = WorldToLocalSpace(worldCoord); DFCoord2d buildingLocalCoord = GetRotatedLocalCoord(worldCoord, building);// = new DFCoord2d(xx - building.pos_x_min, yy - building.pos_y_min); if (!InSliceBoundsLocal(localCoord)) { Debug.LogError(worldCoord + " is out of bounds for " + MapSize); continue; } if (tiles[localCoord.x, localCoord.y, localCoord.z] == null) tiles[localCoord.x, localCoord.y, localCoord.z] = new Tile(this, localCoord); tiles[localCoord.x, localCoord.y, localCoord.z].buildingType = building.building_type; tiles[localCoord.x, localCoord.y, localCoord.z].buildingMaterial = building.material; tiles[localCoord.x, localCoord.y, localCoord.z].buildingLocalPos = buildingLocalCoord; tiles[localCoord.x, localCoord.y, localCoord.z].buildingDirection = building.direction; } } }
public RegionTile(RemoteFortressReader.RegionTile tile) { elevation = tile.elevation; water_elevation = tile.water_elevation; rainfall = tile.rainfall; vegetation = tile.vegetation; temperature = tile.temperature; evilness = tile.evilness; drainage = tile.drainage; volcanism = tile.volcanism; savagery = tile.savagery; salinity = tile.salinity; rivers = tile.river_tiles; surfaceMaterial = tile.surface_material; plantMaterials = new List<MatPairStruct>(); foreach (var item in tile.plant_materials) { plantMaterials.Add(item); } buildings = tile.buildings; stoneMaterials = new List<MatPairStruct>(); foreach (var item in tile.stone_materials) { stoneMaterials.Add(item); } treeMaterials = new List<MatPairStruct>(); foreach (var item in tile.tree_materials) { treeMaterials.Add(item); } snow = tile.snow; }
void addSeasonalUpdates(RemoteFortressReader.MapBlock block, int mapBlockX, int mapBlockY, int mapBlockZ) { if (DFConnection.Instance.NetPlantRawList == null) return; mapBlockX /= blockSize; mapBlockY /= blockSize; if (blockUpdateSchedules[mapBlockX, mapBlockY, mapBlockZ] != null) blockUpdateSchedules[mapBlockX, mapBlockY, mapBlockZ].Clear(); foreach (var material in block.materials) { if (material.mat_type != 419 || material.mat_index < 0 || DFConnection.Instance.NetPlantRawList.plant_raws.Count <= material.mat_index || DFConnection.Instance.NetPlantRawList.plant_raws[material.mat_index].growths.Count == 0) continue; PlantRaw plantRaw = DFConnection.Instance.NetPlantRawList.plant_raws[material.mat_index]; if (blockUpdateSchedules[mapBlockX, mapBlockY, mapBlockZ] == null) blockUpdateSchedules[mapBlockX, mapBlockY, mapBlockZ] = new UpdateSchedule(); var schedule = blockUpdateSchedules[mapBlockX, mapBlockY, mapBlockZ]; foreach (TreeGrowth growth in plantRaw.growths) { schedule.Add(growth.timing_start); schedule.Add(growth.timing_end); foreach (GrowthPrint print in growth.prints) { schedule.Add(print.timing_start); schedule.Add(print.timing_end); } } } }
public void StoreTiles(RemoteFortressReader.MapBlock block) { bool setTiles = block.tiles.Count > 0; bool setLiquids = block.water.Count > 0 || block.magma.Count > 0; if (!setTiles && !setLiquids) return; for (int xx = 0; xx < 16; xx++) for (int yy = 0; yy < 16; yy++) { DFCoord worldCoord = new DFCoord(block.map_x + xx, block.map_y + yy, block.map_z); DFCoord localCoord = WorldToLocalSpace(worldCoord); if (!InSliceBoundsLocal(localCoord)) { Debug.LogError(worldCoord + " is out of bounds for " + MapSize); return; } int netIndex = xx + (yy * 16); tilesPresent[PresentIndex(localCoord.x, localCoord.y, localCoord.z)] = true; if (setTiles) { tiles[localCoord.x, localCoord.y, localCoord.z].tileType = block.tiles[netIndex]; tiles[localCoord.x, localCoord.y, localCoord.z].material = block.materials[netIndex]; tiles[localCoord.x, localCoord.y, localCoord.z].base_material = block.base_materials[netIndex]; tiles[localCoord.x, localCoord.y, localCoord.z].layer_material = block.layer_materials[netIndex]; tiles[localCoord.x, localCoord.y, localCoord.z].vein_material = block.vein_materials[netIndex]; if (block.construction_items != null && block.construction_items.Count > netIndex) tiles[localCoord.x, localCoord.y, localCoord.z].construction_item = block.construction_items[netIndex]; else tiles[localCoord.x, localCoord.y, localCoord.z].construction_item = new MatPairStruct(-1, -1); } if (setLiquids) { tiles[localCoord.x, localCoord.y, localCoord.z].waterLevel = block.water[netIndex]; tiles[localCoord.x, localCoord.y, localCoord.z].magmaLevel = block.magma[netIndex]; } } foreach (var building in block.buildings) { for (int xx = building.pos_x_min; xx <= building.pos_x_max; xx++) for (int yy = building.pos_y_min; yy <= building.pos_y_max; yy++) { if((building.building_type.building_type == 29 || building.building_type.building_type == 29) && building.room != null && building.room.extents.Count > 0) { int buildingLocalX = xx - building.room.pos_x; int buildingLocalY = yy - building.room.pos_y; if (building.room.extents[buildingLocalY * building.room.width + buildingLocalX] == 0) continue; } DFCoord worldCoord = new DFCoord(xx,yy, block.map_z); DFCoord localCoord = WorldToLocalSpace(worldCoord); DFCoord2d buildingLocalCoord = new DFCoord2d(xx - building.pos_x_min, yy - building.pos_y_min); if (!InSliceBoundsLocal(localCoord)) { Debug.LogError(worldCoord + " is out of bounds for " + MapSize); continue; } tilesPresent[PresentIndex(localCoord.x, localCoord.y, localCoord.z)] = true; tiles[localCoord.x, localCoord.y, localCoord.z].buildingType = building.building_type; tiles[localCoord.x, localCoord.y, localCoord.z].buildingMaterial = building.material; tiles[localCoord.x, localCoord.y, localCoord.z].buildingLocalPos = buildingLocalCoord; } } }