| 113 | } |
| 114 | |
| 115 | VehicleTileInfo ControlGenerator::createVehicleInfo(GameState &state, sp<Vehicle> v) |
| 116 | { |
| 117 | VehicleTileInfo t; |
| 118 | t.vehicle = v; |
| 119 | t.selected = UnitSelectionState::Unselected; |
| 120 | |
| 121 | for (auto &veh : state.current_city->cityViewSelectedVehicles) |
| 122 | { |
| 123 | if (veh == v) |
| 124 | { |
| 125 | t.selected = (veh == state.current_city->cityViewSelectedVehicles.front()) |
| 126 | ? UnitSelectionState::FirstSelected |
| 127 | : UnitSelectionState::Selected; |
| 128 | break; |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | float maxHealth; |
| 133 | float currentHealth; |
| 134 | if (v->getShield() != 0) |
| 135 | { |
| 136 | maxHealth = v->getMaxShield(); |
| 137 | currentHealth = v->getShield(); |
| 138 | t.shield = true; |
| 139 | } |
| 140 | else |
| 141 | { |
| 142 | maxHealth = v->getMaxHealth(); |
| 143 | currentHealth = v->getHealth(); |
| 144 | t.shield = false; |
| 145 | } |
| 146 | |
| 147 | t.healthProportion = currentHealth / maxHealth; |
| 148 | // Clamp passengers to 13 as anything beyond that gets the same icon |
| 149 | t.passengers = std::min(13, v->getPassengers()); |
| 150 | // Faded if in other dimension or if haven't left dimension gate yet |
| 151 | t.faded = v->city != state.current_city || (!v->tileObject && !v->currentBuilding); |
| 152 | // Headed home if we have a mission and it's to our home building |
| 153 | if (!v->missions.empty()) |
| 154 | { |
| 155 | t.headedHome = v->missions.back().targetBuilding == v->homeBuilding || |
| 156 | v->missions.back().type == VehicleMission::MissionType::OfferService; |
| 157 | } |
| 158 | else |
| 159 | { |
| 160 | t.headedHome = false; |
| 161 | } |
| 162 | |
| 163 | auto b = v->currentBuilding; |
| 164 | if (b) |
| 165 | { |
| 166 | if (b == v->homeBuilding) |
| 167 | { |
| 168 | t.state = CityUnitState::InBase; |
| 169 | } |
| 170 | else |
| 171 | { |
| 172 | t.state = CityUnitState::InBuilding; |
nothing calls this directly
no test coverage detected