wavelength 1.0.0
Loading...
Searching...
No Matches
catchtrack.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5
6#include "game/backmusic.h"
11#include "game/gemcursor.h"
12#include "game/guideticker.h"
13#include "game/player.h"
14#include "game/playmap.h"
16#include "game/track.h"
17#include "game/trackcapturer.h"
18#include "os/command.h"
19#include "os/mem.h"
20#include "os/ptr.h"
21
22// GameLogic and CatchTrack refer to each other.
23class GameLogic;
24
33class CatchTrack : public Track {
34public:
40 class DeactivateCmd : public Command {
41 public:
47 explicit DeactivateCmd(CatchTrack *pTrack) : mTrack(pTrack) {
48 }
49
56 ~DeactivateCmd() override {
57 }
58
65 void Execute() override;
66
67 private:
68 CatchTrack *mTrack;
69 };
70
78 public:
84 explicit CaptureReceiver(CatchTrack *pTrack) : mTrack(pTrack) {
85 }
86
93 ~CaptureReceiver() override {
94 }
95
103 void OnCapture(const GemCursor &cursor) override {
104 mTrack->OnCapture(cursor);
105 }
106
113 void OnRunLost() override {
114 mTrack->OnRunLost();
115 }
116
125 void OnRunStart(const GemCursor &cursor, int nEndBar) override {
126 mTrack->OnRunStart(cursor, nEndBar);
127 }
128
129 private:
130 CatchTrack *mTrack;
131 };
132
138 static void operator delete(void *pBlock) {
139 PoolMemFree(pBlock);
140 }
141
159 CatchTrackData *pData,
160 const float *pfMsPerTick,
161 PlayMap *pPlayMap,
162 SectionBoundaries *pSections,
163 int nIndex,
164 int nIntroBars,
165 int nNumBars,
166 int nTicksPerBar,
167 int nFlags);
168
175 ~CatchTrack() override;
176
183 void Start() override;
184
191 void Stop() override;
192
200 void SetPlayer(Player *pPlayer) override;
201
211 void HandleInput(Player *pPlayer, const PlayNoteEvent &event) override;
212
221 void HandleInput([[maybe_unused]] Player *pPlayer,
222 [[maybe_unused]] const BtnEvent<8> &event) override {
223 }
224
233 void HandleInput([[maybe_unused]] Player *pPlayer,
234 [[maybe_unused]] const StickEvent<2> &event) override {
235 }
236
245 void HandleInput([[maybe_unused]] Player *pPlayer,
246 [[maybe_unused]] const StickEvent<6> &event) override {
247 }
248
257 void HandleInput([[maybe_unused]] Player *pPlayer,
258 [[maybe_unused]] const BtnEvent<10> &event) override {
259 }
260
268 void AddBackMusic(BackMusic *pMusic);
269
279 void Loop(int nBar);
280
289 void SetPowerup(int nBar, int nPowerup);
290
301 void SetBarPowerup(int nBar, int nPowerup);
302
311 void Enable(int nBar);
312
323 void Restart(Player *pPlayer, int nTick);
324
333 bool HasPhraseAt(int nBar);
334
347 bool FindPhrase(int nBar, int *pTick, int *pLane);
348
358 int GetNextGemTick(int nTick, int *pLane);
359
368 void Capture(int nBar, Player *pPlayer);
369
379 bool Autocatch(int nBar, Player *pPlayer);
380
390 void Freestyle(int nBar, int nBars, Player *pPlayer);
391
403 void AssignBars(int nBar, int nBars, Player *pPlayer);
404
414 void SetAutopilot(bool bAutopilot);
415
425 void SetNoSeeker(bool bNoSeeker);
426
427private:
440 void CaptureBars(int nBar, Player *pPlayer, bool bAuto);
441
456 void ActivateBars(int nStartBar, int nEndBar, Player *pPlayer, bool bAuto, bool bFreestyle);
457
466 void UpdateHint();
467
476 void ScheduleHint();
477
487 static int GetStrandBars();
488
498 void OnCapture(const GemCursor &cursor);
499
508 void OnRunLost();
509
520 void OnRunStart(const GemCursor &cursor, int nEndBar);
521
522 PlayMap *mPlayMap;
523 GameLogic *mLogic;
524 CatchTrackState mState;
525 const SectionBoundaries *mSections;
526 int mTicksPerBar;
527 int mNumBars;
528 CatchTrackDisplay mDisplay;
529 CatchTrackMusic mMusic;
530 GuideTicker mGuideTicker;
531 std::unique_ptr<CaptureReceiver> mReceiver;
532 Ptr<Command> mDeactivateCommand;
533 Ptr<Command> mIdleCommand;
534 Ptr<Command> mHintCommand;
535 std::vector<BackMusic *> mBackMusic;
536 int mShowHints;
537 TrackCapturer mCapturer;
538 int mStarted;
539 int mEnabled;
540};
Background music of a song, played alone or along with a catch track.
Definition backmusic.h:20
Input event of a button press that names only the player.
Definition btnevent.h:15
The gems of one catch track, in the order of their ticks.
Definition catchtrackdata.h:14
Drawer of the bars and gems of one catch track ahead of the song.
Definition catchtrackdisplay.h:16
Player of the music of the captured bars of one catch track.
Definition catchtrackmusic.h:21
Per-bar state of one catch track during a song.
Definition catchtrackstate.h:17
void OnCapture(const GemCursor &cursor) override
Pass a capture to the track.
Definition catchtrack.h:103
void OnRunStart(const GemCursor &cursor, int nEndBar) override
Pass the start of a run to the track.
Definition catchtrack.h:125
CaptureReceiver(CatchTrack *pTrack)
Construct the receiver of a track.
Definition catchtrack.h:84
~CaptureReceiver() override
Release the receiver.
Definition catchtrack.h:93
void OnRunLost() override
Pass a lost run to the track.
Definition catchtrack.h:113
void Execute() override
End the phrase of the track and stop its background music.
DeactivateCmd(CatchTrack *pTrack)
Construct the command of a track.
Definition catchtrack.h:47
~DeactivateCmd() override
Release the command.
Definition catchtrack.h:56
void AddBackMusic(BackMusic *pMusic)
Play a background music track while a captured run of this track plays.
void HandleInput(Player *pPlayer, const PlayNoteEvent &event) override
Pass a button press of the track's player to the capturer, or show another player that the track is b...
void HandleInput(Player *pPlayer, const StickEvent< 2 > &event) override
Ignore the input.
Definition catchtrack.h:233
void Restart(Player *pPlayer, int nTick)
Enable every bar, give every bar to a player, and move the display to a tick.
void Capture(int nBar, Player *pPlayer)
Capture the phrase of a bar for a player.
bool Autocatch(int nBar, Player *pPlayer)
Capture the phrase of a bar or the next bar for a player with the autocatcher power-up.
bool HasPhraseAt(int nBar)
Report whether a phrase of the track is in a bar.
void SetNoSeeker(bool bNoSeeker)
Hide or show the seeker of the track.
void HandleInput(Player *pPlayer, const BtnEvent< 8 > &event) override
Ignore the input.
Definition catchtrack.h:221
void HandleInput(Player *pPlayer, const StickEvent< 6 > &event) override
Ignore the input.
Definition catchtrack.h:245
bool FindPhrase(int nBar, int *pTick, int *pLane)
Find the first gem of the next phrase from a bar.
void HandleInput(Player *pPlayer, const BtnEvent< 10 > &event) override
Ignore the input.
Definition catchtrack.h:257
int GetNextGemTick(int nTick, int *pLane)
Report the tick of the first gem at or after a tick.
void Stop() override
Stop the track and every scheduled command.
~CatchTrack() override
Stop and release the track.
void Enable(int nBar)
Enable the bars with gems from a bar on, except the checkpoint bars at the start of each section,...
void AssignBars(int nBar, int nBars, Player *pPlayer)
Give a run of bars as written to a player, or take them from every player.
void SetAutopilot(bool bAutopilot)
Turn on or off the automatic play of the track's gems.
void SetPlayer(Player *pPlayer) override
Give the track to the player it plays for.
void Start() override
Start the display, the music, and the guide ticker of the track, once.
void SetBarPowerup(int nBar, int nPowerup)
Place a power-up in a bar as written.
void Freestyle(int nBar, int nBars, Player *pPlayer)
Give a player the freestyle power-up for a number of bars.
CatchTrack(GameLogic *pLogic, CatchTrackData *pData, const float *pfMsPerTick, PlayMap *pPlayMap, SectionBoundaries *pSections, int nIndex, int nIntroBars, int nNumBars, int nTicksPerBar, int nFlags)
Construct a catch track.
void Loop(int nBar)
Redraw the track from a bar and restart the capturer after the song gained a loop.
void SetPowerup(int nBar, int nPowerup)
Place a power-up in a bar.
Unit of work a Scheduler runs at a set time.
Definition command.h:13
Rules of the main game, shared by the solo, multiplayer, and tutorial logic.
Definition gamelogic.h:39
Position at one gem of a catch track, walked in the order the song plays the gems.
Definition gemcursor.h:14
Player of the guide sound of each gem of a catch track as the song reaches the gem.
Definition guideticker.h:15
Map from the bars a song plays to the bars of the song as written, with the loops that repeat stretch...
Definition playmap.h:11
Input event that plays a note on one of the three gem buttons.
Definition playnoteevent.h:10
One participant in a song: the track the participant plays, the score, and the streak.
Definition player.h:19
Owner of one reference to an Attachment.
Definition ptr.h:16
Ascending list of the measures at which the sections of a song end.
Definition sectionboundaries.h:12
Input event of an analog stick position.
Definition stickevent.h:15
Interface told when a run is started, lost, or captured.
Definition trackcapturer.h:33
Rules of capturing the phrases of a catch track.
Definition trackcapturer.h:26
Track(int nIndex)
Construct a track with no player.
void PoolMemFree(void *pBlock)
Return a block PoolMemAlloc() handed out to the pool heap that owns it.