Skip to main content
8 events
when toggle format what by license comment
Jun 17, 2021 at 15:23 comment added DMGregory I read Philipp's answer as saying "keep executable code out of the component". So the component wouldn't directly contain a lambda or function pointer for example. But that doesn't preclude the component from containing data that informs how to handle its events. Say you have a "Collision Tag" that you can apply to tag a Collider component. The collision system can then place the collision event into a distinct queue depending on the tag(s) on the colliders involved. Then your DamageCollisionSystem needs only process the collisions in the DamageCollision tag queue, without all the branching.
Jun 17, 2021 at 14:58 comment added Ryan Peschel @DMGregory Ahh, now I'm really unsure, as Philip's answer basically says "go with #2" and your comment is saying #2 could be a mess. How would I direct my events? For example, my CollisionSystem simply detects whether or not there is a collision between two entities. Are you saying it should also determine what sorts of entities they are and then create events other than just CollisionEvents?
Jun 17, 2021 at 14:29 comment added DMGregory Option 2 looks like it could grow into an absolute mess of if checks for various conditions or sprawling switch statements as your game evolves. Is there any way you could direct your events into separate queues for each handler, so that the handler can process just the relevant events consecutively, without a lot of case selection in the middle of that loop?
Jun 17, 2021 at 14:21 comment added Evorlor Not a direct answer to your question, but I think you are missing some of the concepts of ECS. This answer here is what helped me learn them, so it may help you as well. gamedev.stackexchange.com/a/31491/41345
Jun 17, 2021 at 14:08 answer added Philipp timeline score: 2
Jun 17, 2021 at 13:40 history edited Ryan Peschel CC BY-SA 4.0
added 164 characters in body
Jun 17, 2021 at 13:39 history edited DMGregory
edited tags
Jun 17, 2021 at 13:28 history asked Ryan Peschel CC BY-SA 4.0