Closed kuviman closed 5 months ago
This example code:
use evenio::prelude::*; #[derive(Event)] struct Init; #[derive(Component)] struct Foo; fn handler1(receiver: Receiver<Init>, mut sender: Sender<(Spawn, Insert<Foo>)>) { let a = sender.spawn(); sender.insert(a, Foo); let b = sender.spawn(); dbg!(b); } fn handler2(receiver: Receiver<Insert<Foo>, ()>, mut sender: Sender<Spawn>) { let c = sender.spawn(); dbg!(c); } fn main() { let mut world = World::new(); world.add_handler(handler1); world.add_handler(handler2); world.send(Init); }
says that b and c are both EntityId(1v1), which sounds completely wrong and they should be different entities
b
c
EntityId(1v1)
Im assuming that the actual spawning happens after the Insert event is handled so the handler2's Sender doesnt know about b's existence yet
Insert
handler2
Sender
Digging into this a little bit, it reserves a and b entities, spawns entity a, reserves c. spawns b and c. When reserving c ReservedEntities.iter returns the same entity loc as b.
This example code:
says that
b
andc
are bothEntityId(1v1)
, which sounds completely wrong and they should be different entitiesIm assuming that the actual spawning happens after the
Insert
event is handled so thehandler2
'sSender
doesnt know aboutb
's existence yet