Skip to main content

EntityMut

Struct EntityMut 

Source
pub struct EntityMut<'s, E: Copy + Eq + Hash + Send + Sync, W: WorldMutType<E>> { /* private fields */ }
Expand description

Scoped mutable handle for a client-owned entity.

Obtained from Client::entity_mut. Borrows Client for the duration of the handle, so only one EntityMut can be live at a time.

Unlike the server counterpart, the client has no static-entity concept — components may be inserted or removed freely while the client holds authority over the entity.

Implementations§

Source§

impl<'s, E: Copy + Eq + Hash + Send + Sync, W: WorldMutType<E>> EntityMut<'s, E, W>

Source

pub fn id(&self) -> E

Returns the underlying entity identifier.

Source

pub fn despawn(&mut self)

Despawns the entity locally and removes it from the replication layer.

Source

pub fn has_component<R: ReplicatedComponent>(&self) -> bool

Returns true if the entity currently carries component R.

Source

pub fn component<R: ReplicatedComponent>( &mut self, ) -> Option<ReplicaMutWrapper<'_, R>>

Returns a mutable accessor for component R, or None if the entity does not carry it.

Source

pub fn insert_component<R: ReplicatedComponent>( &mut self, component_ref: R, ) -> &mut Self

Inserts component R onto the entity and registers it for replication.

Source

pub fn remove_component<R: ReplicatedComponent>(&mut self) -> Option<R>

Removes component R from the entity, returning its value if present.

Source

pub fn configure_replication(&mut self, config: Publicity) -> &mut Self

Updates the Publicity for this entity. Returns &mut Self for chaining.

Source

pub fn replication_config(&self) -> Option<Publicity>

Returns the current Publicity, or None if the entity is not registered with the replication layer.

Source

pub fn authority(&self) -> Option<EntityAuthStatus>

Returns the current authority status for this entity, or None if the entity is not configured as Delegated.

Source

pub fn owner(&self) -> EntityOwner

Returns the current EntityOwner — who holds authoritative control over this entity right now.

Source

pub fn request_authority(&mut self) -> Result<&mut Self, AuthorityError>

Sends an authority request to the server for this delegated entity.

The server responds asynchronously with an EntityAuthGrantedEvent or EntityAuthDeniedEvent.

§Errors

Returns AuthorityError if the entity is not in a requestable state.

Source

pub fn release_authority(&mut self) -> Result<&mut Self, AuthorityError>

Releases the client’s authority over this entity back to the server.

§Errors

Returns AuthorityError if the entity is not currently client-authoritative.

Auto Trait Implementations§

§

impl<'s, E, W> Freeze for EntityMut<'s, E, W>
where W: Freeze, E: Freeze,

§

impl<'s, E, W> !RefUnwindSafe for EntityMut<'s, E, W>

§

impl<'s, E, W> Send for EntityMut<'s, E, W>
where W: Send,

§

impl<'s, E, W> Sync for EntityMut<'s, E, W>
where W: Sync,

§

impl<'s, E, W> Unpin for EntityMut<'s, E, W>
where W: Unpin, E: Unpin,

§

impl<'s, E, W> UnsafeUnpin for EntityMut<'s, E, W>
where W: UnsafeUnpin, E: UnsafeUnpin,

§

impl<'s, E, W> !UnwindSafe for EntityMut<'s, E, W>

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

Source§

fn vzip(self) -> V