Struct ark_api::world::EntityMessenger
source · 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
impl EntityMessenger
sourcepub fn spatial_query_result(
&self,
id: u64
) -> MessageResponse<&[SpatialQueryHit]>
pub fn spatial_query_result( &self, id: u64 ) -> MessageResponse<&[SpatialQueryHit]>
Poll a spatial query request to see if a result has been received.
sourcepub fn animation_reply(&self, id: u64) -> MessageResponse<&AnimationReplyType>
pub fn animation_reply(&self, id: u64) -> MessageResponse<&AnimationReplyType>
Poll an animation request to see if a reply has been received.
sourcepub fn listen_collisions(&mut self, entity: Entity)
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).
sourcepub fn listen_triggers(&mut self, entity: Entity)
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).
sourcepub fn collisions(&mut self, entity: Entity) -> Option<Vec<OnCollision>>
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).
sourcepub fn triggers(&mut self, entity: Entity) -> Option<Vec<OnTrigger>>
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).
sourcepub fn global_queue(&mut self) -> &mut EntityMessageQueue
pub fn global_queue(&mut self) -> &mut EntityMessageQueue
Returns a global EntityMessageQueue that can be used to send
delayed messages from anywhere.
sourcepub fn send_messages(&mut self)
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
sourcepub fn submit_queue(&mut self, queue_to_submit: &mut EntityMessageQueue)
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.
sourcepub fn new_queue(&mut self) -> EntityMessageQueue
pub fn new_queue(&mut self) -> EntityMessageQueue
Creates a new EntityMessageQueue that can be used
for sending messages.
sourcepub fn set_allow_sending_messages_to_dead_entities(&mut self, allow: bool)
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
sourcepub fn process_messages(&mut self) -> usize
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.
sourcepub fn get() -> &'static mut Self
pub fn get() -> &'static mut Self
Get the EntityMessenger singleton.