logo
#[repr(transparent)]
pub struct Entity(pub EntityHandle);
Expand description

An Entity is a single “thing” in the gameworld.

It can have multiple components attached, giving it a position in the world, a mesh to display, physical properties, and so forth.

The Entity struct has accessors to access its components, like transform, mesh_style, physics and so on.

Represents a raw non-owned reference to an entity, an EntityHandle with functionality. Use EntityOwned if you want the entity to get destroyed if it goes out of scope.

Tuple Fields

0: EntityHandle

Implementations

Check if handle is valid

NOTE: This does not check whether there’s actually an entity represented by this entity handle. For that, use World::is_valid_entity.

Returns an eternally invalid entity handle.

Non-owning reference to an entity

Creates an empty world entity with just a name.

Add components of your preference to it.

Creates a world entity with Transform, Render, Physics, and MeshStyle components.

name - only used for display in the inspector and similar, it cannot later be changed or queried to affect the game so don’t store data in it.

Creates a world entity with Transform, Render and MeshStyle components.

name - only used for display in the inspector and similar, it cannot later be changed or queried to affect the game so don’t store data in it.

Creates a world entity with a Camera and Transform component.

An entity with a Camera component is special in that the rotation of its transform component will be controlled directly by the client. See the documentation of Camera for more details.

Creates a reference to an entity from an owned entity. This one won’t be owning the entity.

If the entity exists in the global arena, you can use this to get ownership of this entity

Lets you check whether this entity still exists and is valid.

Clones this world entity and all its components.

name - only used for display in the inspector and similar, it cannot later be changed or queried to affect the game so don’t store data in it. Will be concatenated to the name of the source of the clone.

Will always be cloned and placed in the global EntityArena.

Destroys the entity if it is in a global arena.

Further access to the entity (like by keeping the id around) after this is an error.

Schedules the entity for destruction if it is in a global arena. A call to EntityArena::global().destroy_pending_entities() will execute the order. Should usually be executed at the beginning of the update function to destroy entities after an update step.

Further access to the entity (like by keeping the id around) after EntityArena::global().destroy_pending_entities() has been executed is an error.

Adds a component to an entity.

Adds a component to an entity.

Copies a component from the entity in src.

Copies a component from the entity in src.

Returns whether the entity has the component or not.

Gets an interface to the component.

Returns an option, none if the component doesn’t exist.

Returns whether the entity has the component or not.

Removes a component from an entity.

Removes a component from an entity.

Retrieves the name of the entity

Accessor for the EntityInfo component, if it exists.

Accessor for the MeshStyle component, if it exists.

Accessor for the Transform component, if it exists.

Accessor for the Physics component, if it exists.

Accessor for the Render component, if it exists.

Accessor for the Joint component, if it exists.

Accessor for the D6Joint component, if it exists.

Accessor for the Camera component, if it exists.

Accessor for the Velocity component, if it exists.

Accessor for the Bounds component, if it exists.

Accessor for the Tag component, if it exists.

Accessor for the Layer component, if it exists.

Accessor for the PhysicsCharacter component, if it exists.

Accessor for the SdfModel component, if it exists.

Accessor for the AudioSource component, if it exists.

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

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

Wraps the passed-in value in a Value enum.

Extracts the value from a Value enum.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.