π Break down the status effect state machine into smaller steps #421
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
β¨ What's this?
This PR breaks the existing logic for elemental status effects into smaller steps that different scopes can hook into.
π Why do we want this?
For multiple status effects we were doing a bit of a hacky approach where we were reapplying their upgrade every tick. With this approach, there are now multiple points where the scopes can hook into changes to the active effect so they can only update certain things when needed.
π How is it done?
The lifecycle of status effects is now as follows:
StartScopeout ElementalStatusto apply a status iconStartEffectStartScope)ChangeStatuson the passed in context object to change the status icon to something newApplyEffectTickEndEffectStartEffect)StartEffect, including undoing their effects if neededEndScopeStartScopeAs mentioned in the table above, I passed in a context object in
StartEffectthat allows modifying the status. Perhaps it can be used for other things as well. Taking this approach a step further, we could even have the context object automatically be responsible for cleanup (e.g.context.ApplyUpgrade(upgrade)could automatically undo that upgrade when the effect ends). For now, I decided to stick to the bare minimal requirements to see if this approach is worth pursuing at all.π‘ Review hints