Noah2610 / deathfloor

Work-in-progress Mega Man inspired game.
MIT License
2 stars 0 forks source link

Root entity config events are reset when switching variant #60

Open Noah2610 opened 4 years ago

Noah2610 commented 4 years ago

When switching variant, the entity's global events (non-variant specific events) are reset / re-inserted. Global events should be persistent when switching variants.

Noticeable example with Interval event.

Noah2610 commented 4 years ago

The way events and entity config variants are setup right now, this isn't too easy to fix. So I won't fix this for now.

So just keep this in mind: Switching variants is like re-applying root events and variant events, which resets stuff like timers (for Interval and Delay events).


Explanation

The EventsRegister stores temporary data, which it uses for events like Interval and Delay for their timers, and when switching variants this data is cleared (on purpose). What would need to happen to fix this, is only clearing the variant's data and keeping all root data when switching variant. This way any root event timers should still be active after switching variants.

The problem is, that the concept of "variants" only exists on entity configs. But the events/actions system is handled with the EventsRegister, which does not have variants. The EventsRegister simply gets its events by merging the entity config's root and active variant events together. So the EventsRegister doesn't know which data belongs to root events and which to variant events.