Inserts a new unit into the internal data structures of the game world, assuming it is on the map.
(&mut self, unit: Unit)
| 903 | /// Inserts a new unit into the internal data structures of the game world, |
| 904 | /// assuming it is on the map. |
| 905 | fn insert_unit(&mut self, unit: Unit) { |
| 906 | let id = unit.id(); |
| 907 | let location = unit.location().map_location().expect("unit is on map"); |
| 908 | self.get_planet_mut(location.planet).units.insert(id, unit); |
| 909 | self.get_planet_mut(location.planet).units_by_loc.insert(location, id); |
| 910 | } |
| 911 | |
| 912 | /// Creates and inserts a new unit into the game world, so that it can be |
| 913 | /// referenced by ID. Used for testing only!!! |
no test coverage detected