1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
use bwapi_sys as sys; use iterator::BwIterator; use position::Position; use from_raw::FromRaw; use std::os::raw::c_void as void; pub struct Region(*mut sys::Region); impl Region { pub fn id(&self) -> i32 { unsafe { sys::Region_getID(self.0) } } pub fn group_id(&self) -> i32 { unsafe { sys::Region_getRegionGroupID(self.0) } } pub fn center(&self) -> Position { Position::from( unsafe { sys::Region_getCenter(self.0) } ) } pub fn defense_priority(&self) -> i32 { unsafe { sys::Region_getDefensePriority(self.0) } } pub fn neighbors(&self) -> Box<Iterator<Item=Region>> { unsafe { let iter = sys::Region_getNeighbors(self.0) as *mut sys::Iterator; Box::new(BwIterator::from(iter)) } } } impl FromRaw for Region { unsafe fn from_raw(raw: *mut void) -> Region { assert!(!raw.is_null()); Region(raw as *mut sys::Region) } }