[][src]Trait akashi::Entity

pub trait Entity: Sized + 'static {
    fn new(
        id: Snowflake,
        component_manager: Arc<ComponentManager<Self>>,
        components_attached: HashSet<TypeId>
    ) -> Self;
fn id(&self) -> Snowflake;
fn dirty(&self) -> bool;
fn dirty_mut(&mut self) -> &mut bool;
fn component_manager(&self) -> &ComponentManager<Self>;
fn components_attached(&self) -> &HashSet<TypeId>;
fn components_attached_mut(&mut self) -> &mut HashSet<TypeId>; fn get_component<T: Component<Self> + 'static>(
        &self
    ) -> Result<Option<T>, Error> { ... }
fn set_component<T: Component<Self> + 'static>(
        &mut self,
        component: T
    ) -> Result<(), Error> { ... }
fn has_component<T: Component<Self> + 'static>(&self) -> bool { ... }
fn delete_component<T: Component<Self> + 'static>(
        &mut self
    ) -> Result<(), Error> { ... }
fn clear_components(&mut self) -> Result<(), ClearComponentsError> { ... } }

Represents an Entity within Akashi's Entity-Component-System architecture.

Entities, on their own, are essentially just a unique ID and a collection of attached Components.

The two main Entity types that Akashi provides are Players and Cards.

Errors

Many of the methods provided by this trait wrap similar methods on ComponentManager objects, which in turn wrap a number of Component storage objects. Errors reported by those will bubble up through these methods.

Additionally, attempts to perform operations with Component types for which no backing store has been registered with ComponentManager::register_component will return TypeNotFoundError.

Required methods

fn new(
    id: Snowflake,
    component_manager: Arc<ComponentManager<Self>>,
    components_attached: HashSet<TypeId>
) -> Self

fn id(&self) -> Snowflake

Gets the unique ID used to identify this Entity and its Components.

fn dirty(&self) -> bool

Checks whether any Components have been modified on this Entity.

fn dirty_mut(&mut self) -> &mut bool

Get this entity's 'dirty' flag.

fn component_manager(&self) -> &ComponentManager<Self>

Gets a reference to the ComponentManager used to perform operations on this Entity.

fn components_attached(&self) -> &HashSet<TypeId>

Gets a reference to a HashSet containing the TypeIds of each Component attached to this Entity.

fn components_attached_mut(&mut self) -> &mut HashSet<TypeId>

Gets a mutable reference to the HashSet of attached component TypeIds.

Loading content...

Provided methods

fn get_component<T: Component<Self> + 'static>(
    &self
) -> Result<Option<T>, Error>

Gets a Component attached to this Entity.

fn set_component<T: Component<Self> + 'static>(
    &mut self,
    component: T
) -> Result<(), Error>

Attaches a Component to this Entity, or updates an already-attached Component.

fn has_component<T: Component<Self> + 'static>(&self) -> bool

Checks to see if the given Component type has been attached to this Entity.

Unlike most of the other Entity trait methods, this doesn't return a TypeNotFoundError for Components without an associated backing store. Instead, it will just return false.

fn delete_component<T: Component<Self> + 'static>(
    &mut self
) -> Result<(), Error>

Deletes an attached Component from this Entity.

fn clear_components(&mut self) -> Result<(), ClearComponentsError>

Delete all Components attached to this Entity.

Errors

Any errors reported by the backing storage objects for Components attached to this Entity will be collected into a ClearComponentsError.

Loading content...

Implementors

impl Entity for Card[src]

impl Entity for CardType[src]

impl Entity for Player[src]

Loading content...