I want to implement a Tekken-Style Combo-/ Input-System.
The basic system i want to realize is, processing a timed sequence of inputs. Example: In Tekken, I have 4 Input Buttons(excluding directional Buttons). Each of them corresponds to a basic Character Action.
Square = Left Jab
Triangle = Right Jab
Circle = High Kick
X = Low Kick
When pressing one of those Buttons the Action executes. For a short period of time after that, the Character is in a state in which each of the Input Buttons (or only a subset of them, depending on the Character's move list) corresponds to a different Character Action. If I manage to press a Button in time the Combo and this Pattern continues until the end of the Combo. If i fail to push a Button in time, the Character returns to it's idle state.
I had the idea of using a Tree to represent all Combos of a Character as a Datastructure.
The buliding blocks are the following...
1. Input(Type: enum): For example the square on a PS4 Controller.
2. Action(Type: enum): A command that is send to the Character when an Input is given.
3. Timing(Type: float or int): A time window for a specific Input of a ComboNode.
4. ComboNode(Type: user defined): Several Inputs where each Input maps to a Triple.
5. Triple (Type: user defined): An Action, a Timing and a set of ComboNodes(ChildComboNodes).
How the Tree would update itself:
1. Check for inputs in current ComboNode while at least one timing is still valid.
2. Pressed Input.
3. Send corresponding Action to Character.
4. Set current to ChildComboNode.
5. Repeat until Combo ends or no timings are valid. In those 2 cases, return to root.
I would appreciate advice or comments :)