Struct Entity

Source
pub struct Entity { /* private fields */ }
Expand description

An Entity can be nearly anything. A field, a wall, a creature. It has values to allow interactions to intermingle. Maybe walls can be teleported, or broken down. Maybe someone can capture a creature and use it later on.

Implementations§

Source§

impl Entity

Implementations for Entity that create standard default entities, such as,

  • Player
  • Specific Enemies
  • Walls
Source

pub fn new_player(x: i32, y: i32) -> Entity

Creates a good default player. Asks for a position.

Source

pub fn new_slimer_entity(x: i32, y: i32) -> Entity

Creates an evil slimer entity.

Source

pub fn new_wall(x: i32, y: i32, height: u32, width: u32) -> Entity

Creates a wall where you specify height, width and position.

Source§

impl Entity

Implementations of movement for the entity.

Source

pub fn get_move(&self, movement: Point) -> Rectangle

Returns a rectangle of the entity if it moved by movement amount.

Source

pub fn get_move_left(&self) -> Rectangle

Returns movement if the entity moved 1 left.

Source

pub fn get_move_right(&self) -> Rectangle

Returns movement if the entity moved 1 right.

Source

pub fn get_move_up(&self) -> Rectangle

Returns movement if the entity moved 1 up.

Source

pub fn get_move_down(&self) -> Rectangle

Returns movement if the entity moved 1 down.

Source

pub fn move_left(&mut self)

Moves the entity one left. Should usually be used with get_move_left first. May be removed in future versions.

Source

pub fn move_right(&mut self)

Moves the entity one right. Should usually be used with get_move_right first. May be removed in future versions.

Source

pub fn move_up(&mut self)

Moves the entity one up. Should usually be used with get_move_up first. May be removed in future versions.

Source

pub fn move_down(&mut self)

Moves the entity one down. Should usually be used with get_move_down first. May be removed in future versions.

Source§

impl Entity

Source

pub fn new() -> EntityBuilder

Creates an instance of EntityBuilder to start building and Entity.

Source

pub fn get_position(&self) -> Point

Returns the current position of the entity.

Source

pub fn get_size(&self) -> Dimension

Returns the size of the entity.

Source

pub fn get_rectangle(&self) -> Rectangle

Returns both the size and position of an entity using a Rectangle.

Source

pub fn get_skin(&self) -> Skin

Returns the skin of the entity.

Source

pub fn get_abilities(&self) -> &Abilities

Returns a reference to the abilities of an entity.

Source§

impl Entity

AI logic here. Should only need to call perform_turn for the object to do what it thinks is best. Almost certainly will become a trait.

Source

pub fn perform_turn(&mut self, data: &mut Data)

The entity performs an action based on its environment.

Trait Implementations§

Source§

impl Clone for Entity

Source§

fn clone(&self) -> Entity

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Entity

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Entity

Source§

fn eq(&self, other: &Entity) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Entity

Auto Trait Implementations§

§

impl Freeze for Entity

§

impl RefUnwindSafe for Entity

§

impl Send for Entity

§

impl Sync for Entity

§

impl Unpin for Entity

§

impl UnwindSafe for Entity

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.