wavelength 1.0.0
Loading...
Searching...
No Matches
MultiGameLogic Class Reference

Rules of a song played by several players, on one console or online. More...

#include <multigamelogic.h>

Inheritance diagram for MultiGameLogic:
Collaboration diagram for MultiGameLogic:

Public Member Functions

 MultiGameLogic (Song *pSong, DataArray *pConfig, int nSeed)
 Construct the logic of a song and register the win_cheat script command.
 ~MultiGameLogic () override
 Release the arbiter, restore the song speed, and unregister the cheat.
bool DispatchPriv (Message *pMsg) override
 Apply a packet from another console, or hand any other message to WorldLogic.
int GetTick () override
 Report the tick of the scheduler's clock.
float GetTime () override
 Report the time of the scheduler's clock.
void HandleInput (const RotateEvent &event) override
 Move a player to a neighbouring track and ask the arbiter to settle the move.
void SetPaused (bool bPaused, int nPad, int nReason) override
 Pause or resume, and show the pause dialog when pausing.
bool DeploySlowdown (Player *pPlayer) override
 Slow the song down for a player and, for a local player online, send a SlowdownPacket.
bool DeployFreestyle (Player *pPlayer) override
 Move a player to the freestyle track.
bool DeployBumper (Player *pPlayer) override
 Bump every other player on a player's track to a random other track.
bool DeployCrippler (Player *pPlayer) override
 Cripple every other player on a player's track.
void EndFreestyle (Player *pPlayer) override
 Move a player from the freestyle track back to a catch track.
void OnStart () override
 Enable the catch tracks, schedule the end of the song, and start the arbiter.
void OnFinish (bool bWon) override
 Celebrate a won song and collect or send the final score.
void OnBar (int nBar) override
 Update the score leader.
void OnSection () override
 Announce the completed stage while sections remain.
void OnPhraseCaptured (CatchTrack *pTrack, Player *pPlayer, int nBar, bool bAutocatch) override
 Update the score leader and, for a local player online, send a CapturePacket.
void OnPhraseEnded (Track *pTrack) override
 Act once a phrase of a track ended.
void OnPhraseMissed (Track *pTrack) override
 Act once a player missed a phrase.
Public Member Functions inherited from GameLogic
 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 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.
bool IsPlaying () const override
 Report whether the song is playing.
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.
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.

Additional Inherited Members

Public Types inherited from GameLogic
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...
Static Public Member Functions inherited from WorldLogic
static int FindDisconnectedPad ()
 Find the controller of a player on this console that is disconnected.
Protected Member Functions inherited from GameLogic
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 inherited from GameLogic
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 inherited from GameLogic
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

Detailed Description

Rules of a song played by several players, on one console or online.

The RTTI records the class as deriving from GameLogic. The logic tracks the score leader, lets the bumper and crippler power-ups strike the other players on the same track, and ends the song with the results of every player. Online, every action of a local player is sent to the other consoles as a packet, every packet received is applied to the remote player it names, and the hosting console runs a NetArbiter and collects the final scores.

Constructor & Destructor Documentation

◆ MultiGameLogic()

MultiGameLogic::MultiGameLogic ( Song * pSong,
DataArray * pConfig,
int nSeed )

Construct the logic of a song and register the win_cheat script command.

Online, the hosting console builds the arbiter, and the players are mapped from their session order.

Parameters
pSongThe song.
pConfigThe configuration of the logic.
nSeedThe seed of the random numbers the logic draws.
Ghidra address:
NTSC-U/C: 0x00124760
Ghidra address:
PAL: 0x00125ee0

◆ ~MultiGameLogic()

MultiGameLogic::~MultiGameLogic ( )
override

Release the arbiter, restore the song speed, and unregister the cheat.

Ghidra address:
NTSC-U/C: 0x00124b58
Ghidra address:
PAL: 0x001262d8

Member Function Documentation

◆ DispatchPriv()

bool MultiGameLogic::DispatchPriv ( Message * pMsg)
overridevirtual

Apply a packet from another console, or hand any other message to WorldLogic.

Parameters
pMsgThe message.
Returns
False for a message the logic handles here, otherwise the result of WorldLogic::DispatchPriv().
Ghidra address:
NTSC-U/C: 0x00127748
Ghidra address:
PAL: 0x00128f58

Implements MsgSink.

◆ GetTick()

int MultiGameLogic::GetTick ( )
overridevirtual

Report the tick of the scheduler's clock.

Returns
The tick.
Ghidra address:
NTSC-U/C: 0x00125210
Ghidra address:
PAL: 0x00126990

Implements WorldLogic.

◆ GetTime()

float MultiGameLogic::GetTime ( )
overridevirtual

Report the time of the scheduler's clock.

Returns
The time.
Ghidra address:
NTSC-U/C: 0x00125230
Ghidra address:
PAL: 0x001269b0

Implements WorldLogic.

◆ HandleInput()

void MultiGameLogic::HandleInput ( const RotateEvent & event)
overridevirtual

Move a player to a neighbouring track and ask the arbiter to settle the move.

Parameters
eventThe event.
Ghidra address:
NTSC-U/C: 0x00125250
Ghidra address:
PAL: 0x001269d0

Reimplemented from GameLogic.

◆ SetPaused()

void MultiGameLogic::SetPaused ( bool bPaused,
int nPad,
int nReason )
overridevirtual

Pause or resume, and show the pause dialog when pausing.

Only a playing song pauses, and a request that does not change the state is ignored.

Parameters
bPausedWhether to pause.
nPadThe pad that requested the change.
nReasonNon-zero for a disconnected controller.
Ghidra address:
NTSC-U/C: 0x00124e10
Ghidra address:
PAL: 0x00126590

Reimplemented from GameLogic.

◆ DeploySlowdown()

bool MultiGameLogic::DeploySlowdown ( Player * pPlayer)
overridevirtual

Slow the song down for a player and, for a local player online, send a SlowdownPacket.

Parameters
pPlayerThe player.
Returns
Whether the power-up was deployed.
Ghidra address:
NTSC-U/C: 0x00125a50
Ghidra address:
PAL: 0x00127260

Reimplemented from GameLogic.

◆ DeployFreestyle()

bool MultiGameLogic::DeployFreestyle ( Player * pPlayer)
overridevirtual

Move a player to the freestyle track.

Offline, a player already on the freestyle track first moves to a random catch track.

Parameters
pPlayerThe player.
Returns
true.
Ghidra address:
NTSC-U/C: 0x00125b00
Ghidra address:
PAL: 0x00127310

Reimplemented from GameLogic.

◆ DeployBumper()

bool MultiGameLogic::DeployBumper ( Player * pPlayer)
overridevirtual

Bump every other player on a player's track to a random other track.

Parameters
pPlayerThe player.
Returns
Whether a player was bumped.
Ghidra address:
NTSC-U/C: 0x00125c18
Ghidra address:
PAL: 0x00127428

Reimplemented from GameLogic.

◆ DeployCrippler()

bool MultiGameLogic::DeployCrippler ( Player * pPlayer)
overridevirtual

Cripple every other player on a player's track.

Parameters
pPlayerThe player.
Returns
Whether a player was crippled.
Ghidra address:
NTSC-U/C: 0x001260a8
Ghidra address:
PAL: 0x001278b8

Reimplemented from GameLogic.

◆ EndFreestyle()

void MultiGameLogic::EndFreestyle ( Player * pPlayer)
overridevirtual

Move a player from the freestyle track back to a catch track.

Parameters
pPlayerThe player.
Ghidra address:
NTSC-U/C: 0x00125ba8
Ghidra address:
PAL: 0x001273b8

Reimplemented from GameLogic.

◆ OnStart()

void MultiGameLogic::OnStart ( )
overridevirtual

Enable the catch tracks, schedule the end of the song, and start the arbiter.

Ghidra address:
NTSC-U/C: 0x00124d40
Ghidra address:
PAL: 0x001264c0

Implements GameLogic.

◆ OnFinish()

void MultiGameLogic::OnFinish ( bool bWon)
overridevirtual

Celebrate a won song and collect or send the final score.

Parameters
bWonWhether the song was won.
Ghidra address:
NTSC-U/C: 0x001256b0
Ghidra address:
PAL: 0x00126ec0

Implements GameLogic.

◆ OnBar()

void MultiGameLogic::OnBar ( int nBar)
overridevirtual

Update the score leader.

Parameters
nBarThe bar.
Ghidra address:
NTSC-U/C: 0x00124fa0
Ghidra address:
PAL: 0x00126720

Implements GameLogic.

◆ OnSection()

void MultiGameLogic::OnSection ( )
overridevirtual

Announce the completed stage while sections remain.

Ghidra address:
NTSC-U/C: 0x00124fc0
Ghidra address:
PAL: 0x00126740

Implements GameLogic.

◆ OnPhraseCaptured()

void MultiGameLogic::OnPhraseCaptured ( CatchTrack * pTrack,
Player * pPlayer,
int nBar,
bool bAutocatch )
overridevirtual

Update the score leader and, for a local player online, send a CapturePacket.

Parameters
pTrackThe track the phrase was captured on.
pPlayerThe player that captured it.
nBarUnused.
bAutocatchWhether an autocatcher captured the phrase.
Ghidra address:
NTSC-U/C: 0x001254d8
Ghidra address:
PAL: 0x00126c58

Implements GameLogic.

◆ OnPhraseEnded()

void MultiGameLogic::OnPhraseEnded ( Track * pTrack)
overridevirtual

Act once a phrase of a track ended.

The body is empty.

Parameters
pTrackThe track.
Ghidra address:
NTSC-U/C: 0x001255c8
Ghidra address:
PAL: 0x00126d48

Implements GameLogic.

◆ OnPhraseMissed()

void MultiGameLogic::OnPhraseMissed ( Track * pTrack)
inlineoverridevirtual

Act once a player missed a phrase.

The body is empty.

Parameters
pTrackThe track.
Ghidra address:
NTSC-U/C: 0x0033c0d0
Ghidra address:
PAL: 0x003a9608

Implements GameLogic.


The documentation for this class was generated from the following file: