For this game I wanted to use a Finite State Machine to handle my gameplay states.
An example of such a system is if you think of your game as a connection of screens, for example:
On caveat I don’t like is that, sometimes a component needs to call the attachedEntities version of a function it has overridden. For example handleInput, it might call the attachedEntities handleInput functions and then with the new movementVector multiply them by negative 1 so now all input while this component is active is reversed.
When I intercept the properties, currently I wrap intercepted function calls into a closure ( see BaseComponent.intercept() ) so that the ‘
this‘ object can refer to the component itself. Without that the ‘this’ object was still being referred to as the attachedEntity (from within the components version of that function), so to get the components properties I had to run a query.
So I’m curious what others think of this implementation.
Things I used as reference: