wavelength 1.0.0
Loading...
Searching...
No Matches
worldlogic.h
Go to the documentation of this file.
1#pragma once
2
3#include "app/msgsink.h"
4#include "game/btnevent.h"
7#include "game/rotateevent.h"
8#include "game/stickevent.h"
10#include "msg/message.h"
11#include "os/command.h"
12#include "os/ptr.h"
13
14#ifdef VIDEO_STANDARD_PAL
15// Only the PAL build includes the header. In the NTSC build it changes the code GCC emits for the
16// virtual call in DispatchPriv().
17#include "msg/keyboardkeymsg.h"
18#endif
19
28class WorldLogic : public MsgSink {
29public:
37
44 ~WorldLogic() override;
45
56 bool DispatchPriv(Message *pMsg) override;
57
59 virtual void Start() = 0;
60
62 virtual void Stop() = 0;
63
69 virtual bool IsFinished() const = 0;
70
76 virtual int HasQuit() const = 0;
77
85 virtual int IsRestartRequested() const = 0;
86
93 virtual bool IsFreestyling(int nPlayer) = 0;
94
100 virtual int GetTick() = 0;
101
107 virtual float GetTime() = 0;
108
110 virtual void Poll() = 0;
111
117 virtual float GetProgress() = 0;
118
124 virtual void HandleInput(const RotateEvent &event) = 0;
125
131 virtual void HandleInput(const PlayNoteEvent &event) = 0;
132
138 virtual void HandleInput(const BtnEvent<3> &event) = 0;
139
145 virtual void HandleInput(const BtnEvent<4> &event) = 0;
146
152 virtual void HandleInput(const BtnEvent<5> &event) = 0;
153
159 virtual void HandleInput(const ChangeSectionEvent &event) = 0;
160
166 virtual void HandleInput(const BtnEvent<9> &event) = 0;
167
173 virtual void HandleInput(const BtnEvent<10> &event) = 0;
174
180 virtual void HandleInput(const BtnEvent<8> &event) = 0;
181
187 virtual void HandleInput(const StickEvent<2> &event) = 0;
188
194 virtual void HandleInput(const StickEvent<6> &event) = 0;
195
207 virtual void SetPaused(bool bPaused, int nPad, int nReason);
208
214 virtual bool IsPlaying() const = 0;
215
223
234
245
257
258#ifdef VIDEO_STANDARD_PAL
266 int OnKeyboardKey(KeyboardKeyMsg *pMsg);
267
268private:
270 Ptr<Command> mCommand{nullptr};
271#endif
272};
Input event of a button press that names only the player.
Definition btnevent.h:15
Input event that changes the section a player is on.
Definition changesectionevent.h:10
Message the controller poll sends when a controller is connected or disconnected.
Definition joypadconnectionmsg.h:23
Message the keyboard poll sends when a key of a USB keyboard is pressed.
Definition keyboardkeymsg.h:23
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:40
Receiver of engine messages.
Definition msgsink.h:21
Input event that plays a note on one of the three gem buttons.
Definition playnoteevent.h:10
Owner of one reference to an Attachment.
Definition ptr.h:16
Input event that rotates a player's view of the tracks by one track.
Definition rotateevent.h:11
Input event of an analog stick position.
Definition stickevent.h:15
virtual void HandleInput(const ChangeSectionEvent &event)=0
Act on a section change.
virtual void SetPaused(bool bPaused, int nPad, int nReason)
Pause or resume the song.
virtual void HandleInput(const BtnEvent< 8 > &event)=0
Act on a button event.
virtual void HandleInput(const BtnEvent< 3 > &event)=0
Act on a button event.
virtual float GetProgress()=0
Report how much of the song has been played.
virtual void Start()=0
Start the song.
virtual void HandleInput(const PlayNoteEvent &event)=0
Act on a played note.
void AllNotesOff()
Silence every synthesiser channel.
int OnJoypadConnection(JoypadConnectionMsg *pMsg)
Pause the playing song when the controller of a player is disconnected.
virtual bool IsPlaying() const =0
Report whether the song is playing.
WorldLogic()
Construct the logic and give the input of every controller to the world.
bool DispatchPriv(Message *pMsg) override
Pass a JoypadConnectionMsg to OnJoypadConnection() and ignore any other message.
virtual int HasQuit() const =0
Report whether a player quit the song.
virtual float GetTime()=0
Report the song time.
virtual void HandleInput(const StickEvent< 6 > &event)=0
Act on a stick event.
virtual bool IsFreestyling(int nPlayer)=0
Report whether a player plays the freestyle track.
virtual void Poll()=0
Advance the logic once per frame.
virtual void HandleInput(const BtnEvent< 9 > &event)=0
Act on a button event.
virtual int IsRestartRequested() const =0
Report whether the song is to start again once it ends.
virtual void HandleInput(const BtnEvent< 10 > &event)=0
Act on a button event.
virtual void Stop()=0
Stop the song.
virtual void HandleInput(const BtnEvent< 5 > &event)=0
Act on a button event.
virtual void HandleInput(const BtnEvent< 4 > &event)=0
Act on a button event.
virtual void HandleInput(const StickEvent< 2 > &event)=0
Act on a stick event.
virtual int GetTick()=0
Report the song position.
virtual void HandleInput(const RotateEvent &event)=0
Act on a rotation.
static int FindDisconnectedPad()
Find the controller of a player on this console that is disconnected.
~WorldLogic() override
Release the logic.
void ScheduleControllerCheck()
Pause the song again one tick from now when a controller is disconnected.
virtual bool IsFinished() const =0
Report whether the song is over.