Apian-Framework / BeamGameCode

Engine-independent C# core game code for Beam
0 stars 0 forks source link

Fix the whole FEModeHelper thing #30

Closed jimkberry closed 2 years ago

jimkberry commented 2 years ago

Currently I<App>Frontend defines the way the application code talks to the frontend (CLI/Unity, at the moment) It's the responsibility of each platform to have a suitable frontend class that implements the interface.

For the most part it's a pretty straightforward API, but it gets a little tricky when there are AppMode-specific things that various AppMode's want to tell the frontend to do.

As it stands, there an IFrontEndModeHelper interface which.. well - it's kinda messy. Needs to be simplified because:

jimkberry commented 2 years ago

Approach will be:

Get rid of IFrontendModeHelper.DispatchCmd() altogether. The interface will only have StartMode and EndMode.

StartMode(modeId) will return a reference to a mode-specific subclass which the mode can talk to directly to do the things it wants to do.

Poof! Simple.

jimkberry commented 2 years ago

Or.. get rid of IFrontendModeHelper completely. Leave StartMode() and EndMode() in IBeamFrontend but use them to have the FE code subscribe/unsubscribe to events that a particular mode publishes and invokes.

Not completely sure which approach I prefer. The 2nd is simpler, but the first seems more cross-language ( C# events sometimes seem kinda "magic" and C#-specific)

jimkberry commented 2 years ago

Going with the events. Turns out there really aren't very many that come from GameMode code