| 1191 | } |
| 1192 | |
| 1193 | void AEquipScreen::addItemToInventoryBase(sp<AEquipment> item) |
| 1194 | { |
| 1195 | // Expecting to have an agent |
| 1196 | auto currentAgent = selectedAgents.front(); |
| 1197 | |
| 1198 | // Find base which is in the current building |
| 1199 | StateRef<Base> base = getAgentBase(currentAgent); |
| 1200 | |
| 1201 | // Unload ammunition and add it too |
| 1202 | sp<AEquipment> ammo = nullptr; |
| 1203 | if (item->payloadType) |
| 1204 | { |
| 1205 | ammo = mksp<AEquipment>(); |
| 1206 | ammo->type = item->payloadType; |
| 1207 | ammo->ammo = item->ammo; |
| 1208 | item->ammo = 0; |
| 1209 | item->payloadType.clear(); |
| 1210 | addItemToInventoryBase(ammo); |
| 1211 | } |
| 1212 | |
| 1213 | if (item->type->type == AEquipmentType::Type::Ammo) |
| 1214 | { |
| 1215 | base->inventoryAgentEquipment[item->type->id] += item->ammo; |
| 1216 | } |
| 1217 | else |
| 1218 | { |
| 1219 | base->inventoryAgentEquipment[item->type->id]++; |
| 1220 | } |
| 1221 | } |
| 1222 | |
| 1223 | void AEquipScreen::addItemToInventoryAgent(sp<AEquipment> item) |
| 1224 | { |