resonance 1.0.1
Loading...
Searching...
No Matches
gamer.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include "app/msgsink.h"
6#include "app/msgsource.h"
7#include "mid/tick.h"
8#include "sch/cmdid.h"
9
11class BGTrackGraph;
12class CrippleMsg;
14class EnableMgr;
15class GameStats;
16class Globals;
17class Message;
19class PhraseDatabase;
20class PlaybackModeMsg;
21class PlayMap;
22class Player;
23class ScoreTrackGraph;
24class TrackData;
25
47class Gamer : public MsgSink, public MsgSource {
48public:
62 Gamer(int nTrackCount, int nEndBar, GameStats *pStats);
63
70 virtual ~Gamer();
71
80 void Withdraw();
81
93 virtual void DispatchPriv(Message *pMsg);
94
108 void CreateEnableMgr(std::vector<ScoreTrackGraph *> *pGraphs);
109
122 void SetBarOwner(int nTrack, int nBar, Player *pPlayer);
123
136 int QueryBar(int nTrack, int nBar);
137
146 bool IsFreestyleTrack(int nTrack) const;
147
157
166 TrackData *GetTrack(int nTrack) const;
167
180 void OnBar(int nBar);
181
190 void Start();
191
202 void SetBackGraphs(std::vector<BGTrackGraph *> *pGraphs);
203
215 void EnablePlayerFreestyle(int nStartBar, int nEndBar);
216
226 void AddJuice(int nAmount);
227
239 void EndWithScore(int nScore);
240
251 void AdvanceAt(Sch::Tick position);
252
253private:
262 void OnMsg(const AdvanceSectionMsg &msg);
263
271 void OnPhraseCaptured(PhraseCapturedMsg *pMsg);
272
280 void OnEnableFreestyle(EnableFreestyleMsg *pMsg);
281
289 void OnPlaybackMode(PlaybackModeMsg *pMsg);
290
298 void OnCripple(CrippleMsg *pMsg);
299
309 void ScheduleBar(int nBar);
310
321 void AdvanceTo(int nBar, int nAdvance);
322
332 bool SendTracksOn(int nBar);
333
343 bool FreeTracksAfterCapture(int nBar);
344
354 void DeclareWinners();
355
365 void RecordSoloStats(int bCompleted, int nBar);
366
367 // How the game has ended. The constructor starts at kEndStateNone.
368 enum EndState {
369 kEndStateNone = 0,
370 kEndStateWon = 1,
371 kEndStateOver = 2,
372 };
373
374 int mTutorial; // +0x18 set in the tutorial
375
376public:
385
386private:
387 // Never read or written by a recovered routine, the constructor included.
388 int mReserved; // +0x20
389 int mEndBar; // +0x24 the bar the game ends at
390 int mEndState; // +0x28 an EndState
391 int mPlayMode; // +0x2c
392 int mGameMode; // +0x30
393 int mJukeboxMode; // +0x34
394 // The bar OnBar() last ran for. No recovered routine reads it.
395 int mCurrentBar; // +0x38
396 // Bars past the following step that AdvanceTo() invalidates, from configuration code 702.
397 int mInvalidateBars; // +0x3c
398 int mTrackCount; // +0x40
399 // The constructor writes 2 here and 0 in the next word, and no recovered routine reads the two.
400 int mUnreadSetting; // +0x44
401 int mUnreadFlag; // +0x48
402 int mPlaybackOn; // +0x4c
403 // Whether the section at the playback toggle repeats, as PlayMap slot 14 reports it, and 1 once
404 // playback stops. No recovered routine reads it.
405 int mSectionRepeats; // +0x50
406 Globals *mGlobals; // +0x54
407 GameStats *mStats; // +0x58
408 Sch::Tick mBarLength; // +0x5c
409 std::vector<Player *> mPlayers; // +0x60
410 Sch::CmdID mCommand; // +0x6c
411 std::vector<BGTrackGraph *> *mBackGraphs; // +0x70
412 std::vector<ScoreTrackGraph *> *mGraphs; // +0x74
413
414public:
421 std::vector<MsgSource> mTrackSources;
422
423private:
424 // The end of the last freestyle span given to a player. No recovered routine reads it.
425 int mFreestyleEndBar; // +0x84
426 int mFreeEndBar; // +0x88 the end bar non-catch tracks are free until
427 PlayMap *mPlayMap; // +0x8c
428
429public:
437
438private:
439 EnableMgr *mBackEnableMgr; // +0x94
440
441public:
450};
Event the game passes between a MsgSource and a MsgSink.
Definition advancesectionmsg.h:24
Audio graph of one background track.
Definition bgtrackgraph.h:24
Event the game passes between a MsgSource and a MsgSink.
Definition cripplemsg.h:25
Event the game passes between a MsgSource and a MsgSink.
Definition enablefreestylemsg.h:24
Policy that decides which tracks a player may catch at each bar.
Definition enablemgr.h:16
Running tally a game session accumulates.
Definition gamestats.h:27
EnableMgr * mEnableMgr
Per-track enable policy.
Definition gamer.h:436
virtual ~Gamer()
Withdraw the queued command and delete both enable policies.
int mJuiceFrozen
Non-zero while the per-bar juice charge is suspended.
Definition gamer.h:384
void OnBar(int nBar)
Run the update of one bar and schedule the next.
bool IsFreestyleTrack(int nTrack) const
Report whether one track is outside catch mode.
void EndWithScore(int nScore)
End the game at the next bar, optionally with a score for the first player.
void Withdraw()
Withdraw every command queued under mCommand from the song clock.
PhraseDatabase * GetPhraseDatabase(int nTrack)
Report the phrase database of one track's graph.
int mCheated
Non-zero once a cheat ran during the game.
Definition gamer.h:449
void EnablePlayerFreestyle(int nStartBar, int nEndBar)
Give the first player a freestyle span.
Gamer(int nTrackCount, int nEndBar, GameStats *pStats)
Build the participant's view for a level.
void AdvanceAt(Sch::Tick position)
Advance to the bar of a position, with PlayMap::ToggleLoop() of that bar as the advance.
void Start()
Schedule the first bar's update.
void CreateEnableMgr(std::vector< ScoreTrackGraph * > *pGraphs)
Record the track graphs and build the enable policy for the session mode.
void AddJuice(int nAmount)
Add juice to the first player and announce it.
TrackData * GetTrack(int nTrack) const
Report one track of the level.
void SetBackGraphs(std::vector< BGTrackGraph * > *pGraphs)
Record the background tracks and build the enable policy for them.
void SetBarOwner(int nTrack, int nBar, Player *pPlayer)
Record a player against one bar of one track.
int QueryBar(int nTrack, int nBar)
Ask whether one bar of one track may be caught.
std::vector< MsgSource > mTrackSources
One message source per track.
Definition gamer.h:421
virtual void DispatchPriv(Message *pMsg)
Receive one message.
Abstract owner of the process-wide services.
Definition globals.h:47
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:41
Receiver of engine messages.
Definition msgsink.h:37
Sender of engine messages, which stores the list of sinks that receive them.
Definition msgsource.h:26
Event the game passes between a MsgSource and a MsgSink.
Definition phrasecapturedmsg.h:27
Store of one phrase per step of a play map, and one jam effect mask per step.
Definition phrasedatabase.h:29
Traversal order over one playable sequence.
Definition playmap.h:47
Event the game passes between a MsgSource and a MsgSink.
Definition playbackmodemsg.h:23
One participant in a session, local or remote.
Definition player.h:39
Handle that identifies one batch of commands the scheduler has queued.
Definition cmdid.h:35
Song position in MIDI ticks, printed as measure, beat, and tick.
Definition tick.h:70
Shared base of the four per-instrument gameplay stages.
Definition scoretrackgraph.h:51
Converted events of one track of a level.
Definition trackdata.h:52