Struct ark_api::world::EntityOwned

source ·
pub struct EntityOwned { /* private fields */ }
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.

This type will own its entity and destroy it when drop is called (i.e. when it goes out of scope).

Implementations§

source§

impl EntityOwned

source

pub fn is_valid(&self) -> bool

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

source

pub fn create_empty(name: &str) -> Self

Creates an empty world entity with just a name.

Add components of your preference to it.

source

pub fn create(name: &str) -> Self

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.

source

pub fn create_non_physics(name: &str) -> Self

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.

source

pub fn create_camera(name: &str) -> Self

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.

source

pub fn clone_entity(&self, name: &str) -> Self

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.

source

pub fn add_component(&self, component_type: ComponentType)

Adds a component to an entity.

source

pub fn add<T: ComponentTrait>(&self) -> T

Adds a component to an entity.

source

pub fn copy_component(&self, src: Entity, component_type: ComponentType)

Copies a component from the entity in src.

source

pub fn copy<T: ComponentTrait>(&self, src: Entity) -> T

Copies a component from the entity in src.

source

pub fn has<T: ComponentTrait>(&self) -> bool

Returns whether the entity has the component or not.

source

pub fn get<T: ComponentTrait>(&self) -> Option<T>

Gets an interface to the component.

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

source

pub fn has_component(&self, component_type: ComponentType) -> bool

Returns whether the entity has the component or not.

source

pub fn remove_component(&self, component_type: ComponentType)

Removes a component from an entity.

source

pub fn remove<T: ComponentTrait>(&self)

Removes a component from an entity.

source

pub fn mesh_style(&self) -> MeshStyle

Accessor for the MeshStyle component, if it exists.

source

pub fn transform(&self) -> Transform

Accessor for the Transform component, if it exists.

source

pub fn physics(&self) -> Physics

Accessor for the Physics component, if it exists.

source

pub fn render(&self) -> Render

Accessor for the Render component, if it exists.

source

pub fn d6_joint(&self) -> D6Joint

Accessor for the D6Joint component, if it exists.

source

pub fn camera(&self) -> Camera

Accessor for the Camera component, if it exists.

source

pub fn bounds(&self) -> Bounds

Accessor for the Bounds component, if it exists.

source

pub fn tag(&self) -> Tag

Accessor for the Tag component, if it exists.

source

pub fn layer(&self) -> Layer

Accessor for the Layer component, if it exists.

source

pub fn sdf_model(&self) -> SdfModel

Accessor for the Sdf component, if it exists.

source

pub fn audio_source(&self) -> AudioSource

Accessor for the AudioSource component, if it exists.

source

pub fn as_ffi(&self) -> EntityHandle

Gets the raw entity id.

source

pub fn as_entity(&self) -> Entity

Gets the inner Entity

source

pub fn name(&self) -> String

Retrieves the name of the entity

Trait Implementations§

source§

impl AsRef<Entity> for EntityOwned

source§

fn as_ref(&self) -> &Entity

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

impl Debug for EntityOwned

source§

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

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

impl Drop for EntityOwned

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl From<&EntityOwned> for Entity

source§

fn from(item: &EntityOwned) -> Self

Converts to this type from the input type.
source§

impl Hash for EntityOwned

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

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

impl PartialEq<EntityOwned> for EntityOwned

source§

fn eq(&self, other: &EntityOwned) -> 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 Eq for EntityOwned

source§

impl StructuralEq for EntityOwned

source§

impl StructuralPartialEq for EntityOwned

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.