Posted March 15, 2024 by Osaze Shears
#code-reflections #future-features #multiplayer
In this update to Synthicate, I made several changes to the code architecture to move away from huge monolithic files. In the past, I based all of the logic in two main scripts: `GameManager.cs` and `GameManagerScriptableObject.cs`. All of the state machine logic was also embedded in the `GameManager.cs`. This approach made it very difficult to iterate on Synthicate and add new features because I would have to hunt down every area that a state was checked and apply the new feature to that area.
With my new approach, I've created a series of game manager states that inherit from a base abstract game manager state class. This new technique allows me to quickly add new game states and change the flow of logic between the game states. One challenge with this new approach, however, was synchronizing the state of the game manager between the clients and the servers. In this version, I've taken an approach where if one client needs to send information to other clients that are in a different state, that sending client must access the state component that the other clients' game managers at "in" and call the RPC there. This makes the code a little tricky when tracking the different states of all the different client. However, I plan to move on with other features as opposed to thinking of the best way to tackle this issue at the moment.
In future updates I plan to add the following features: