NSSTC / sim-ecs

Batteries included TypeScript ECS
https://nsstc.github.io/sim-ecs/
Mozilla Public License 2.0
84 stars 12 forks source link

Support change detection #9

Closed minecrawler closed 1 year ago

minecrawler commented 4 years ago

Fire events when components are created, components are added/removed and deleted.

minecrawler commented 4 years ago

I guess I should change the scope to add/remove, because that's the only thing we can detect on an entity.

minecrawler commented 3 years ago

Now tracked on Kanban:

minecrawler commented 1 year ago

So I tested field-based changes, and while JS is a wonderful unicorn chewing gum and I can easily implement it, the performance is actually very bad (using Object.defineProperty.set) - especially for continually changing fields. Even if I create a wrapper which can be applied only to interesting components, it's bad. Iteration is faster if you just copy values over in a system, so that's what I recommend to do. Don't wait for mutation, just copy it.

With that, change events are handled. That's one of my oldest tickets, so cheers to closing it!