pub struct Sender<'a, T>where
T: EventSet,{ /* private fields */ }
Expand description
A HandlerParam
for sending events from the set T
.
For more information, see the relevant tutorial chapter.
Implementations§
Source§impl<T> Sender<'_, T>where
T: EventSet,
impl<T> Sender<'_, T>where
T: EventSet,
Sourcepub fn send<E>(&mut self, event: E)where
E: GlobalEvent + 'static,
pub fn send<E>(&mut self, event: E)where
E: GlobalEvent + 'static,
Add a GlobalEvent
to the queue of events to send.
The queue is flushed once all handlers for the current event have run.
§Panics
- Panics if
E
is not in theEventSet
of this sender.
Sourcepub fn send_to<E>(&mut self, target: EntityId, event: E)where
E: TargetedEvent + 'static,
pub fn send_to<E>(&mut self, target: EntityId, event: E)where
E: TargetedEvent + 'static,
Add a TargetedEvent
to the queue of events to send.
The queue is flushed once all handlers for the current event have run.
Sourcepub fn spawn(&mut self) -> EntityId
pub fn spawn(&mut self) -> EntityId
Queue the creation of a new entity.
This returns the EntityId
of the to-be-spawned entity and queues the
Spawn
event. Note that the returned EntityId
may not be valid
until after the Spawn
event has finished broadcasting.
The new entity will be spawned without any components attached, and the
returned EntityId
will not have been used by any previous entities.
§Panics
Panics if Spawn
is not in the EventSet
of this sender.
Trait Implementations§
Source§impl<T> HandlerParam for Sender<'_, T>where
T: EventSet,
impl<T> HandlerParam for Sender<'_, T>where
T: EventSet,
Source§type This<'a> = Sender<'a, T>
type This<'a> = Sender<'a, T>
Self
but with the lifetime of 'a
.Source§fn init(
world: &mut World,
config: &mut HandlerConfig,
) -> Result<<Sender<'_, T> as HandlerParam>::State, InitError>
fn init( world: &mut World, config: &mut HandlerConfig, ) -> Result<<Sender<'_, T> as HandlerParam>::State, InitError>
Source§unsafe fn get<'a>(
state: &'a mut <Sender<'_, T> as HandlerParam>::State,
_info: &'a HandlerInfo,
_event_ptr: EventPtr<'a>,
_target_location: EntityLocation,
world: UnsafeWorldCell<'a>,
) -> <Sender<'_, T> as HandlerParam>::This<'a>
unsafe fn get<'a>( state: &'a mut <Sender<'_, T> as HandlerParam>::State, _info: &'a HandlerInfo, _event_ptr: EventPtr<'a>, _target_location: EntityLocation, world: UnsafeWorldCell<'a>, ) -> <Sender<'_, T> as HandlerParam>::This<'a>
Source§fn refresh_archetype(
_state: &mut <Sender<'_, T> as HandlerParam>::State,
_arch: &Archetype,
)
fn refresh_archetype( _state: &mut <Sender<'_, T> as HandlerParam>::State, _arch: &Archetype, )
Handler::refresh_archetype
is called.Source§fn remove_archetype(
_state: &mut <Sender<'_, T> as HandlerParam>::State,
_arch: &Archetype,
)
fn remove_archetype( _state: &mut <Sender<'_, T> as HandlerParam>::State, _arch: &Archetype, )
Handler::remove_archetype
is called.