Struct rust_warrior::unit::Unit
source · [−]pub struct Unit {
pub unit_type: UnitType,
pub position: (i32, i32),
pub hp: (i32, i32),
pub atk: i32,
pub facing: Option<Direction>,
}Expand description
The state of a unit: its position, current/max hp, and atk power.
Fields
unit_type: UnitTypeposition: (i32, i32)hp: (i32, i32)atk: i32facing: Option<Direction>Implementations
sourceimpl Unit
impl Unit
sourcepub fn new(unit_type: UnitType, position: (i32, i32)) -> Unit
pub fn new(unit_type: UnitType, position: (i32, i32)) -> Unit
Create a unit of type unit_type at position.
sourcepub fn archer(position: (i32, i32)) -> Unit
pub fn archer(position: (i32, i32)) -> Unit
Create a unit of type Archer (7 HP, 3 ATK) at position.
sourcepub fn captive(position: (i32, i32)) -> Unit
pub fn captive(position: (i32, i32)) -> Unit
Create a unit of type Captive (1 HP, 0 ATK) at position.
sourcepub fn sludge(position: (i32, i32)) -> Unit
pub fn sludge(position: (i32, i32)) -> Unit
Create a unit of type Sludge (12 HP, 3 ATK) at position.
sourcepub fn thick_sludge(position: (i32, i32)) -> Unit
pub fn thick_sludge(position: (i32, i32)) -> Unit
Create a unit of type ThickSludge (18 HP, 3 ATK) at position.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Unit
impl Send for Unit
impl Sync for Unit
impl Unpin for Unit
impl UnwindSafe for Unit
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more