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

Method sense_unit_at_location

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

The unit at the location, if it exists. LocationOffMap - the location is off the map. LocationNotVisible - the location is outside the vision range.

(&self, location: MapLocation)

Source from the content-addressed store, hash-verified

621 /// * LocationOffMap - the location is off the map.
622 /// * LocationNotVisible - the location is outside the vision range.
623 pub fn sense_unit_at_location(&self, location: MapLocation)
624 -> Result<Option<Unit>, GameError> {
625 self.ok_if_can_sense_location(location)?;
626 let unit_id = self.my_planet().units_by_loc.get(&location);
627 Ok(unit_id.map(|id| self.unit(*id).expect("unit exists").clone()))
628 }
629
630 // ************************************************************************
631 // ************************** WEATHER METHODS *****************************

Callers 1

test_replicateFunction · 0.45

Calls 4

my_planetMethod · 0.80
cloneMethod · 0.80
unitMethod · 0.45

Tested by 1

test_replicateFunction · 0.36