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

Method unit

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

The single unit with this ID. Use this method to get detailed statistics on a unit: heat, cooldowns, and properties of special abilities like units garrisoned in a rocket. NoSuchUnit - the unit does not exist (inside the vision range).

(&self, id: UnitID)

Source from the content-addressed store, hash-verified

473 ///
474 /// * NoSuchUnit - the unit does not exist (inside the vision range).
475 pub fn unit(&self, id: UnitID) -> Result<Unit, GameError> {
476 if let Some(unit) = self.my_planet().units.get(&id) {
477 Ok(unit.clone())
478 } else if let Some(unit) = self.my_team().units_in_space.get(&id) {
479 Ok(unit.clone())
480 } else {
481 Err(GameError::NoSuchUnit)?
482 }
483 }
484
485 /// All the units within the vision range, in no particular order.
486 /// Does not include units in space.

Callers 8

can_sense_unitMethod · 0.45
sense_nearby_unitsMethod · 0.45
destroy_unitMethod · 0.45
ok_if_can_attackMethod · 0.45
attackMethod · 0.45
ok_if_can_javelinMethod · 0.45
land_rocketMethod · 0.45

Calls 3

my_planetMethod · 0.80
cloneMethod · 0.80
my_teamMethod · 0.80

Tested by

no test coverage detected