Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
Action.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <chrono>
4 #include <ctime>
5 #include <memory>
6 
7 #include "network.h"
8 
9 class Entity;
10 
14 class Action
15 {
16 public:
17  Action(std::chrono::system_clock::time_point startTime, std::shared_ptr<Entity> pEntity);
18 
19  ~Action() = default;
20 
26  std::chrono::system_clock::time_point getStartTime();
27 
33  std::chrono::milliseconds getActionTime();
34 
40  ActionType getActionType();
41 
47  virtual CurrentAction getActionInfo();
48 
54  bool isCompleted();
55 
60  virtual void act() = 0;
61 
62 protected:
63  std::chrono::system_clock::time_point startTimeM;
64 
65  std::chrono::milliseconds actionTimeM = std::chrono::milliseconds(0);
66 
67  ActionType actionTypeM = ActionType::None;
68 
69  std::shared_ptr<Entity> pEntityM;
70 
71  bool completedM = false;
72 };
Represents an action that an entity can perform.
Definition: Action.hpp:15
ActionType actionTypeM
Definition: Action.hpp:67
virtual CurrentAction getActionInfo()
Returns information about the current action. This is used to send information to the client.
Definition: Action.cpp:23
std::chrono::milliseconds actionTimeM
Definition: Action.hpp:65
std::chrono::system_clock::time_point startTimeM
Definition: Action.hpp:63
std::chrono::system_clock::time_point getStartTime()
Get the time when the action started.
Definition: Action.cpp:8
Action(std::chrono::system_clock::time_point startTime, std::shared_ptr< Entity > pEntity)
Definition: Action.cpp:6
ActionType getActionType()
Get the ActionType object.
Definition: Action.cpp:18
std::shared_ptr< Entity > pEntityM
Definition: Action.hpp:69
~Action()=default
bool completedM
Definition: Action.hpp:71
virtual void act()=0
Functionality for the action, pure virtual function that needs to be implemented by derived classes....
bool isCompleted()
Returns true if the action is completed.
Definition: Action.cpp:33
std::chrono::milliseconds getActionTime()
Get the time how long a single iteration of the action takes.
Definition: Action.cpp:13
Base pure virtual Entity class. Different types of enities inherit this.
Definition: Entity.hpp:17