resonance 1.0.1
Loading...
Searching...
No Matches
LocalPlayer Class Reference

Player driven by a controller on this machine. More...

#include <localplayer.h>

Inheritance diagram for LocalPlayer:
Collaboration diagram for LocalPlayer:

Public Member Functions

 LocalPlayer (int nId, int nInputSlot, const HxStr &colorName, const FreqAppearance *pAppearance, Sch::TickClock *pClock, int nTrack)
 Build the player and the powerup collection and placer its play mode calls for.
virtual ~LocalPlayer ()
 Delete the placer and the collection.
virtual int GetInputSlot () const
virtual int GetTrack ()
virtual int GetPlace ()
virtual int UnusedQuery ()
virtual void UnusedHook ()
virtual void SetFreestyleSpan (int nStartBar, int nEndBar)
virtual int IsFreestyleBar (int nBar)
virtual int IsLooping ()
virtual void AnnounceState ()
 Announce the player's whole state and start the per-bar command.
virtual void DeactivatePlacer ()
 Run PowerupPlacer::Deactivate() on the placer.
virtual int CountCaughtGem ()
virtual int CountMissedGem ()
virtual int GetMultiplier (int nBar)
 Report the multiplier a capture starting at a bar earns.
virtual int GetBestStreak ()
 Report the best streak of consecutive captures.
virtual float GetCaptureRatio ()
 Report the proportion of captured phrases among those captured and muffed.
virtual int GetGameMode ()
virtual int MarkBarScored (int nBar)
virtual void SetLooping (int bLooping, const Sch::Tick &position)
 Start or stop looping.
virtual void SetGhost (int bGhost)
 Show or hide the player's ghost.
virtual void DispatchPriv (Message *pMsg)
 Receive one message.
virtual void AddSink (MsgSink *pSink)
virtual void RemoveSink (MsgSink *pSink)
void OnBarTick (int nTick)
 Run the update of the bar that starts at a tick, then post the next bar's.
void ToggleLoop (const Sch::Tick &position)
 Toggle looping.
Public Member Functions inherited from Player
 Player (int nId, const HxStr &colorName, const FreqAppearance *pAppearance)
 Register the player under its identifier and start its tallies.
virtual ~Player ()
virtual int IsNull ()
 Test whether this player is the stand-in for an absent one.
virtual void Print (std::ostream &stream)
 Write a description of this player to stream.
int GetJuice ()
 Report the juice the player has banked.
int GetScore ()
 Report the player's score.
void SetScore (int nScore, int nMaxScore)
 Set the score and the ceiling it is clamped to.
void SetJuice (int nJuice, int nMaxJuice)
 Set the juice and the ceiling it is clamped to.
void AddJuice (int nAmount, int bNotify)
 Add juice, clamped to 0 through the ceiling, and announce a change.
void AddScore (int nDelta, int bNotify)
 Add to the score, clamped to 0 through the ceiling, and announce a change.
void OnMsg (const PhraseCapturedMsg &msg)
 Add a captured phrase's score and juice, announcing both.
int IsLocal () const
 Report whether the player has an input slot.
HxStr GetColorName ()
 Copy the player's colour name.
HxStr GetUsername ()
 Copy the username of the player's appearance.
int StartMF ()
 Run AnnounceState() and report zero.
int StopMF ()
 Run DeactivatePlacer() and report zero.
Public Member Functions inherited from IDable< Player >
 IDable (int nId)
 Register the object in sObjects under an identifier.
virtual ~IDable ()
 Release the table slot this object occupies.
Public Member Functions inherited from IDableBase
virtual ~IDableBase ()
Public Member Functions inherited from MsgSink
void * operator new (size_t nSize)
 Allocate a sink from the tagged heap under the tag "MsgSink".
void operator delete (void *pBlock)
 Release a sink to the tagged heap.
virtual ~MsgSink ()
virtual void Dispatch (Message *pMsg)
 Accept a message.
Public Member Functions inherited from MsgSource
virtual ~MsgSource ()
void Send (Message *pMsg) const
 Deliver a message to every registered sink, in registration order.
void ClearSinks ()
 Unregister every sink.

Public Attributes

PowerupCollectionI * mCollection
Public Attributes inherited from Player
int mPlayerId
 Identifier a message addresses this player by.
HxStr mColorName
 The player's colour name, such as green or red.
long long mLastEraseTime
 Scheduler time of this player's last erase press, in nanoseconds.
Public Attributes inherited from MsgSource
int mGraphBuilt
 A word no member of this class reads.

Additional Inherited Members

Static Public Member Functions inherited from Player
static void Delete (Player *pPlayer)
 Delete a player through its virtual destructor, doing nothing for null.
Static Public Attributes inherited from IDable< Player >
static std::vector< Player * > sObjects
 Every registered object, indexed by mId.
Protected Attributes inherited from Player
int mMaxJuice
int mMaxScore
Protected Attributes inherited from IDableBase
int mId

Detailed Description

Player driven by a controller on this machine.

LocalPlayer in the RTTI descriptor at 0x008eeff8, with Player as its only base. Its three vtables are at 0x007d0160, 0x007d0138, and 0x007d0110, each walked to its terminator.

The primary table has 23 entries against the base's 21, so this class adds two virtuals past the end of the base table rather than overriding into it. It replaces slots 2 and 4 through 12 and 14 through 20, and inherits only slots 3 and 13. In the MsgSource table it replaces both AddSink and RemoveSink, which the base leaves inherited, and in the MsgSink table it replaces DispatchPriv.

The constructor gives the player a powerup collection and a placer that fits the play mode, and AddSink() and RemoveSink() fan registration out to both. The player also keeps the capture statistics the solo statistics read back: the streak of consecutive captures and its best, the multiplier, and the counts of captured and muffed phrases. A LocalPlayerCmd posted every bar on mClock ends a multiplier bonus and resets the multiplier when the player stops catching.

Constructor & Destructor Documentation

◆ LocalPlayer()

LocalPlayer::LocalPlayer ( int nId,
int nInputSlot,
const HxStr & colorName,
const FreqAppearance * pAppearance,
Sch::TickClock * pClock,
int nTrack )

Build the player and the powerup collection and placer its play mode calls for.

In jam the player gets an unlimited PowerupCollection and a JamPowerupPlacer, a freestyle span that never ends, and starts looping. In game modes 1 through 3 it gets a SinglePowerupCollection and a SimplifiedGamePowerupPlacer. In any other mode it gets neither.

Parameters
nIdThe player's identifier.
nInputSlotThe controller slot GetInputSlot() reports.
colorNameThe player's colour name.
pAppearanceThe appearance the player is drawn with.
pClockThe clock the per-bar command is posted on.
nTrackThe track GetTrack() reports.
Ghidra address:
NTSC-U/C: 0x0011e000
Ghidra address:
PAL: 0x0011e5a0

◆ ~LocalPlayer()

virtual LocalPlayer::~LocalPlayer ( )
virtual

Delete the placer and the collection.

Ghidra address:
NTSC-U/C: 0x0011e348
Ghidra address:
PAL: 0x0011e8f8

Member Function Documentation

◆ GetInputSlot()

virtual int LocalPlayer::GetInputSlot ( ) const
virtual
Ghidra address:
NTSC-U/C: 0x00121ea0
Ghidra address:
PAL: 0x001224a8

Reimplemented from Player.

◆ GetTrack()

virtual int LocalPlayer::GetTrack ( )
virtual
Ghidra address:
NTSC-U/C: 0x00121e90
Ghidra address:
PAL: 0x00122498

Reimplemented from Player.

◆ GetPlace()

virtual int LocalPlayer::GetPlace ( )
virtual
Ghidra address:
NTSC-U/C: 0x00121e98
Ghidra address:
PAL: 0x001224a0

Reimplemented from Player.

◆ UnusedQuery()

virtual int LocalPlayer::UnusedQuery ( )
virtual
Ghidra address:
NTSC-U/C: 0x00122890
Ghidra address:
PAL: 0x00122ea8

Reimplemented from Player.

◆ UnusedHook()

virtual void LocalPlayer::UnusedHook ( )
virtual
Ghidra address:
NTSC-U/C: 0x00121ea8
Ghidra address:
PAL: 0x001224b0

Reimplemented from Player.

◆ SetFreestyleSpan()

virtual void LocalPlayer::SetFreestyleSpan ( int nStartBar,
int nEndBar )
virtual
Ghidra address:
NTSC-U/C: 0x00122898
Ghidra address:
PAL: 0x00122eb0

Reimplemented from Player.

◆ IsFreestyleBar()

virtual int LocalPlayer::IsFreestyleBar ( int nBar)
virtual
Ghidra address:
NTSC-U/C: 0x001228a8
Ghidra address:
PAL: 0x00122ec0

Reimplemented from Player.

◆ IsLooping()

virtual int LocalPlayer::IsLooping ( )
virtual
Ghidra address:
NTSC-U/C: 0x00121eb0
Ghidra address:
PAL: 0x001224b8

Reimplemented from Player.

◆ AnnounceState()

virtual void LocalPlayer::AnnounceState ( )
virtual

Announce the player's whole state and start the per-bar command.

Runs Player::AnnounceState(), then sends a TrackSelectMsg for the player's track at the current song position, has the collection announce its state, and sends a PointAmountMsg, a ToggleGhostMsg, and a LoopToggleMsg. It then posts a LocalPlayerCmd at the end of the first bar under mCommand.

Ghidra address:
NTSC-U/C: 0x0011e4e0
Ghidra address:
PAL: 0x0011eaa0

Reimplemented from Player.

◆ DeactivatePlacer()

virtual void LocalPlayer::DeactivatePlacer ( )
virtual

Run PowerupPlacer::Deactivate() on the placer.

That slot's body is two instructions, and the call arrives at an empty routine. Both the PowerupPlacer and JamPowerupPlacer tables record the same address for it rather than a re-emitted copy each. The shared address proves the empty body is inherited rather than a local override. This dispatch is therefore real and does nothing.

Ghidra address:
NTSC-U/C: 0x001228c8
Ghidra address:
PAL: 0x00122ee0

Reimplemented from Player.

◆ CountCaughtGem()

virtual int LocalPlayer::CountCaughtGem ( )
virtual
Ghidra address:
NTSC-U/C: 0x00121ec0
Ghidra address:
PAL: 0x001224c8

Reimplemented from Player.

◆ CountMissedGem()

virtual int LocalPlayer::CountMissedGem ( )
virtual
Ghidra address:
NTSC-U/C: 0x00121ed0
Ghidra address:
PAL: 0x001224d8

Reimplemented from Player.

◆ GetMultiplier()

virtual int LocalPlayer::GetMultiplier ( int nBar)
virtual

Report the multiplier a capture starting at a bar earns.

A bar after the end of the last caught run earns only the bonus plus one, and a bar inside it adds the streak multiplier.

Ghidra address:
NTSC-U/C: 0x00122ca0
Ghidra address:
PAL: 0x001232b8

Reimplemented from Player.

◆ GetBestStreak()

virtual int LocalPlayer::GetBestStreak ( )
virtual

Report the best streak of consecutive captures.

Ghidra address:
NTSC-U/C: 0x00121ee0
Ghidra address:
PAL: 0x001224e8

Reimplemented from Player.

◆ GetCaptureRatio()

virtual float LocalPlayer::GetCaptureRatio ( )
virtual

Report the proportion of captured phrases among those captured and muffed.

Returns zero when nothing was captured, so the division never runs on an empty total.

Returns
A fraction between 0 and 1.
Ghidra address:
NTSC-U/C: 0x00122cc8
Ghidra address:
PAL: 0x001232e0

Reimplemented from Player.

◆ GetGameMode()

virtual int LocalPlayer::GetGameMode ( )
virtual
Ghidra address:
NTSC-U/C: 0x00121ee8
Ghidra address:
PAL: 0x001224f0

Reimplemented from Player.

◆ MarkBarScored()

virtual int LocalPlayer::MarkBarScored ( int nBar)
virtual
Ghidra address:
NTSC-U/C: 0x00122c00
Ghidra address:
PAL: 0x00123218

Reimplemented from Player.

◆ SetLooping()

virtual void LocalPlayer::SetLooping ( int bLooping,
const Sch::Tick & position )
virtual

Start or stop looping.

Only in jam. Stores bLooping, invalidates the seeker of the player's track at the position's bar, and sends a LoopToggleMsg. The title is inferred.

Parameters
bLoopingNon-zero to loop.
positionThe song position of the change.
Ghidra address:
NTSC-U/C: 0x0011e810
Ghidra address:
PAL: 0x0011edd0

◆ SetGhost()

virtual void LocalPlayer::SetGhost ( int bGhost)
virtual

Show or hide the player's ghost.

Slot 22, declared by this class rather than inherited. Returns at once unless the play mode is jam. Otherwise it stores its argument in mGhost and sends a ToggleGhostMsg for this player with its argument as ToggleGhostMsg::mOn. The set-ghost-mode script command is the recovered caller.

Parameters
bGhostNon-zero to show the ghost.
Ghidra address:
NTSC-U/C: 0x0011e908
Ghidra address:
PAL: 0x0011eec8

◆ DispatchPriv()

virtual void LocalPlayer::DispatchPriv ( Message * pMsg)
virtual

Receive one message.

Acts on the controller, capture, and powerup messages that address this player, and passes every message it does not recognise to Player::DispatchPriv().

Parameters
pMsgThe message.
Ghidra address:
NTSC-U/C: 0x0011ed98
Ghidra address:
PAL: 0x0011f358

Reimplemented from Player.

◆ AddSink()

virtual void LocalPlayer::AddSink ( MsgSink * pSink)
virtual
Ghidra address:
NTSC-U/C: 0x001228f8
Ghidra address:
PAL: 0x00122f10

Reimplemented from MsgSource.

◆ RemoveSink()

virtual void LocalPlayer::RemoveSink ( MsgSink * pSink)
virtual
Ghidra address:
NTSC-U/C: 0x00122968
Ghidra address:
PAL: 0x00122f80

Reimplemented from MsgSource.

◆ OnBarTick()

void LocalPlayer::OnBarTick ( int nTick)

Run the update of the bar that starts at a tick, then post the next bar's.

Ends a multiplier bonus whose last bar has passed, resets the multiplier two bars after the last caught bar, and announces the multiplier when either changes. LocalPlayerCmd::Execute() is the caller. The title is inferred.

Parameters
nTickThe song position.
Ghidra address:
NTSC-U/C: 0x0011ec00
Ghidra address:
PAL: 0x0011f1c0

◆ ToggleLoop()

void LocalPlayer::ToggleLoop ( const Sch::Tick & position)

Toggle looping.

Only in jam. Invalidates the seeker of the player's track at the position's bar and sends a LoopToggleMsg. The title is inferred.

Parameters
positionThe song position of the change.
Ghidra address:
NTSC-U/C: 0x0011e700
Ghidra address:
PAL: 0x0011ecc0

Member Data Documentation

◆ mCollection

PowerupCollectionI* LocalPlayer::mCollection

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