Finished refactoring for now. My player script went from 2339 LOC to 446, everything is nicely isolated and much easier to work with 🙌 #indiedev #gamedev #godot #godotengine

10:55 AM · Nov 22, 2021

16
29
0
293
I created a state machine that supports black-box states—they can operate without knowing of the others. Instead of specifying the next state, they can simply flag for the StateManager to figure out what the next state should be. This way I can maintain really loose coupling.
3
0
0
20
Augmentations are what I call similarily isolated features, but that aren't dependent on state. However, a state can disable an augmentation if desired, so that interaction is suspended while climbing or something.
1
0
0
17
As states are Spatials I can also place nodes relating to each state under it in the hierarchy and keep it visually isolated as well. Feeling pretty confident this will scale well for this game project.
2
0
0
16
Replying to @nsrosenqvist
Sounds awesome :) what is LOC?
1
0
0
1
Short for Lines Of Code (LOC)
0
0
0
1
Replying to @nsrosenqvist
Feels good to delete that many lines of code :)
1
0
0
2
Really does 😁
0
0
0
2
Replying to @nsrosenqvist
So, i don't know GDScript - what exactly did you do? Seems like there are nodes for different states, is this common practice?
2
0
0
4
There's no need to have these as nodes, they can just as well be pure scripts, but using nodes allows for isolating nodes in the scene hierarchy that only are relevant for one state, and also to easily set its exported properties.
0
0
0
9