Clockwork TD Devlog #3: CursorState FSM


This is the third post in an ongoing series about the development of my thesis project, Clockwork TD.

Rather than define separate game states Building, Moving, Selling, etc., I chose to create a separate FSM for the cursor state. Like the game states, each of the cursor states is strongly defined as a ScriptableObject; this makes it easy to add new game & cursor states and also to access them from anywhere in the project. The base CursorState includes abstract & virtual methods to override, depending on the desired behavior of the current state.

As in the GameStates, CursorStates have Entered and Exited events that can be subscribed to, as well as OnEnter() and OnExit() methods for inheriting CursorStates to override. Buildable and Tile both implement the “IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler” interfaces, calling back to the current CursorState during those mouse events. This allows the code for say, Building to be fairly straightforward (incomplete code but you can get the gist — oh I just got why github named it that).

To keep reading this devlog and see the example code & gifs, visit:

https://onewinter.net/2023/07/11/clockwork-td-devlog-3-cursorstate-fsm/

Get Terrorformer TD

Leave a comment

Log in with itch.io to leave a comment.