resonance 1.0.1
Loading...
Searching...
No Matches
gamemanagerimpl.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include "app/msgqueue.h"
6#include "app/msgsink.h"
7#include "game/gameparams.h"
8#include "game/gamestats.h"
9#include "game/grooveworld.h"
10#include "game/inputpoller.h"
11#include "game/metagameworld.h"
12#include "met/metpersonadata.h"
13#include "msg/message.h"
14#include "os/hxstr.h"
15#include "stream/ibstream.h"
16#include "stream/obstream.h"
17
18class GamePlaybacker;
19class GameRecorder;
20
28
35
111class GameManagerImpl : public MsgSink {
112public:
127
137
150 virtual void DrawFrame();
151
163 virtual void DrawFrameSimple();
164
173 virtual void StartPlay();
174
185 virtual void StartRecording();
186
202 virtual void Recreate(const HxStr &file, int nUnusedFlag);
203
213 virtual int GetWorldLoadFlag();
214
226 virtual void AddPersona(const MetPersonaData &persona);
227
237 virtual std::vector<MetPersonaData *> *GetPersonas();
238
248 virtual void ClearPersonas();
249
258 virtual void Start();
259
272 virtual void PollPlayback();
273
284
295
306
316 virtual int GetUnwrittenValue();
317
328 virtual GameStats *GetStats();
329
340 virtual void Save(OBStream *pStream);
341
356 virtual void Load(IBStream *pStream);
357
367 virtual int IsPlaybackActive();
368
381 virtual void SetGameMode(int nMode);
382
392 virtual int GetGameMode();
393
404
415 virtual int GetChangeCount();
416
427 virtual void SetParams(const GameParams &params);
428
440 virtual void SetDifficulty(int nDifficulty);
441
454 virtual void SetPlayMode(int nMode);
455
465 virtual int GetDifficulty();
466
476 virtual int GetPlayMode();
477
488 virtual void QueueMessage(Message *pMsg);
489
500 virtual void SetDrawEnabled(int nEnabled);
501
502protected:
510 virtual void DispatchPriv(Message *pMsg);
511
526 virtual void OnBeginGameLocal(Message *pMsg);
527
537 virtual void OnEndGame(Message *pMsg);
538
551 virtual void OnPauseGameSystem(Message *pMsg);
552
564 virtual void OnUnpauseGameSystem(Message *pMsg);
565
576 virtual void OnDoPlayback(Message *pMsg);
577
578private:
588 int CheckState();
589
598 void RunStateCheck();
599
609 void DestroyWorld();
610
621 void CreateWorld();
622
632 void FinishWorldLoad();
633
642 void AddPlayers();
643
653 void AddPersonaPlayers();
654
664 void EndGame(int bRestart);
665
666 // A state word. The two diagnostics StartRecording() and Recreate() trip both describe it
667 // as the state, and both fire when it is non-zero. Load() is the only writer recovered, so its
668 // value set is unrecovered.
669 int mState; // +0x04
670 // A word Save() writes and Load() restores between mState and mGameMode. No other routine
671 // reads or writes it.
672 int mSavedWord; // +0x08
673 GrooveWorld *mpWorld; // +0x0c
674 InputPoller *mpPoller; // +0x10
675 MetaGameWorld *mpMetaWorld; // +0x14
676 // Not written by the constructor and not written anywhere recovered.
677 int mUnwrittenValue; // +0x18
678 std::vector<MetPersonaData *> mPersonas; // +0x1c
679 GameStats mStats; // +0x28
680 GameParams mParams; // +0x68
681 // The connectivity mode, one of the four values SetGameMode() publishes.
682 int mGameMode; // +0xa0
683 int mChangeCount; // +0xa4
684 // Set by Start() and by EndGame() on a return to the front end, and cleared by
685 // OnBeginGameLocal(). DrawFrame() runs MemcardManager::Update() while it is set, so memory-card
686 // work advances only in the front end.
687 int mFrontEndActive; // +0xa8
688 GameRecorder *mpRecorder; // +0xac the recorder StartRecording() installs
689 GamePlaybacker *mpPlayback; // +0xb0 the playback Recreate() installs
690 // The constructor clears both of its words and the destructor frees the buffer at +0xb8 only
691 // when it is set, which is HxStr's own destruction. Nothing recovered writes it otherwise.
692 HxStr mUnusedString; // +0xb4
693 // Neither written by the constructor nor touched anywhere recovered. The field exists
694 // because the queue starts at +0xc0 while the run of cleared fields ends at +0xb8, so four
695 // bytes sit between them.
696 int mPadBeforeQueue; // +0xbc
697 MsgQueue mQueue; // +0xc0
698 // Set by the constructor, FinishWorldLoad(), and Load(), and never cleared.
699 // GetWorldLoadFlag() is its one reader.
700 int mWorldLoadFlag; // +0xfc
701 // Set by EndGame() on a restart. OnBeginGameLocal() clears it, and while it is set, skips the
702 // front-end world's forwarder.
703 int mRestartPending; // +0x100
704 // Set by OnPauseGameSystem() and cleared by OnUnpauseGameSystem(), each of which returns early
705 // on the value it would write.
706 int mPaused; // +0x104
707 // The inverse of SetDrawEnabled()'s argument. The constructor sets it, so a fresh manager draws
708 // nothing.
709 int mDrawSuppressed; // +0x108
710};
virtual GrooveWorld * GetWorld()
Resolve the world a game session runs in.
virtual void SetParams(const GameParams &params)
Replace the settings and republish the two modes.
virtual int GetUnwrittenValue()
Report a word that only the constructor writes.
virtual void OnUnpauseGameSystem(Message *pMsg)
Resume the session.
virtual void Load(IBStream *pStream)
Read the manager back from a stream.
virtual void StartPlay()
Starts play on the game world.
virtual int GetDifficulty()
Report the difficulty.
virtual void Recreate(const HxStr &file, int nUnusedFlag)
Replay a recorded session from a file.
virtual void OnBeginGameLocal(Message *pMsg)
Enter a local game.
virtual ~GameManagerImpl()
Destroy the recorder, the front-end world, the poller, the queue, and the tally.
virtual void QueueMessage(Message *pMsg)
Store a message on the embedded queue.
virtual void Save(OBStream *pStream)
Write the manager to a stream.
virtual int GetGameMode()
Resolve the connectivity mode.
virtual void SetGameMode(int nMode)
Record the connectivity mode and publish it to the script layer.
virtual void SetPlayMode(int nMode)
Record the play mode and publish it to the script layer.
virtual int IsPlaybackActive()
Report whether a playback is running.
virtual void OnDoPlayback(Message *pMsg)
Replay the recording the script layer nominates.
GameManagerImpl()
Build the manager, its input poller, and its message queue.
virtual MetaGameWorld * GetMetaWorld()
Resolve the front-end world.
virtual GameStats * GetStats()
Resolve the tally.
virtual void ClearPersonas()
Delete every persona on the roster and empty it.
virtual int GetPlayMode()
Resolve the play mode.
virtual int GetChangeCount()
Report how many times the settings have changed.
virtual void DrawFrameSimple()
Redraw the front-end world alone.
virtual void OnPauseGameSystem(Message *pMsg)
Pause the session.
virtual int GetWorldLoadFlag()
Report the flag the world load sets.
virtual std::vector< MetPersonaData * > * GetPersonas()
Resolve the roster.
virtual void Start()
Create the front-end world and hand it to the poller.
virtual void PollPlayback()
Poll the controllers, and end a playback when a button is pressed.
virtual void OnEndGame(Message *pMsg)
Leave the game.
virtual InputPoller * GetPoller()
Resolve the controller reader.
virtual GameParams * GetParams()
Resolve the settings a session starts with.
virtual void StartRecording()
Start recording the session.
virtual void DrawFrame()
Draw one frame.
virtual void AddPersona(const MetPersonaData &persona)
Copy one persona onto the roster.
virtual void DispatchPriv(Message *pMsg)
Act on a message.
virtual void SetDrawEnabled(int nEnabled)
Enable or suppress drawing.
virtual void SetDifficulty(int nDifficulty)
Record the difficulty and publish it to the script layer.
Settings a game session is started with.
Definition gameparams.h:42
Playback of a recorded game session that GameManagerImpl::Recreate() installs.
Definition gameplaybacker.h:12
Recording of a game session that GameManagerImpl::StartRecording() installs.
Definition gamerecorder.h:13
Running tally a game session accumulates.
Definition gamestats.h:27
Owner of the world a game session runs in.
Definition grooveworld.h:66
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
Input half of the byte stream interface.
Definition ibstream.h:36
Reader of the physical controllers.
Definition inputpoller.h:32
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:41
Saved record of one player persona.
Definition metpersonadata.h:39
Owner of the front-end world, outside a game session.
Definition metagameworld.h:26
Relay that stores a copy of every message it accepts and forwards to its own sinks.
Definition msgqueue.h:34
Receiver of engine messages.
Definition msgsink.h:37
Output half of the byte stream interface.
Definition obstream.h:25
PlayMode
Kind of a session, recorded by GameManagerImpl::SetPlayMode().
Definition gamemanagerimpl.h:34
@ kPlayModeGame
Definition gamemanagerimpl.h:34
@ kPlayModeJam
Definition gamemanagerimpl.h:34
@ kPlayModeNone
Definition gamemanagerimpl.h:34
GameMode
Connectivity of a session, recorded by GameManagerImpl::SetGameMode().
Definition gamemanagerimpl.h:27
@ kGameModeNet
Definition gamemanagerimpl.h:27
@ kGameModeNone
Definition gamemanagerimpl.h:27
@ kGameModeLocal
Definition gamemanagerimpl.h:27
@ kGameModeSolo
Definition gamemanagerimpl.h:27