resonance 1.0.1
Loading...
Searching...
No Matches
player.h
Go to the documentation of this file.
1#pragma once
2
3#include <iostream>
4
5#include "app/msgsink.h"
6#include "app/msgsource.h"
7#include "game/idable.h"
8#include "os/hxstr.h"
9
10class FreqAppearance;
13
15constexpr int kNoInputSlot = -1;
16
39class Player : public IDable<Player>, public MsgSink, public MsgSource {
40public:
53 Player(int nId, const HxStr &colorName, const FreqAppearance *pAppearance);
54
59 virtual ~Player();
60
71 virtual int GetInputSlot() const;
72
83 virtual int IsNull();
84
95 virtual int GetTrack();
96
107 virtual int GetPlace();
108
119 virtual int UnusedQuery();
120
130 virtual void UnusedHook();
131
144 virtual void SetFreestyleSpan(int nStartBar, int nEndBar);
145
157 virtual int IsFreestyleBar(int nBar);
158
169 virtual int IsLooping();
170
181 virtual void AnnounceState();
182
193 virtual void DeactivatePlacer();
194
206 virtual void Print(std::ostream &stream);
207
220 virtual int CountCaughtGem();
221
232 virtual int CountMissedGem();
233
245 virtual int GetMultiplier(int nBar);
246
256 virtual int GetBestStreak();
257
267 virtual float GetCaptureRatio();
268
278 virtual int GetGameMode();
279
291 virtual int MarkBarScored(int nBar);
292
305 virtual void DispatchPriv(Message *pMsg);
306
307 // Declared in recovered offset order. The base subobjects occupy +0x00 through +0x1f.
319
328
340 int GetJuice();
341
352 int GetScore();
353
364 void SetScore(int nScore, int nMaxScore);
365
377 void SetJuice(int nJuice, int nMaxJuice);
378
391 void AddJuice(int nAmount, int bNotify);
392
405 void AddScore(int nDelta, int bNotify);
406
416 void OnMsg(const PhraseCapturedMsg &msg);
417
428 int IsLocal() const {
429 return GetInputSlot() != kNoInputSlot;
430 }
431
442 static void Delete(Player *pPlayer) {
443 delete pPlayer;
444 }
445
456
467
477 int StartMF();
478
488 int StopMF();
489
490private:
499 void OnUpdateScore(UpdateScorePacket *pPacket);
500
501 // The persona's appearance. GrooveWorld::AddLocalPlayer() passes MetPersonaData::mAppearance.
502 const FreqAppearance *mAppearance; // +0x2c
503 int mJuice; // +0x30
504
505protected:
506 // The ceiling AddJuice() clamps mJuice to. AnnounceState() clamps it to kJuiceMaximum before
507 // announcing it.
508 int mMaxJuice; // +0x34
509
510private:
511 int mScore; // +0x38
512
513protected:
514 // The ceiling AddScore() clamps mScore to. LocalPlayer::AnnounceState() announces it.
515 int mMaxScore; // +0x3c
516
517public:
525 long long mLastEraseTime;
526};
Appearance of a player's avatar.
Definition freqappearance.h:39
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
IDable(int nId)
Definition idable.h:40
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:41
Receiver of engine messages.
Definition msgsink.h:37
Sender of engine messages, which stores the list of sinks that receive them.
Definition msgsource.h:26
Event the game passes between a MsgSource and a MsgSink.
Definition phrasecapturedmsg.h:27
void AddJuice(int nAmount, int bNotify)
Add juice, clamped to 0 through the ceiling, and announce a change.
virtual int GetGameMode()
Report the game mode the player was built in.
virtual void SetFreestyleSpan(int nStartBar, int nEndBar)
Give the player a span of bars it plays freely.
virtual int IsFreestyleBar(int nBar)
Test whether a bar lies in the player's freestyle span.
HxStr mColorName
The player's colour name, such as green or red.
Definition player.h:327
virtual void UnusedHook()
Do nothing.
virtual int GetInputSlot() const
Report the controller slot that drives this player.
virtual float GetCaptureRatio()
Report the proportion of captured phrases among those captured and muffed.
int IsLocal() const
Report whether the player has an input slot.
Definition player.h:428
virtual void DispatchPriv(Message *pMsg)
Receive one message.
virtual int UnusedQuery()
Report zero.
void AddScore(int nDelta, int bNotify)
Add to the score, clamped to 0 through the ceiling, and announce a change.
virtual void DeactivatePlacer()
Deactivate the powerup placer.
int GetScore()
Report the player's score.
static void Delete(Player *pPlayer)
Delete a player through its virtual destructor, doing nothing for null.
Definition player.h:442
HxStr GetUsername()
Copy the username of the player's appearance.
int GetJuice()
Report the juice the player has banked.
int mMaxScore
Definition player.h:515
int mMaxJuice
Definition player.h:508
virtual int GetMultiplier(int nBar)
Report the score multiplier a capture starting at a bar earns.
virtual int IsLooping()
Report whether the player is looping.
virtual int GetBestStreak()
Report the best streak of consecutive captures.
virtual int CountCaughtGem()
Count one caught gem.
virtual int IsNull()
Test whether this player is the stand-in for an absent one.
virtual int GetPlace()
Report the player's place on its track.
virtual ~Player()
int StartMF()
Run AnnounceState() and report zero.
long long mLastEraseTime
Scheduler time of this player's last erase press, in nanoseconds.
Definition player.h:525
void OnMsg(const PhraseCapturedMsg &msg)
Add a captured phrase's score and juice, announcing both.
int StopMF()
Run DeactivatePlacer() and report zero.
void SetScore(int nScore, int nMaxScore)
Set the score and the ceiling it is clamped to.
virtual int MarkBarScored(int nBar)
Record that a bar scored, reporting whether it had not scored before.
virtual void Print(std::ostream &stream)
Write a description of this player to stream.
virtual void AnnounceState()
Announce the player's state.
HxStr GetColorName()
Copy the player's colour name.
void SetJuice(int nJuice, int nMaxJuice)
Set the juice and the ceiling it is clamped to.
Player(int nId, const HxStr &colorName, const FreqAppearance *pAppearance)
Register the player under its identifier and start its tallies.
virtual int GetTrack()
Report the track this player occupies.
int mPlayerId
Identifier a message addresses this player by.
Definition player.h:318
virtual int CountMissedGem()
Count one missed gem.
Network packet the game sends between game systems.
Definition updatescorepacket.h:26
constexpr int kNoInputSlot
What Player::GetInputSlot() reports for a player with no input slot.
Definition player.h:15