wavelength 1.0.0
Loading...
Searching...
No Matches
gemcatcher.h
Go to the documentation of this file.
1#pragma once
2
4#include "game/gemcursor.h"
5#include "os/command.h"
6#include "os/commandid.h"
7#include "os/ptr.h"
8
16public:
18 static constexpr int kNumLanes = 3;
19
25 class Receiver {
26 public:
33 virtual ~Receiver() {
34 }
35
42 virtual void OnHit(int nTick, const GemCursor &cursor) = 0;
43
50 virtual void OnPass(int nTick, const GemCursor &cursor) = 0;
51
58 virtual void OnMiss(int nTick, int nLane) = 0;
59 };
60
67 class CatchCheckCmd : public Command {
68 public:
75 ~CatchCheckCmd() override = default;
76
91 CatchTrackState *pState,
92 const float *pMsPerTick,
93 int nTrack,
94 int nLane,
95 int nSlopMs,
96 int nTicksPerBar);
97
104 void Schedule();
105
112 void Execute() override;
113
120 void Restart();
121
128 void Catch();
129
137
149 GemCursor Nearest(const GemCursor &first, const GemCursor &second, int nTick) const;
150
160 void Hit(int nTick, const GemCursor &cursor, float fErrorMs);
161
170 void Pass(int nTick, const GemCursor &cursor);
171
181 void Miss(int nTick, const GemCursor &cursor, float fErrorMs);
182
190 void Miss(int nTick);
191
192 private:
193 Receiver *mReceiver;
194 CatchTrackState *mState;
195 const float *mMsPerTick;
196 int mTrack;
197 int mLane;
198 int mSlopMs;
199 int mTicksPerBar;
200 GemCursor mCursor;
201 CommandId mId;
202 };
203
216 CatchTrackState *pState,
217 const float *pMsPerTick,
218 int nTrack,
219 int nTicksPerBar);
220
228
235 void Start();
236
243 void Stop();
244
251 void Reset();
252
260 void Catch(int nLane);
261
262private:
264};
Per-bar state of one catch track during a song.
Definition catchtrackstate.h:17
Tag that a Scheduler stores beside each queued command.
Definition commandid.h:8
Unit of work a Scheduler runs at a set time.
Definition command.h:13
void Restart()
Withdraw the queued command and queue it again from the current tick.
void ScheduleNext()
Move to the next gem of the lane and queue the command for it.
CatchCheckCmd(Receiver *pReceiver, CatchTrackState *pState, const float *pMsPerTick, int nTrack, int nLane, int nSlopMs, int nTicksPerBar)
Construct the command for a lane.
GemCursor Nearest(const GemCursor &first, const GemCursor &second, int nTick) const
Report the cursor whose gem is nearer a tick.
void Pass(int nTick, const GemCursor &cursor)
Report a gem that passed without a press.
void Execute() override
Pass the gem when its bar is open, and wait on the next gem.
void Schedule()
Move to the next gem of the lane from the current tick and queue the command for it.
void Miss(int nTick)
Report a press with no gem near it.
~CatchCheckCmd() override=default
Destroy the object.
void Miss(int nTick, const GemCursor &cursor, float fErrorMs)
Report a press too far from the nearest gem.
void Catch()
Judge a press at the current tick.
void Hit(int nTick, const GemCursor &cursor, float fErrorMs)
Report a caught gem.
Object told of each judged gem and press.
Definition gemcatcher.h:25
virtual void OnMiss(int nTick, int nLane)=0
Handle a press that caught no gem.
virtual ~Receiver()
Release the receiver.
Definition gemcatcher.h:33
virtual void OnHit(int nTick, const GemCursor &cursor)=0
Handle a caught gem.
virtual void OnPass(int nTick, const GemCursor &cursor)=0
Handle a gem that passed without a press.
static constexpr int kNumLanes
The number of lanes of a catch track.
Definition gemcatcher.h:18
GemCatcher(Receiver *pReceiver, CatchTrackState *pState, const float *pMsPerTick, int nTrack, int nTicksPerBar)
Construct the commands of every lane.
void Start()
Queue the command of every lane from the current tick.
~GemCatcher()
Withdraw the queued commands.
void Catch(int nLane)
Judge a press on a lane at the current tick.
void Stop()
Withdraw the command of every lane.
void Reset()
Queue the command of every lane again from the current tick.
Position at one gem of a catch track, walked in the order the song plays the gems.
Definition gemcursor.h:14
Owner of one reference to an Attachment.
Definition ptr.h:16