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