Struct EntitiesAndComponentsThreadSafe

Source
pub struct EntitiesAndComponentsThreadSafe<'a> { /* private fields */ }
Expand description

This struct is a thread safe version of the EntitiesAndComponents struct It is used to allow systems to access the entities and components in parallel It will not allow any non send sync components to be accessed or added

Implementations§

Source§

impl<'b> EntitiesAndComponentsThreadSafe<'b>

Source

pub fn add_entity(&mut self) -> Entity

Adds an entity to the game engine Returns the entity

Source

pub fn add_entity_with<T: OwnedComponents<Input = T> + Send + Sync>( &mut self, components: T, ) -> Entity

Adds an entity to the game engine with components

Source

pub fn remove_entity(&mut self, entity: Entity)

Removes an entity from the game engine

Source

pub fn get_entities(&self) -> Vec<Entity>

Gets a reference to all the entities in the game engine Should rarely if ever be used

Source

pub fn get_nth_entity(&self, index: usize) -> Option<Entity>

Gets a copy of an entity at a certain index

Source

pub fn get_entity_count(&self) -> usize

Gets the number of entities in the game engine

Source

pub fn try_get_component<T: Component + Send + Sync>( &self, entity: Entity, ) -> Option<&Box<T>>

Gets a reference to a component on an entity If the component does not exist on the entity, it will return None

Source

pub fn try_get_component_mut<T: Component + Send + Sync>( &mut self, entity: Entity, ) -> Option<&mut Box<T>>

Gets a mutable reference to a component on an entity If the component does not exist on the entity, it will return None

Source

pub fn get_components<'a, T: ComponentsRef<'a> + Send + Sync + 'static>( &'a self, entity: Entity, ) -> T::Result

Gets a tuple of references to components on an entity If the component does not exist on the entity, it will panic

Source

pub fn get_components_mut<'a, T: ComponentsMut<'a> + Send + Sync + 'static>( &'a mut self, entity: Entity, ) -> T::Result

Gets a mutable reference to a component on an entity If the component does not exist on the entity, it will panic

Source

pub fn try_get_components<'a, T: TryComponentsRef<'a> + Send + Sync + 'static>( &'a self, entity: Entity, ) -> T::Result

Gets a tuple of references to components on an entity

Source

pub fn try_get_components_mut<'a, T: TryComponentsMut<'a> + Send + Sync + 'static>( &'a mut self, entity: Entity, ) -> T::Result

Gets a mutable reference to a component on an entity

Source

pub fn add_component_to<T: Component + Send + Sync>( &mut self, entity: Entity, component: T, )

Adds a component to an entity If the component already exists on the entity, it will be overwritten

Source

pub fn remove_component_from<T: Component + Send + Sync>( &mut self, entity: Entity, )

Removes a component from an entity

Source

pub fn get_entities_with_component<T: Component + Send + Sync>( &self, ) -> Flatten<IntoIter<Values<'_, DefaultKey, Entity>>>

returns an iterator over all entities with a certain component

Source

pub fn get_entity_count_with_component<T: Component + Send + Sync>( &self, ) -> usize

gets the number of entities with a certain component

Source

pub fn get_entity_with_component<T: Component + Send + Sync>( &self, index: usize, ) -> Option<Entity>

gets the nth entity with a certain component O(n) use get_entities_with_component if you need to iterate over all entities with a certain component

Source

pub fn get_resource<T: Resource + Send + Sync>(&self) -> Option<&T>

Gets a resource from the game engine

Source

pub fn add_resource<T: Resource + Send + Sync>(&mut self, resource: T)

Adds a resource to the game engine

Source

pub fn remove_resource<T: Resource + Send + Sync>(&mut self)

Removes a resource from the game engine

Source

pub fn get_resource_mut<T: Resource + Send + Sync>(&mut self) -> Option<&mut T>

Gets a resource from the game engine mutably, panics if the resource does not exist

Source

pub fn does_entity_exist(&self, entity: Entity) -> bool

Checks if an entity exists in the world

Source

pub fn get_children(&self, entity: Entity) -> Vec<Entity>

gets the children of an entity

Source

pub fn get_parent(&self, entity: Entity) -> Option<Entity>

gets the parent of an entity returns None if the entity is a root entity

Source

pub fn set_parent( &mut self, child_entity: Entity, parent_entity: Entity, ) -> bool

sets the parent of an entity if the entity already has a parent it will be changed returns true if the parent was set, false if the parent was not set (inverse relationship detected)

Source

pub fn remove_parent(&mut self, child_entity: Entity)

this function removes the link between a parent and a child making the child a root entity

Source

pub fn get_entities_with_children( &self, ) -> Flatten<IntoIter<Values<'_, DefaultKey, Entity>>>

gets the entities with children

Source

pub fn get_entities_with_parent( &self, ) -> Flatten<IntoIter<Values<'_, DefaultKey, Entity>>>

gets the entities with parents

Trait Implementations§

Auto Trait Implementations§

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
Source§

impl<T> Component for T
where T: 'static,