wavelength 1.0.0
Loading...
Searching...
No Matches
triggermgr.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4#include <utility>
5#include <vector>
6
8#include "game/triggerevent.h"
9#include "os/binstream.h"
10#include "os/string.h"
15
29public:
31 enum Clock {
35 };
36
38 enum {
42 };
43
51
59
68 void Init();
69
78 void Terminate();
79
87 void SetPaths(const std::vector<bool> &paths);
88
97 bool IsPathUnlocked(unsigned int nPath) const;
98
107 bool PathExists(unsigned int nPath) const;
108
119 void Schedule(TriggerAction *pAction, float flDelay);
120
130 void AddRunning(TriggerAction *pAction);
131
138 void Poll();
139
148 void Load(const char *pszFile, BinStream *pStream);
149
157 void AddTriggers(DataArray *pTriggers);
158
166 void BeatEvent(char chNote);
167
180 void MetagameEvent(float flStart, float flTime, float flValue);
181
193
202
211
222 void ComponentFocusEvent(const char *pszComponent, const char *pszPanel, const char *pszScreen);
223
232
241 void ButtonEvent(int nPlayer, int nButtons);
242
253 void BeginEvent(int nRuleSet);
254
262 void StageCompleteEvent(int nPlayer);
263
272 void EndEvent(int nState, int nPlayer);
273
282 void ScoreEvent(int nPlayer, int nScore);
283
292 void HitEvent(int nPlayer, int nGemPos);
293
302 void MissEvent(int nPlayer, int nGemPos);
303
314 void GemEvent(int nTrack, int nGemPos);
315
323 void NewBarEvent(int nBar);
324
334 void PhraseEndEvent(int nTrack);
335
346 void PhraseCaptureEvent(int nPlayer, int nStreak);
347
357 void PhraseMissEvent(int nPlayer);
358
369 void NewTrackEvent(int nPlayer, int nTrack, int nInstrument, int nMode);
370
379 void HealthEvent(int nPlayer, int nHealth);
380
391 void DyingEvent(int nPlayer, int nDying);
392
400
410 void LyricEvent(const char *pszLyric);
411
419 void PathUnlockedEvent(int nPath);
420
422 int GetClock() const {
423 return mClock;
424 }
425
431 void SetClock(int nClock) {
432 mClock = nClock;
433 }
434
436 float GetCurrentTime() const {
437 return mTime[mClock];
438 }
439
446 float GetTime(int nClock) const {
447 return mTime[nClock];
448 }
449
451 int GetPlayer() const {
452 return mPlayer;
453 }
454
456 char GetNote() const {
457 return mNote;
458 }
459
461 int GetGemPos() const {
462 return mGemPos;
463 }
464
466 const String &GetLyric() const {
467 return mLyric;
468 }
469
471 int GetBar() const {
472 return mBar;
473 }
474
476 int GetButtons() const {
477 return mButtons;
478 }
479
486 int GetCapturer(int nTrack) const {
487 return mCapturer[nTrack];
488 }
489
491 const String &GetComponent() const {
492 return mComponent;
493 }
494
496 float GetDistance() const {
497 return mDistance;
498 }
499
506 int GetDying(int nPlayer) const {
507 return mDying[nPlayer];
508 }
509
511 int GetGameState() const {
512 return mGameState;
513 }
514
521 int GetHealth(int nPlayer) const {
522 return mHealth[nPlayer];
523 }
524
531 int GetInstrument(int nPlayer) const {
532 return mInstrument[nPlayer];
533 }
534
536 int GetLeader() const {
537 return mLeader;
538 }
539
546 int GetMode(int nPlayer) const {
547 return mMode[nPlayer];
548 }
549
551 const String &GetOldComponent() const {
552 return mOldComponent;
553 }
554
556 const String &GetOldPanel() const {
557 return mOldPanel;
558 }
559
561 const String &GetOldScreen() const {
562 return mOldScreen;
563 }
564
566 const String &GetPanel() const {
567 return mPanel;
568 }
569
571 int GetPowerup() const {
572 return mPowerup;
573 }
574
576 float GetRandom() const {
577 return mRandom;
578 }
579
581 int GetRuleSet() const {
582 return mRuleSet;
583 }
584
591 int GetScore(int nPlayer) const {
592 return mScore[nPlayer];
593 }
594
596 const String &GetScreen() const {
597 return mScreen;
598 }
599
606 int GetStreak(int nPlayer) const {
607 return mStreak[nPlayer];
608 }
609
616 int GetTrack(int nPlayer) const {
617 return mTrack[nPlayer];
618 }
619
620private:
621 std::vector<TriggerEvent> mEvents;
622 std::list<TriggerAction *> mRunning;
624 std::list<std::pair<TriggerAction *, float>> mScheduled[kNumClocks];
625 char mNote;
626 int mPlayer;
627 float mTime[kNumClocks];
628 int mClock;
629 float mDistance;
630 int mLeader;
631 int mBar;
632 int mPowerup;
633 int mHealth[kNumPlayers];
634 int mDying[kNumPlayers];
635 int mScore[kNumPlayers];
636 int mTrack[kNumPlayers];
637 int mStreak[kNumPlayers];
638 int mInstrument[kNumPlayers];
639 int mMode[kNumPlayers];
640 int mButtons;
641 int mGemPos;
642 String mComponent;
643 String mOldComponent;
644 String mPanel;
645 String mOldPanel;
646 String mScreen;
647 String mOldScreen;
648 int mGameState;
649 int mRuleSet;
650 String mLyric;
651 int mCapturer[kNumTracks];
652 float mRandom;
653 std::vector<bool> mPaths;
654 int mDebug;
655};
656
const int kNumPlayers
Number of players.
Definition Joypad.h:12
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
Reference-counted array of script data nodes.
Definition dataarray.h:20
Growable text buffer that is also a PrnStream.
Definition string.h:19
Something a trigger does when its conditions hold.
Definition triggeraction.h:15
Registry of the triggers that fire actions on game and display events.
Definition triggermgr.h:28
void ScoreEvent(int nPlayer, int nScore)
Fire the triggers that wait on a new score.
void PathUnlockedEvent(int nPath)
Fire the triggers that wait on a path being unlocked.
const String & GetScreen() const
Definition triggermgr.h:596
@ kNumTracks
Definition triggermgr.h:41
@ kNumPlayers
Definition triggermgr.h:39
@ kNoPlayer
Definition triggermgr.h:40
void AddTriggers(DataArray *pTriggers)
Register the triggers of an array, each with the event its node 0 names.
void ButtonEvent(int nPlayer, int nButtons)
Fire the triggers that wait on a button.
void ComponentFocusEvent(const char *pszComponent, const char *pszPanel, const char *pszScreen)
Fire the triggers that wait on the focus arriving at a component, with no previous component.
void EndEvent(int nState, int nPlayer)
Fire the triggers that wait on the end of the game.
int GetPowerup() const
Definition triggermgr.h:571
const String & GetPanel() const
Definition triggermgr.h:566
void ComponentSelectEvent(UIComponentSelectMsg *pMsg)
Fire the triggers that wait on a component being chosen.
const String & GetComponent() const
Definition triggermgr.h:491
int GetGemPos() const
Definition triggermgr.h:461
void ComponentSelectStartEvent(UIComponentSelectStartMsg *pMsg)
Fire the triggers that wait on the choice of a component beginning.
int GetScore(int nPlayer) const
Report the score of a player.
Definition triggermgr.h:591
void PhraseMissEvent(int nPlayer)
Fire the triggers that wait on a missed phrase.
void HitEvent(int nPlayer, int nGemPos)
Fire the triggers that wait on a player hitting a gem.
float GetDistance() const
Definition triggermgr.h:496
void BeginEvent(int nRuleSet)
Fire the triggers that wait on the begin event.
void PhraseCaptureEvent(int nPlayer, int nStreak)
Fire the triggers that wait on a player capturing a phrase.
int GetCapturer(int nTrack) const
Report the player who captured a track.
Definition triggermgr.h:486
void MetagameEvent(float flStart, float flTime, float flValue)
Advance the clocks and fire the triggers that wait on the time.
void DyingEvent(int nPlayer, int nDying)
Fire the triggers that wait on a player starting or stopping dying.
const String & GetLyric() const
Definition triggermgr.h:466
void NewBarEvent(int nBar)
Fire the triggers that wait on the start of a bar.
bool IsPathUnlocked(unsigned int nPath) const
Report whether a path exists and is unlocked.
int GetDying(int nPlayer) const
Report whether a player is dying.
Definition triggermgr.h:506
int GetBar() const
Definition triggermgr.h:471
void NewTrackEvent(int nPlayer, int nTrack, int nInstrument, int nMode)
Fire the triggers that wait on a player moving to a new track.
int GetGameState() const
Definition triggermgr.h:511
const String & GetOldPanel() const
Definition triggermgr.h:556
bool PathExists(unsigned int nPath) const
Report whether a path exists.
int GetStreak(int nPlayer) const
Report the phrase streak of a player.
Definition triggermgr.h:606
void MissEvent(int nPlayer, int nGemPos)
Fire the triggers that wait on a player missing a gem.
void AddRunning(TriggerAction *pAction)
Poll an action every frame until it reports itself done.
~TriggerMgr()
Release every trigger.
int GetHealth(int nPlayer) const
Report the health of a player.
Definition triggermgr.h:521
void GemEvent(int nTrack, int nGemPos)
Fire the triggers that wait on a gem of a captured track.
void Poll()
Run the actions whose time has come, and poll the running actions.
const String & GetOldComponent() const
Definition triggermgr.h:551
char GetNote() const
Definition triggermgr.h:456
int GetTrack(int nPlayer) const
Report the track of a player.
Definition triggermgr.h:616
int GetRuleSet() const
Definition triggermgr.h:581
int GetLeader() const
Definition triggermgr.h:536
void Load(const char *pszFile, BinStream *pStream)
Read triggers from a data file and register them.
float GetTime(int nClock) const
Report the time of a clock.
Definition triggermgr.h:446
int GetPlayer() const
Definition triggermgr.h:451
int GetButtons() const
Definition triggermgr.h:476
void Terminate()
Release every registered trigger.
void StageCompleteEvent(int nPlayer)
Fire the triggers that wait on a player completing a stage.
float GetRandom() const
Definition triggermgr.h:576
void HealthEvent(int nPlayer, int nHealth)
Fire the triggers that wait on a change of health.
void SetClock(int nClock)
Set the clock of the action in progress.
Definition triggermgr.h:431
TriggerMgr()
Construct the registry with an empty event of each kind.
void Init()
Read the "trigger" section of the configuration.
void BossJourneyEvent()
Fire the triggers that wait on the boss journey starting.
void ScreenChangeEvent(UIScreenChangeMsg *pMsg)
Fire the triggers that wait on a move between screens.
float GetCurrentTime() const
Definition triggermgr.h:436
int GetInstrument(int nPlayer) const
Report the instrument of the track of a player.
Definition triggermgr.h:531
int GetMode(int nPlayer) const
Report the music mode of the track of a player.
Definition triggermgr.h:546
Clock
The clocks an action runs on, the indices of mTime.
Definition triggermgr.h:31
@ kClockReal
Definition triggermgr.h:33
@ kNumClocks
Definition triggermgr.h:34
@ kClockGame
Definition triggermgr.h:32
const String & GetOldScreen() const
Definition triggermgr.h:561
void LyricEvent(const char *pszLyric)
Fire the triggers that wait on a lyric.
void SetPaths(const std::vector< bool > &paths)
Record which paths of the arena are unlocked.
int GetClock() const
Definition triggermgr.h:422
void ComponentFocusEvent(UIComponentFocusChangeMsg *pMsg)
Fire the triggers that wait on the focus moving between components.
void BeatEvent(char chNote)
Fire the triggers that wait on a note of the background music.
void Schedule(TriggerAction *pAction, float flDelay)
Schedule an action to run after a delay on the current clock.
void PhraseEndEvent(int nTrack)
Fire the triggers that wait on the end of a phrase.
Message a panel sends before it moves its focus to another component.
Definition uicomponentfocuschangemsg.h:26
Message a component sends when the player chooses it.
Definition uicomponentselectmsg.h:28
Message a component sends when the player presses the button that chooses it.
Definition uicomponentselectstartmsg.h:27
Message UIManager sends before it leaves the current screen for another.
Definition uiscreenchangemsg.h:24
TriggerMgr TheTriggerMgr
The trigger registry.