|
wavelength 1.0.0
|
Rules of the main game, shared by the solo, multiplayer, and tutorial logic. More...
#include <gamelogic.h>


Classes | |
| class | SpeedRamp |
| Change of the song speed while a slowdown runs. More... | |
| class | PlayerData |
| Per-player record of the phrase each player should play next. More... | |
Public Types | |
| enum | State { kStateIdle = 0 , kStatePlaying = 1 , kStatePaused = 2 , kStateSuspended = 3 , kStateWon = 4 , kStateRunning = 5 , kStateEnding = 6 , kStateFinished = 7 } |
| Values of mState. More... | |
| enum | Powerup { kPowerupNone = 0 , kPowerupAutocatcher = 1 , kPowerupMultiplier = 2 , kPowerupSlowdown = 3 , kPowerupFreestyle = 4 , kPowerupBumper = 5 , kPowerupCrippler = 6 , kPowerupCount = 7 } |
| Kinds of power-up a player can hold. More... | |
Public Member Functions | |
| GameLogic (Song *pSong, DataArray *pConfig, int nSeed) | |
| Construct the logic of a song. | |
| ~GameLogic () override | |
| Stop the song and release the players and the tracks. | |
| void | Start () override |
| Start the song, the tracks, the players, and the bar counting. | |
| void | Stop () override |
| Stop the song, the tracks, and the players. | |
| bool | IsFinished () const override |
| Report whether Stop() ran. | |
| int | HasQuit () const override |
| Report mQuit. | |
| int | IsRestartRequested () const override |
| Report whether the song is to start again once it ends. | |
| bool | IsFreestyling (int nPlayer) override |
| Report whether a player is on the freestyle track. | |
| void | Poll () override |
| Stop the song once the ending finished. | |
| float | GetProgress () override |
| Report how far the song has played. | |
| void | HandleInput (const RotateEvent &event) override |
| Move a playing player to the next or previous catch track. | |
| void | HandleInput (const PlayNoteEvent &event) override |
| Pass a note to the player. | |
| void | HandleInput (const BtnEvent< 3 > &event) override |
| Pause the song from the controller of the player. | |
| void | HandleInput (const BtnEvent< 4 > &event) override |
| Toggle the display option of a single controller and save it in the profile. | |
| void | HandleInput (const BtnEvent< 5 > &event) override |
| Deploy the power-up of a player and log it. | |
| void | HandleInput (const ChangeSectionEvent &event) override |
| Ignore the event. | |
| void | HandleInput (const BtnEvent< 9 > &event) override |
| Ignore the event. | |
| void | HandleInput (const BtnEvent< 10 > &event) override |
| Pass the button to the player. | |
| void | HandleInput (const BtnEvent< 8 > &event) override |
| Ignore the event. | |
| void | HandleInput (const StickEvent< 2 > &event) override |
| Pass the stick event to the player. | |
| void | HandleInput (const StickEvent< 6 > &event) override |
| Pass the stick event to the player. | |
| void | SetPaused (bool bPaused, int nPad, int nReason) override |
| Pause or resume the song, the force feedback, and the controllers. | |
| bool | IsPlaying () const override |
| Report whether the song is playing. | |
| virtual bool | DeploySlowdown (Player *pPlayer) |
| Slow the song down for a player. | |
| virtual bool | DeployFreestyle (Player *pPlayer) |
| Move a player to the freestyle track for the configured number of bars. | |
| virtual bool | DeployBumper (Player *pPlayer) |
| Refuse a bumper. | |
| virtual bool | DeployCrippler (Player *pPlayer) |
| Refuse a crippler. | |
| virtual void | EndFreestyle (Player *pPlayer) |
| Move a player from the freestyle track back to a catch track. | |
| virtual void | OnStart ()=0 |
| Act once Start() finished. | |
| virtual void | OnFinish (bool bWon)=0 |
| Act once Finish() stopped the players. | |
| virtual void | OnBar (int nBar)=0 |
| Act at the start of every bar. | |
| virtual void | OnSection ()=0 |
| Act at the start of every section. | |
| virtual void | OnPhraseCaptured (CatchTrack *pTrack, Player *pPlayer, int nBar, bool bStreak)=0 |
| Act once CapturePhrase() found the next phrases. | |
| virtual void | OnPhraseEnded (Track *pTrack)=0 |
| Act once a phrase of a track ended. | |
| virtual void | OnPhraseMissed (Track *pTrack)=0 |
| Act once a player missed a phrase. | |
| bool | IsFreestyleTrackActive () const |
| Report whether a player is on the freestyle track while the song plays. | |
| bool | HasPhraseThisBar () const |
| Report whether a catch track has a phrase in the current bar. | |
| void | EndSong () |
| Start the ending of the song. | |
| void | Finish (bool bWon) |
| Stop the players at the end of the song. | |
| void | CapturePhrase (CatchTrack *pTrack, Player *pPlayer, int nBar, bool bStreak) |
| Record the capture of a phrase and find the next phrase of each local player. | |
| void | ContinueStreak (Track *pTrack, int nBar, int nFromBar) |
| Lengthen or reset the streak of the player of a track and find the next phrase. | |
| void | EndPhrase (Track *pTrack) |
| Report the end of a phrase to the triggers and to OnPhraseEnded(). | |
| void | MissPhrase (Track *pTrack) |
| Record a missed phrase and report it to the triggers and to OnPhraseMissed(). | |
| void | EnableNextTracks (int nBar) |
| Enable the catch tracks of the next step of the song's enable order. | |
| void | EnterFreestyle (Player *pPlayer, bool bVictory) |
| Move a player to the freestyle track. | |
| void | LeaveFreestyle (Player *pPlayer, int nTrack) |
| Move a player from the freestyle track to a catch track and find the next phrase. | |
| void | StartSlowdown () |
| Slow the song down. | |
| void | StopSlowdown () |
| Return the song to its speed after StartSlowdown(). | |
| bool | DeployAutocatcher (Player *pPlayer) |
| Capture a phrase of the track of a player and pulse the controllers of every player on it. | |
| bool | DeployMultiplier (Player *pPlayer) |
| Raise the multiplier of a player. | |
| Public Member Functions inherited from WorldLogic | |
| WorldLogic () | |
| Construct the logic and give the input of every controller to the world. | |
| ~WorldLogic () override | |
| Release the logic. | |
| bool | DispatchPriv (Message *pMsg) override |
| Pass a JoypadConnectionMsg to OnJoypadConnection() and ignore any other message. | |
| virtual int | GetTick ()=0 |
| Report the song position. | |
| virtual float | GetTime ()=0 |
| Report the song time. | |
| void | AllNotesOff () |
| Silence every synthesiser channel. | |
| void | ScheduleControllerCheck () |
| Pause the song again one tick from now when a controller is disconnected. | |
| int | OnJoypadConnection (JoypadConnectionMsg *pMsg) |
| Pause the playing song when the controller of a player is disconnected. | |
| Public Member Functions inherited from MsgSink | |
| void * | operator new (size_t nSize) |
| Allocate a sink from the pool heaps under the tag "MsgSink". | |
| void | operator delete (void *pBlock) |
| Return a sink to the pool heaps. | |
| virtual | ~MsgSink () |
| virtual bool | Dispatch (Message *pMsg) |
| Accept a message. | |
| void * | operator new (size_t size) |
| Allocate from the main heap under the name MsgSink. | |
| void | operator delete (void *mem) |
| Return memory to its heap. | |
| virtual | ~MsgSink () |
| Destroy the sink. | |
| virtual bool | Dispatch (Message *msg) |
| Handle a message. | |
Protected Member Functions | |
| void | AssignTracks () |
| Assign each player to a random catch track. | |
| void | ApplyFreestyleEffect (int nSet) |
| Apply one effect set of the song. | |
| void | ShowPowerupText (const char *pszToken, int nPlayer) |
| Show the localised text of a power-up. | |
| void | CreateTracks (int *pFreestyleType, int *pFreestyleInstrument) |
| Create the catch tracks and the freestyle track of the song. | |
| void | TickBar () |
| Count one bar, starting the next section when it begins. | |
| void | AdvanceSection () |
| Start the next section. | |
| void | ClearNextPhrase (int nPlayer) |
| Forget the next phrase of a player. | |
| void | FindNextPhrase (int nPlayer, int nTrack, int nFromBar) |
| Find the first phrase on another catch track at or after a bar, and point the player at it. | |
| void | PlaceRandomPowerups () |
| Place a random power-up in every bar of every catch track. | |
| void | PlacePowerups () |
| Place the power-ups of every section in the busiest bars of the catch tracks. | |
Static Protected Member Functions | |
| static int | GetControllerArgument (DataArray *pCommand) |
| Report the controller argument of a script command. | |
| static void | OnAutocatcherCommand (DataArray *pCommand, void *pUserData) |
| Deploy the autocatcher for a controller on the autocatcher script command. | |
| static void | OnMultiplierCommand (DataArray *pCommand, void *pUserData) |
| Deploy the multiplier for a controller on the multiplier script command. | |
| static void | OnSlowCommand (DataArray *pCommand, void *pUserData) |
| Turn the slowdown on or off outside an online game on the slow script command. | |
| static void | OnFreestyleCommand (DataArray *pCommand, void *pUserData) |
| Deploy the freestyle for a controller on the freestyle script command. | |
| static void | OnFreestyleToggleCommand (DataArray *pCommand, void *pUserData) |
| Move the player of a controller onto or off the freestyle track on the freestyle_toggle script command. | |
| static void | OnBumperCommand (DataArray *pCommand, void *pUserData) |
| Deploy the bumper for a controller on the bumper script command. | |
| static void | OnCripplerCommand (DataArray *pCommand, void *pUserData) |
| Deploy the crippler for a controller on the crippler script command. | |
| static void | OnPowerupCommand (DataArray *pCommand, void *pUserData) |
| Give a power-up to the player of a controller on the powerup script command while the power-up cheat is on. | |
Protected Attributes | |
| Song * | mSong |
| int | mState |
| int | mPaused |
| int | mTicksPerBar |
| int | mNumBars |
| PlayMap * | mPlayMap |
| std::vector< std::unique_ptr< Player > > | mPlayers |
| std::vector< LocalPlayer * > | mLocalPlayers |
| std::vector< std::unique_ptr< CatchTrack > > | mCatchTracks |
| std::unique_ptr< FreestyleTrack > | mFreestyleTrack |
| std::unique_ptr< GameTrackSelector > | mTrackSelector |
| std::unique_ptr< SpeedRamp > | mSpeedRamp |
| int | mPhraseThisBar |
| int | mQuit |
| int | mReserved60 |
| int | mSectionStartBar |
| int | mNextSectionBar |
| int | mSection |
| WorldBeat | mWorldBeat |
| int | mSavedState |
| int | mReserved8c |
| int | mSlowdown |
| int | mNextEnableStep |
| std::vector< PlayerData > | mPlayerData |
| Ptr< Command > | mBarCmd |
| Ptr< Command > | mStopSlowdownCmd |
| Rand | mRand |
| int | mEndTick |
Additional Inherited Members | |
| Static Public Member Functions inherited from WorldLogic | |
| static int | FindDisconnectedPad () |
| Find the controller of a player on this console that is disconnected. | |
Rules of the main game, shared by the solo, multiplayer, and tutorial logic.
The RTTI records the class as deriving from WorldLogic. The logic creates the players, one catch track for each catch track of the song, and the freestyle track. It counts the bars and the sections of the song, places the power-ups, moves the players between the tracks, and finds the phrase each player should play next.
The derived classes supply GetTick(), GetTime(), and the hooks from OnStart() on.
| enum GameLogic::State |
Values of mState.
| Enumerator | |
|---|---|
| kStateIdle | The song has not started. |
| kStatePlaying | The song is playing. |
| kStatePaused | The song is paused, and mSavedState records the state to resume. |
| kStateSuspended | The derived logic stopped the song without pausing it. |
| kStateWon | The song was won and the victory lap plays. |
| kStateRunning | The derived logic runs the song without the player input. |
| kStateEnding | The song ended, and the logic waits for the display to finish. |
| kStateFinished | Stop() ran. |
| enum GameLogic::Powerup |
Kinds of power-up a player can hold.
Construct the logic of a song.
Creates one player for each player in the game database, the catch tracks and the freestyle track of the song, assigns the players to the tracks, places the power-ups, and registers the script commands that deploy a power-up.
| pSong | The song. |
| pConfig | The configuration of the logic. |
| nSeed | The seed of the random numbers the logic draws. |
|
override |
Stop the song and release the players and the tracks.
|
overridevirtual |
Start the song, the tracks, the players, and the bar counting.
Implements WorldLogic.
|
overridevirtual |
Stop the song, the tracks, and the players.
Implements WorldLogic.
|
overridevirtual |
Report whether Stop() ran.
Implements WorldLogic.
|
overridevirtual |
Report mQuit.
Implements WorldLogic.
|
overridevirtual |
Report whether the song is to start again once it ends.
Implements WorldLogic.
|
overridevirtual |
Report whether a player is on the freestyle track.
| nPlayer | The player. |
Implements WorldLogic.
|
overridevirtual |
Stop the song once the ending finished.
Only a logic in kStateEnding acts. The song stops once the camera move of the ending is done and either the scheduler stopped or it arrived at mEndTick.
Implements WorldLogic.
Reimplemented in TutorialGameLogic.
|
overridevirtual |
Report how far the song has played.
Implements WorldLogic.
Reimplemented in TutorialGameLogic.
|
overridevirtual |
Move a playing player to the next or previous catch track.
| event | The event. |
Implements WorldLogic.
Reimplemented in MultiGameLogic, SoloGameLogic, and TutorialGameLogic.
|
overridevirtual |
Pass a note to the player.
| event | The event. |
Implements WorldLogic.
Reimplemented in SoloGameLogic, and TutorialGameLogic.
|
overridevirtual |
Pause the song from the controller of the player.
| event | The event. |
Implements WorldLogic.
Reimplemented in SoloGameLogic, and TutorialGameLogic.
|
overridevirtual |
Toggle the display option of a single controller and save it in the profile.
| event | The event. |
Implements WorldLogic.
Reimplemented in SoloGameLogic, and TutorialGameLogic.
|
overridevirtual |
Deploy the power-up of a player and log it.
| event | The event. |
Implements WorldLogic.
Reimplemented in SoloGameLogic, and TutorialGameLogic.
|
inlineoverridevirtual |
Ignore the event.
| event | The event. |
Implements WorldLogic.
Reimplemented in SoloGameLogic, and TutorialGameLogic.
|
inlineoverridevirtual |
Ignore the event.
| event | The event. |
Implements WorldLogic.
Reimplemented in SoloGameLogic, and TutorialGameLogic.
|
overridevirtual |
Pass the button to the player.
| event | The event. |
Implements WorldLogic.
Reimplemented in SoloGameLogic, and TutorialGameLogic.
|
inlineoverridevirtual |
Ignore the event.
| event | The event. |
Implements WorldLogic.
Reimplemented in SoloGameLogic, and TutorialGameLogic.
|
overridevirtual |
Pass the stick event to the player.
| event | The event. |
Implements WorldLogic.
Reimplemented in SoloGameLogic, and TutorialGameLogic.
|
overridevirtual |
Pass the stick event to the player.
| event | The event. |
Implements WorldLogic.
Reimplemented in SoloGameLogic, and TutorialGameLogic.
|
overridevirtual |
Pause or resume the song, the force feedback, and the controllers.
| bPaused | Whether to pause. |
| nPad | The controller that requested the change. |
| nReason | The reason the change was requested. |
Reimplemented from WorldLogic.
Reimplemented in MultiGameLogic, SoloGameLogic, and TutorialGameLogic.
|
inlineoverridevirtual |
Report whether the song is playing.
Implements WorldLogic.
|
virtual |
Slow the song down for a player.
| pPlayer | The player. |
Reimplemented in MultiGameLogic.
|
virtual |
Move a player to the freestyle track for the configured number of bars.
| pPlayer | The player. |
Reimplemented in MultiGameLogic, and SoloGameLogic.
|
inlinevirtual |
Refuse a bumper.
The solo game has no bumper.
| pPlayer | The player. |
Reimplemented in MultiGameLogic.
|
inlinevirtual |
Refuse a crippler.
The solo game has no crippler.
| pPlayer | The player. |
Reimplemented in MultiGameLogic.
|
virtual |
Move a player from the freestyle track back to a catch track.
| pPlayer | The player. |
Reimplemented in MultiGameLogic.
|
pure virtual |
Act once Start() finished.
Implemented in MultiGameLogic, SoloGameLogic, and TutorialGameLogic.
|
pure virtual |
Act once Finish() stopped the players.
| bWon | Whether the song was won. |
Implemented in MultiGameLogic, SoloGameLogic, and TutorialGameLogic.
|
pure virtual |
Act at the start of every bar.
| nBar | The bar. |
Implemented in MultiGameLogic, SoloGameLogic, and TutorialGameLogic.
|
pure virtual |
Act at the start of every section.
Implemented in MultiGameLogic, SoloGameLogic, and TutorialGameLogic.
|
pure virtual |
Act once CapturePhrase() found the next phrases.
| pTrack | The track the phrase was captured on. |
| pPlayer | The player that captured it. |
| nBar | The first bar the capture clears. |
| bStreak | Whether the capture continues the streak of the player. |
Implemented in MultiGameLogic, SoloGameLogic, and TutorialGameLogic.
|
pure virtual |
Act once a phrase of a track ended.
| pTrack | The track. |
Implemented in MultiGameLogic, SoloGameLogic, and TutorialGameLogic.
|
pure virtual |
Act once a player missed a phrase.
| pTrack | The track the phrase was missed on. |
Implemented in MultiGameLogic, SoloGameLogic, and TutorialGameLogic.
| bool GameLogic::IsFreestyleTrackActive | ( | ) | const |
Report whether a player is on the freestyle track while the song plays.
| bool GameLogic::HasPhraseThisBar | ( | ) | const |
Report whether a catch track has a phrase in the current bar.
| void GameLogic::EndSong | ( | ) |
Start the ending of the song.
Fades the mixer out over at least one second and schedules WorldLogic::AllNotesOff() at the end of the fade, unless the song is paused. The logic enters kStateEnding either way.
| void GameLogic::Finish | ( | bool | bWon | ) |
Stop the players at the end of the song.
A won song gives the first player the freestyle track and checks for an unlocked song. A demo starts the ending at once, and any other game passes the result to OnFinish().
| bWon | Whether the song was won. |
| void GameLogic::CapturePhrase | ( | CatchTrack * | pTrack, |
| Player * | pPlayer, | ||
| int | nBar, | ||
| bool | bStreak ) |
Record the capture of a phrase and find the next phrase of each local player.
| pTrack | The track the phrase was captured on. |
| pPlayer | The player that captured it. |
| nBar | The first bar the capture clears. |
| bStreak | Whether the capture continues the streak of the player. |
| void GameLogic::ContinueStreak | ( | Track * | pTrack, |
| int | nBar, | ||
| int | nFromBar ) |
Lengthen or reset the streak of the player of a track and find the next phrase.
| pTrack | The track. |
| nBar | The bar the phrase ended in. |
| nFromBar | The first bar to search for the next phrase from. |
| void GameLogic::EndPhrase | ( | Track * | pTrack | ) |
Report the end of a phrase to the triggers and to OnPhraseEnded().
| pTrack | The track. |
| void GameLogic::MissPhrase | ( | Track * | pTrack | ) |
Record a missed phrase and report it to the triggers and to OnPhraseMissed().
| pTrack | The track the phrase was missed on. |
| void GameLogic::EnableNextTracks | ( | int | nBar | ) |
Enable the catch tracks of the next step of the song's enable order.
| nBar | The bar the tracks start at. |
| void GameLogic::EnterFreestyle | ( | Player * | pPlayer, |
| bool | bVictory ) |
Move a player to the freestyle track.
| pPlayer | The player. |
| bVictory | Whether the freestyle rewards a won song. |
| void GameLogic::LeaveFreestyle | ( | Player * | pPlayer, |
| int | nTrack ) |
Move a player from the freestyle track to a catch track and find the next phrase.
| pPlayer | The player. |
| nTrack | The catch track, or -1 for the track the camera of the player shows. |
| void GameLogic::StartSlowdown | ( | ) |
Slow the song down.
| void GameLogic::StopSlowdown | ( | ) |
Return the song to its speed after StartSlowdown().
| bool GameLogic::DeployAutocatcher | ( | Player * | pPlayer | ) |
Capture a phrase of the track of a player and pulse the controllers of every player on it.
| pPlayer | The player. |
| bool GameLogic::DeployMultiplier | ( | Player * | pPlayer | ) |
Raise the multiplier of a player.
| pPlayer | The player. |
|
protected |
Assign each player to a random catch track.
|
protected |
Apply one effect set of the song.
| nSet | The effect set. |
|
protected |
Show the localised text of a power-up.
Only the solo game shows the text.
| pszToken | The token of the text. |
| nPlayer | The player. The body does not read it. |
|
protected |
Create the catch tracks and the freestyle track of the song.
| pFreestyleType | Receives the track type of the freestyle track. |
| pFreestyleInstrument | Receives the instrument of the freestyle track. |
|
protected |
Count one bar, starting the next section when it begins.
The command in mBarCmd runs the routine at the start of every bar.
|
protected |
Start the next section.
|
protected |
Forget the next phrase of a player.
| nPlayer | The player. |
|
protected |
Find the first phrase on another catch track at or after a bar, and point the player at it.
| nPlayer | The player. |
| nTrack | The catch track to skip. |
| nFromBar | The first bar to search. |
|
protected |
Place a random power-up in every bar of every catch track.
|
protected |
Place the power-ups of every section in the busiest bars of the catch tracks.
|
staticprotected |
Report the controller argument of a script command.
| pCommand | The command. |
|
staticprotected |
Deploy the autocatcher for a controller on the autocatcher script command.
| pCommand | The command. |
| pUserData | The logic. |
|
staticprotected |
Deploy the multiplier for a controller on the multiplier script command.
| pCommand | The command. |
| pUserData | The logic. |
|
staticprotected |
Turn the slowdown on or off outside an online game on the slow script command.
| pCommand | The command. |
| pUserData | The logic. |
|
staticprotected |
Deploy the freestyle for a controller on the freestyle script command.
| pCommand | The command. |
| pUserData | The logic. |
|
staticprotected |
Move the player of a controller onto or off the freestyle track on the freestyle_toggle script command.
| pCommand | The command. |
| pUserData | The logic. |
|
staticprotected |
Deploy the bumper for a controller on the bumper script command.
| pCommand | The command. |
| pUserData | The logic. |
|
staticprotected |
Deploy the crippler for a controller on the crippler script command.
| pCommand | The command. |
| pUserData | The logic. |
|
staticprotected |
Give a power-up to the player of a controller on the powerup script command while the power-up cheat is on.
| pCommand | The command. |
| pUserData | The logic. |
|
protected |
The song. Borrowed.
|
protected |
One of State.
|
protected |
Whether SetPaused() paused the song.
|
protected |
Length of a bar, in ticks.
|
protected |
Length of the song, in bars.
|
protected |
The map of the song positions. Borrowed.
|
protected |
Every player, by index.
|
protected |
The players on this console. Borrowed.
|
protected |
The catch tracks, by index.
|
protected |
The freestyle track, or null.
|
protected |
The assignment of the players.
|
protected |
The speed of the song.
|
protected |
Whether a catch track has a phrase this bar.
|
protected |
Set by the derived logic when a player quit.
|
protected |
|
protected |
First bar of the current section.
|
protected |
First bar of the next section.
|
protected |
Index of the current section.
|
protected |
The events of the track named "WORLD".
|
protected |
The state SetPaused() restores.
|
protected |
|
protected |
Whether StartSlowdown() slowed the song.
|
protected |
The step EnableNextTracks() enables next.
|
protected |
The record of each player.
Runs StopSlowdown().
|
protected |
The random numbers of the logic.
|
protected |
The tick the song stops at.