-
Hello 👋 What is the reason for the event package to use donburi.World instead of *ecs.ECS on the subscription? If an event is handled by a function (Subscriber), than the donburi.World argument is available. func (a *archetype) SpawnInWorld(world donburi.World, cs ...donburi.IComponentType) *donburi.Entry {
// where is it located? Is it placed in a layer?
e := world.Entry(world.Create(
append(a.components, cs...)...,
))
return e
}
func eventHandler(w donburi.World, e *event.Collide){
archetype.Settings.SpawnInWorld()
} I was wondering that the layers systems can not be utilized that easily this way. The following shows a entity creating with the ecs, that contains the world naturally. func (a *archetype) Spawn(ecs *ecs.ECS, cs ...donburi.IComponentType) *donburi.Entry {
e := ecs.World.Entry(ecs.Create(
layers.Default,
append(a.components, cs...)...,
))
return e
}
func eventHandler(w donburi.World, e *event.Collide){
// now located in the default layer
archetype.Settings.Spawn()
} So I would appreciate a reasoning for this design choice. :) Best regards, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello, the |
Beta Was this translation helpful? Give feedback.
Hello, the
ecs
package was an experimental feature and that's why the event package use World instance. I think we can improve the event package to allow us to use an ecs or a world instance (using Generics orany
). I'd very much welcome a contribution if anyone wants to work on it.