MCPcopy Index your code
hub / github.com/battlecode/battlecode-2018 / insert_unit

Method insert_unit

battlecode-engine/src/world.rs:905–910  ·  view source on GitHub ↗

Inserts a new unit into the internal data structures of the game world, assuming it is on the map.

(&mut self, unit: Unit)

Source from the content-addressed store, hash-verified

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!!!

Callers 2

newMethod · 0.80
create_unitMethod · 0.80

Calls 4

idMethod · 0.80
map_locationMethod · 0.80
locationMethod · 0.80
get_planet_mutMethod · 0.80

Tested by

no test coverage detected