Struct ambient_api::ecs::Entity

source ·
pub struct Entity(/* private fields */);
Expand description

An Entity is a collection of components and associated values.

Use the spawn method to insert the Entity into the world.

Implementations§

source§

impl Entity

source

pub fn new() -> Entity

Creates a new Entity.

source

pub fn len(&self) -> usize

Returns the number of component (values) in the entity.

source

pub fn is_empty(&self) -> bool

Returns true if the entity has no components (values).

source

pub fn has<T>(&self, component: Component<T>) -> bool
where T: SupportedValue,

Returns true if this has component.

source

pub fn has_components(&self, components: &[&dyn UntypedComponent]) -> bool

Returns true if this has all of components.

source

pub fn get<T>(&self, component: Component<T>) -> Option<T>
where T: SupportedValue,

Gets the data for component in this, if it exists.

source

pub fn get_ref<T>(&self, component: Component<T>) -> Option<&T>
where T: SupportedValueRef,

Gets a reference to the data for component in this, if it exists.

source

pub fn set<T>(&mut self, component: Component<T>, value: T)
where T: SupportedValue,

Adds component to this with value. It will replace an existing component if present.

source

pub fn set_default<T>(&mut self, component: Component<T>)

Sets the component in this to the default value for T.

source

pub fn with<T>(self, component: Component<T>, value: T) -> Entity
where T: SupportedValue,

Adds component to this with value, and returns self to allow for easy chaining.

source

pub fn with_merge(self, other: impl Into<Entity>) -> Entity

Merges in the other Entity and returns this; any fields that were present in both will be replaced by other’s.

source

pub fn without<T>(self, component: Component<T>) -> Entity
where T: SupportedValue,

Removes component to this with value, and returns self to allow for easy chaining.

source

pub fn remove<T>(&mut self, component: Component<T>) -> Option<T>
where T: SupportedValue,

Removes the specified component from this, and returns the value if it was present.

source

pub fn merge(&mut self, other: Entity)

Merges in the other Entity; any fields that were present in both will be replaced by other’s.

source

pub fn spawn(&self) -> EntityId

Spawns an entity with these components.

Returns spawned_entity_uid.

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<(), Error>

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

impl Default for Entity

source§

fn default() -> Entity

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Entity

source§

fn deserialize<__D>( __deserializer: __D ) -> Result<Entity, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T> From<T> for Entity
where T: Concept,

source§

fn from(concept: T) -> Entity

Converts to this type from the input type.
source§

impl PartialEq for Entity

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Entity

source§

fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for Entity

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> AsAny for T
where T: Any,

source§

fn as_any(&self) -> &(dyn Any + 'static)

source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

source§

fn type_name(&self) -> &'static str

Gets the type name of self
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> Downcast for T
where T: AsAny + ?Sized,

source§

fn is<T>(&self) -> bool
where T: AsAny,

Returns true if the boxed type is the same as T. Read more
source§

fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny,

Forward to the method defined on the type Any.
source§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny,

Forward to the method defined on the type Any.
source§

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

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> ElementComponentName for T

source§

fn element_component_name(&self) -> &'static str

Returns the name of the type implementing ElementComponent.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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,

§

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>,

§

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>,

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> AnyCloneable for T
where T: Clone + Debug + Any + 'static,

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,