resonance 1.0.1
Loading...
Searching...
No Matches
catcher.h
Go to the documentation of this file.
1#pragma once
2
4#include "game/player.h"
5#include "game/quantizer.h"
6#include "game/trackdata.h"
7#include "gs/phrasemgr.h"
8#include "mid/tick.h"
9#include "msg/autocatchmsg.h"
11#include "msg/message.h"
12#include "msg/pitchriffmsg.h"
13#include "msg/trackselectmsg.h"
14#include "sch/cmdid.h"
15#include "sch/tickclock.h"
16
50class Catcher : public GenericCatcher {
51public:
62 Catcher(PhraseMgr *pPhraseMgr,
63 Quantizer *pQuantizer,
64 const TrackData *pTrackData,
65 Sch::TickClock *pClock,
66 int nSeekerBarCount,
67 Sch::Tick catchWindow);
68
75 virtual ~Catcher();
76
87 virtual void DispatchPriv(Message *pMsg);
88
97 virtual void Start();
98
108 virtual void Stop();
109
119 virtual int IsPhraseRunEmpty();
120
136 virtual void MissGem(int nTick, int nGem);
137
154 virtual void CatchGem(int nTick, int nGem);
155
165 virtual void CapturePhrase(int nBar, int nRun, int nAutoCatch) = 0;
166
174 virtual void ReportCaughtPowerbar(int nBar) = 0;
175
189 void ProcessGemCommand(int nTick);
190
204 void SimulateRemoteGem(int nTick);
205
206protected:
216 void PostPhraseMuffedMsg(int nBar, Sch::Tick position);
217
230
241 void PostCaughtBarMsg(int nBar, int nNextBar);
242
252 int SnapToNearestGem(int nTick);
253
261
271
281 void EndBar(int nBar);
282
292 int FindNextGemTick(int nTick);
293
301 void SchedulePostGemCommand(int nTick);
302
309 void ScheduleGemCommand(int nTick);
310
318 int PostGemDelay(int nTick);
319
329 void UpdateSeeker(int nBar);
330
338
346 void PostSeekerRangeMsg(int nFirstBar, int nBarCount);
347
358 int IsBarFree(int nBar);
359
367
376 void SetPhraseOwners(int nFirstBar, int nEndBar, Player *pPlayer);
377
380 const TrackData *mTrackData; // +0x20
381 Player *mPlayer; // +0x24, the file-scope NullPlayer until one is assigned
385 Sch::Tick mTicksPerBar; // +0x34, copied from the phrase manager and used as a divisor
386 int mSeekerBarCount; // +0x38, the constructor's int parameter
387 int mCatchWindow; // +0x3c, the constructor's catch window
388 int mEnabled; // +0x40, always 1 and never read
391 int mTrack; // +0x4c, copied from TrackData::mIndex
392 int mCaughtGems; // +0x50, gems caught in the current bar
393 int mMissedGems; // +0x54, gems missed in the current bar
394 int mMuffedGems; // +0x58, gems passed without a riff in the current bar
395 int mLastEndedBar; // +0x5c, the bar EndBar() closed last
396 int mPhraseRunBars; // +0x60, the caught bars of the current run
397 int mLastMuffedBar; // +0x64, the bar PostPhraseMuffedMsg() reported last, starts -1
398 int mSeekerFirstBar; // +0x68
399 int mSeekerEndBar; // +0x6c
400 int mSeekerEnabled; // +0x70
401 Player *mRemotePlayer; // +0x74, from a CatchProgressPacket
402 float mRemoteSuccess; // +0x78, the packet's success rate
403 Sch::Tick mRemotePosition; // +0x7c, the packet's position
404};
Event the game passes between a MsgSource and a MsgSink.
Definition autocatchmsg.h:25
int mPhraseRunBars
Definition catcher.h:396
int mMuffedGems
Definition catcher.h:394
void SchedulePostGemCommand(int nTick)
Build a PostGemCmd for the gem after nTick and queue it one tick after PostGemDelay() under the handl...
int mSeekerEnabled
Definition catcher.h:400
int mSeekerEndBar
Definition catcher.h:399
int mCatchWindow
Definition catcher.h:387
Quantizer * mQuantizer
Definition catcher.h:378
int mLastMuffedBar
Definition catcher.h:397
Sch::Tick mLastCaughtPosition
Definition catcher.h:389
float mRemoteSuccess
Definition catcher.h:402
Catcher(PhraseMgr *pPhraseMgr, Quantizer *pQuantizer, const TrackData *pTrackData, Sch::TickClock *pClock, int nSeekerBarCount, Sch::Tick catchWindow)
virtual int IsPhraseRunEmpty()
Report whether the catcher has nothing outstanding.
void SimulateRemoteGem(int nTick)
Play the remote player's gem at a song position, then schedule the next gem command.
virtual void ReportCaughtPowerbar(int nBar)=0
Report a caught bar's power bar.
int mSeekerBarCount
Definition catcher.h:386
int mLastEndedBar
Definition catcher.h:395
virtual void MissGem(int nTick, int nGem)
Record a missed gem.
Sch::CmdID mPostGemCommand
Definition catcher.h:383
void ScheduleGemCommand(int nTick)
Build a GemCmd for the gem after nTick and queue it at that gem under the handle mGemCommand.
const TrackData * mTrackData
Definition catcher.h:380
int FindNextGemTick(int nTick)
Returns the first gem position after nTick.
virtual void CatchGem(int nTick, int nGem)
Record a caught gem.
void EndBar(int nBar)
Closes the counts for a bar.
virtual void Start()
Schedule the catcher's two commands on the clock.
Sch::TickClock * mClock
Definition catcher.h:382
virtual ~Catcher()
Withdraw both commands through Stop().
int mSeekerFirstBar
Definition catcher.h:398
void OnTrackSelect(TrackSelectMsg *pMsg)
Takes the track for the player a TrackSelectMsg names.
void PostSeekerRangeMsg(int nFirstBar, int nBarCount)
Sends a SeekerMsg for nBarCount bars from nFirstBar at position 0, and records the range in mSeekerFi...
Sch::Tick mRemotePosition
Definition catcher.h:403
int mCaughtGems
Definition catcher.h:392
int mMissedGems
Definition catcher.h:393
void ProcessGemCommand(int nTick)
Run the post-gem command at a song position.
virtual void DispatchPriv(Message *pMsg)
Act on a message.
void PostCaughtBarMsg(int nBar, int nNextBar)
Does nothing once a gem of the phrase was missed or muffed.
int SnapToNearestGem(int nTick)
Returns the gem on either side of nTick nearer to it when that gem lies within mCatchWindow,...
PhraseMgr * mPhraseMgr
Definition catcher.h:379
virtual void Stop()
Withdraw the catcher's two commands from the clock.
Sch::Tick mLastMissedPosition
Definition catcher.h:390
void OnInvalidateSeeker(InvalidateSeekerMsg *pMsg)
The out-of-line copy of the InvalidateSeekerMsg branch DispatchPriv() expands inline.
int mTrack
Definition catcher.h:391
Sch::CmdID mGemCommand
Definition catcher.h:384
void UpdateSeeker(int nBar)
Finds the next free bar within 32 bars of nBar (or of the bar after mLastMuffedBar) and points the se...
Player * mPlayer
Definition catcher.h:381
int PostGemDelay(int nTick)
Returns the earlier of the midpoint between nTick and the next gem, and nTick plus mCatchWindow.
virtual void CapturePhrase(int nBar, int nRun, int nAutoCatch)=0
Capture the phrase a caught run of bars completes.
void PostCatchMsg(PitchRiffMsg *pMsg)
Scores a PitchRiffMsg for this track.
void PostPhraseMuffedMsg(int nBar, Sch::Tick position)
Sends a PhraseMuffedMsg for a bar once, recording the bar in mLastMuffedBar.
Sch::Tick mTicksPerBar
Definition catcher.h:385
void OnAutoCatch(AutoCatchMsg *pMsg)
Plays a free bar for the player an AutoCatchMsg identifies through CapturePhrase(),...
Player * mRemotePlayer
Definition catcher.h:401
int mEnabled
Definition catcher.h:388
int IsBarFree(int nBar)
Returns whether a bar is non-negative, playable according to TrackData::QueryBar(),...
void PostSeekerMsg()
Sends a SeekerMsg that turns the seeker off and clears mSeekerEnabled.
void SetPhraseOwners(int nFirstBar, int nEndBar, Player *pPlayer)
Gives every bar from nFirstBar up to nEndBar to one player.
Event the game passes between a MsgSource and a MsgSink.
Definition invalidateseekermsg.h:19
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:41
Owner of the gem phrases on one track, and the seam between the network and the gems.
Definition phrasemgr.h:51
Event the game passes between a MsgSource and a MsgSink.
Definition pitchriffmsg.h:26
One participant in a session, local or remote.
Definition player.h:39
Holder of the track description the beat-quantising paths consult.
Definition quantizer.h:14
Handle that identifies one batch of commands the scheduler has queued.
Definition cmdid.h:35
Pausable view of scheduler time, together with the tempo that maps it to a song position.
Definition tickclock.h:40
Song position in MIDI ticks, printed as measure, beat, and tick.
Definition tick.h:70
Converted events of one track of a level.
Definition trackdata.h:52
Event the game passes between a MsgSource and a MsgSink.
Definition trackselectmsg.h:24