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

Method unit_ref

battlecode-engine/src/world.rs:445–453  ·  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

443 ///
444 /// * NoSuchUnit - the unit does not exist (inside the vision range).
445 pub fn unit_ref(&self, id: UnitID) -> Result<&Unit, GameError> {
446 if let Some(unit) = self.my_planet().units.get(&id) {
447 Ok(unit)
448 } else if let Some(unit) = self.my_team().units_in_space.get(&id) {
449 Ok(unit)
450 } else {
451 Err(GameError::NoSuchUnit)?
452 }
453 }
454
455 /// The single unit with this ID. Use this method to get detailed
456 /// statistics on a unit: heat, cooldowns, and properties of special

Callers

nothing calls this directly

Calls 2

my_planetMethod · 0.80
my_teamMethod · 0.80

Tested by

no test coverage detected