What I want to do is refactor a lot of the client code.
Right now basically the entire client game is handled by a single class that can found here:client.h
This is slowly becoming/ is a God Object/ God Class, meaning it is responsible for way too much.
It works fine, and I am low key afraid to change it as right now it is pretty easy to do things, but of course this can rapidly get out of hand.
It has the following responsibilities, all to do with gameplay:
- Connect the client to the server
- Handles player input
- Handles incoming network packets from the server
- Handles sending outgoing packets to the server
- Loads all the shaders of the game
- Handles chunks
- Renders players of the world
- Renders the world itself
Although this works, I feel it is doing a bit too much and so want to find a way (if possible) to split out the responsibility a bit, as eventually, this would just become a huge multi-thousand line class.
What I propose is some kind of refactor, with the intent to be that the rendering, netcode, world code etc should be split out as their own class.
This would also make it easier to delegate responsibilities in the client lua code.
For example, right now it simply wouldn't be possible to make a button for a main menu that creates a new world*, whereas if this is done correctly it could be pretty easily done while not violating things like SOLID or whatever.
*where create a new world:
- Pop main menu gui
- Push loading GUI
- Starts a local server
- Connects the client to the server
- (Maybe have a callback to detect the client has successfully connected to the server?)
- Pop loading GUI
- Push HUD/In-Game GUI
- Etc?
The steps listed above seems like a good initial goal for this, which I am currently working on.
Definitely open to ideas on how to achieve more maintainability for the client code, which is what this issue is for :)
(And later, server code)
Other ideas/ Notes (just 1 for now lol):
Opening a chest, how could this work?
- Player right clicks a chest
- Server receives a "block interaction event"
- Server sees it is a chest
- Server sends back request to client to open the "chest GUI"