| 134 | StateRef<Organisation> GameState::getCivilian() { return this->civilian; } |
| 135 | |
| 136 | void GameState::initState() |
| 137 | { |
| 138 | if (current_battle) |
| 139 | { |
| 140 | current_battle->initBattle(*this); |
| 141 | } |
| 142 | |
| 143 | for (auto &c : this->cities) |
| 144 | { |
| 145 | auto &city = c.second; |
| 146 | for (auto &s : city->scenery) |
| 147 | { |
| 148 | for (auto &b : city->buildings) |
| 149 | { |
| 150 | auto &building = b.second; |
| 151 | Vec2<int> pos2d{s->initialPosition.x, s->initialPosition.y}; |
| 152 | if (building->bounds.within(pos2d)) |
| 153 | { |
| 154 | s->building = {this, building}; |
| 155 | if (s->isAlive() && !s->type->commonProperty) |
| 156 | { |
| 157 | s->building->buildingParts.insert(s->initialPosition); |
| 158 | } |
| 159 | break; |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | for (auto &c : this->cities) |
| 165 | { |
| 166 | auto &city = c.second; |
| 167 | city->initCity(*this); |
| 168 | if (newGame) |
| 169 | { |
| 170 | // if (c.first == "CITYMAP_HUMAN") |
| 171 | { |
| 172 | city->fillRoadSegmentMap(*this); |
| 173 | city->initialSceneryLinkUp(); |
| 174 | |
| 175 | // Use values provided with original maps for now |
| 176 | // Uncomment this if algoritm improves |
| 177 | // for (auto &b : c.second->buildings) |
| 178 | //{ |
| 179 | // b.second->initBuilding(*this); |
| 180 | //} |
| 181 | } |
| 182 | } |
| 183 | // Add vehicles to map |
| 184 | for (auto &v : this->vehicles) |
| 185 | { |
| 186 | auto vehicle = v.second; |
| 187 | if (vehicle->city == city && !vehicle->currentBuilding && !vehicle->betweenDimensions) |
| 188 | { |
| 189 | |
| 190 | city->map->addObjectToMap(*this, vehicle); |
| 191 | } |
| 192 | vehicle->strategyImages = city_common_image_list->strategyImages; |
| 193 | vehicle->setupMover(); |