Split Game
into gamestate and UI
#63
Labels
k: new system
a whole new system to integrate into the engine
p: tuig
tuig crate
s: runner
agent runners
Milestone
Currently,
Game
has two jobs:This kinda breaks in networked situations, and several other features would benefit greatly from it. In #28 I mused about one way to solve this (having the
Game
be able to return aState
at any time), but that doesn't solve the netcode issue -- or at least, it requires gamedevs to avoid a footgun, when there's a better way.Briefly,
Game
gets split intoGameState
(for the first responsibility -- though it's a global, shared view of the game state) andPlayerUI
(for the... UI). The gist is:Game
is cloned; the clone is passed to everyAgent
as it processes messages.Game
gets fed messages that theAgent
s are producing in this round. (SoAgent
s will only see theGame
as it was at the end of last round/beginning of this one, not as it's updated.)GameState
gets passed to thePlayerUI
-- and not any messages -- to render updates, ensuring it has the same view of the game state as agents in the current round.This design lets us sync the
GameState
across all networked players separately from any UI state, which there can still be. But that can get stored locally and doesn't need to be synced. It also forces devs into a design where their world state they care about tracking is separated into the sync'd type, where theGame::state
approach could let devs building the singleplayer first accidentally entwine a bunch of UI and game state logic and then have to untangle it later. Granted, this design suffers from the opposite issue as it risks UI state being embedded in the game state, but that seems like it'd be easier to untangle.Actually implementing this is gonna be kind of a bear, but hey, at least I'm doing this nice and early while the engine is still fluid and easy to change!
The text was updated successfully, but these errors were encountered: