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: UnitType
§position: (i32, i32)
§hp: (i32, i32)
§atk: i32
§facing: Option<Direction>
Implementations§
Source§impl 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 Freeze for Unit
impl RefUnwindSafe for Unit
impl Send for Unit
impl Sync for Unit
impl Unpin for Unit
impl UnwindSafe for Unit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more