Godot Version
4.7
Question
Hello, I need help with finding a decoupled way to queue and play UI animations sequentially without allowing user input or triggering ‘queue empty’ states mid-computation. I started to learn Godot recently and decided to build a turn based game with battles on a hex field.
The current problem I have is that I want to add animations and I need to make sure that no input is possible until they are over. I have an overburdened BattleFlowManager that handles the game state, calls GridOverlay to show highlights, hover effects, etc. Once the manager receives a signal that turn has ended, it has to do some cleaning, get the next character, calculate which hexes are traversable in this turn and which are visible from the current position. It doesn’t do it all on its own, it just manages, but it’s far from ideal. I don’t want to call animations with await as I want to keep processing data and then play animations as soon as its possible.
A real example I have. A character attacks an enemy with a skill that applies displacement by 1 hex. I try to move the enemy to the new position. If it has a non destructible obstacle - the enemy stays in their original position and gets some damage on impact. Otherwise, it moves to a new position. The new position can have a trap or some fire effect. So the potential sequence here can be to show displacement animation, apply effect, death animation.
The current code does: user inputs a skill - game state changes - create skill commands SequenceCommand[AttackCommand, DisplacementCommand] - CommandProcessor consumes them in order - calls resolvers inside the commands - emit message that all commands are processed - game state changes → User Can make a new input.
Now with the UI animations I need a new entity to handle it. The problem I see is that this new entity won’t know how many events to expect, so it might not be able to correctly tell when all the events are processed.
If an animation takes 0.1s and the next step’s logic/event generation takes 0.2s, the animation consumer might see an empty queue at 0.1s and prematurely declare the sequence complete.