pub struct EntityMessenger { /* private fields */ }
Expand description

Utility for submitting message queues and collecting message responses.

For this to work, you must call EntityMessenger::get().process_messages(); first thing in your world_update.

Implementations§

source§

impl EntityMessenger

source

pub fn spatial_query_result( &self, id: u64 ) -> MessageResponse<&[SpatialQueryHit]>

Poll a spatial query request to see if a result has been received.

source

pub fn animation_reply(&self, id: u64) -> MessageResponse<&AnimationReplyType>

Poll an animation request to see if a reply has been received.

source

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

Register this entity as a listener for collision events

The entity needs a Physics component for this to work. If its collision events mask is set to 0 this function will automatically set it to listen to collisions from all layers (!0u64).

source

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

Register this entity as a listener for trigger events

The entity needs a Physics component for this to work. If its collision events mask is set to 0 this function will automatically set it to listen to collisions from all layers (!0u64).

source

pub fn collisions(&mut self, entity: Entity) -> Option<Vec<OnCollision>>

Will return a collision if is has been received, otherwise register a listener for collisions (collisions will be returned in a later invocation if they happen).

source

pub fn triggers(&mut self, entity: Entity) -> Option<Vec<OnTrigger>>

Will return a trigger event if is has been received, otherwise register a listener for trigger events (trigger events will be returned in a later invocation if they happen).

source

pub fn global_queue(&mut self) -> &mut EntityMessageQueue

Returns a global EntityMessageQueue that can be used to send delayed messages from anywhere.

source

pub fn send_messages(&mut self)

This can be called anytime to send away all globally pending messages, will otherwise be called from process_messages

source

pub fn submit_queue(&mut self, queue_to_submit: &mut EntityMessageQueue)

Submits an EntityMessageQueue

An EntityMessageQueue will however automatically be submitted when it goes out of scope.

source

pub fn new_queue(&mut self) -> EntityMessageQueue

Creates a new EntityMessageQueue that can be used for sending messages.

source

pub fn set_allow_sending_messages_to_dead_entities(&mut self, allow: bool)

Turn this on to allow sending messages to dead entities Useful for debugging

source

pub fn process_messages(&mut self) -> usize

This needs to be called first once per frame in the world update function as it sends pending messages and processes incoming messages and builds a database of all replies gathered.

These replies will be cleared every frame so one need to poll for replies every frame if one is expecting them.

source

pub fn get() -> &'static mut Self

Get the EntityMessenger singleton.

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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.
const: unstable · 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.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.