Terminus
synccommand.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 
6 
7 namespace terminus
8 {
9 
10 class Train;
11 
21 {
22 public:
23  SyncCommand(Timer::TimerMSec timeStamp, const Train & playerTrain);
24  SyncCommand(Timer::TimerMSec timeStamp, QJsonObject jsonObject);
25 
26  virtual QJsonObject toJson() const override;
27  virtual void doWork() override;
28 
29  virtual Commands commandType() const override { return Commands::Command_Sync; }
30 
31  const std::vector<float> & wagonHealthVector() const { return m_wagonHealthVector; }
32 protected:
33  std::vector<float> m_wagonHealthVector;
34  float m_velocity;
36 };
37 
38 } // namespace terminus
The SyncCommand is used to keep shared game state synchronized.
Definition: synccommand.h:20
virtual void doWork() override
Every Commands must define its effects on the receiving game.
Definition: synccommand.cpp:61
const std::vector< float > & wagonHealthVector() const
Definition: synccommand.h:31
Definition: commands.h:15
float m_velocity
Definition: synccommand.h:34
Commands
The Commands enum stores all command types with corresponding ID.
Definition: commands.h:9
signed int TimerMSec
Definition: timer.h:22
std::vector< float > m_wagonHealthVector
Definition: synccommand.h:33
virtual Commands commandType() const override
Every Command must specify its type.
Definition: synccommand.h:29
Definition: eventhandler.cpp:18
virtual QJsonObject toJson() const override
Every command must define how its members can be serialized.
Definition: synccommand.cpp:43
Timer::TimerMSec timeStamp() const
get the time as counted by the sending game that this command was created and sent ...
Definition: abstractcommand.cpp:54
float m_travelledDistance
Definition: synccommand.h:35
SyncCommand(Timer::TimerMSec timeStamp, const Train &playerTrain)
Definition: synccommand.cpp:15
The AbstractCommand class defines the interface that every command has to implement.
Definition: abstractcommand.h:23
The Train class works as a logical container for all wagons one train consists of.
Definition: train.h:25