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

Method create_unit

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

Creates and inserts a new unit into the game world, so that it can be referenced by ID. Used for testing only!!! ResearchLevelInvalid - the research level is invalid.

(&mut self, team: Team, location: MapLocation,
                       unit_type: UnitType)

Source from the content-addressed store, hash-verified

914 ///
915 /// * ResearchLevelInvalid - the research level is invalid.
916 pub(crate) fn create_unit(&mut self, team: Team, location: MapLocation,
917 unit_type: UnitType) -> Result<UnitID, GameError> {
918 let id = self.id_generator.next_id();
919 let level = self.get_team(team).research.get_level(&unit_type);
920 let unit = Unit::new(id, team, unit_type, level, OnMap(location))?;
921
922 self.insert_unit(unit);
923 Ok(id)
924 }
925
926 /// Destroys a unit. Removes any traces of it.
927 ///

Callers 15

blueprintMethod · 0.80
replicateMethod · 0.80
test_unit_disintegrateFunction · 0.80
test_unit_createFunction · 0.80
test_unit_moveFunction · 0.80
test_knight_javelinFunction · 0.80
test_mage_blinkFunction · 0.80
test_ranger_snipeFunction · 0.80
test_healer_overchargeFunction · 0.80
test_rocket_successFunction · 0.80
test_rocket_failureFunction · 0.80

Calls 4

next_idMethod · 0.80
get_levelMethod · 0.80
get_teamMethod · 0.80
insert_unitMethod · 0.80

Tested by 15

test_unit_disintegrateFunction · 0.64
test_unit_createFunction · 0.64
test_unit_moveFunction · 0.64
test_knight_javelinFunction · 0.64
test_mage_blinkFunction · 0.64
test_ranger_snipeFunction · 0.64
test_healer_overchargeFunction · 0.64
test_rocket_successFunction · 0.64
test_rocket_failureFunction · 0.64
test_rocket_loadFunction · 0.64
test_rocket_unloadFunction · 0.64