amico_core/world/
delegate.rs1use crate::ecs;
2
3#[derive(Debug)]
6pub struct HandlerRegistry<'world> {
7 pub(crate) world: &'world mut ecs::World,
8}
9
10impl HandlerRegistry<'_> {
11 pub fn register<M>(&mut self, handler: impl ecs::IntoHandler<M>) {
13 self.world.add_handler(handler);
14 }
15}
16
17pub struct ActionSender<'world> {
22 pub(crate) world: &'world mut ecs::World,
23}
24
25impl ActionSender<'_> {
26 pub fn send<E: ecs::GlobalEvent>(&mut self, event: E) {
28 self.world.send(event);
29 }
30
31 pub fn send_to<E: ecs::TargetedEvent>(&mut self, target: ecs::EntityId, event: E) {
33 self.world.send_to(target, event);
34 }
35}