Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
AttackAction.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <optional>
4 
5 #include "../world/Coordinates.hpp"
6 #include "Action.hpp"
7 #include "MoveAction.hpp"
8 
12 class AttackAction : public Action
13 {
14 public:
15  AttackAction(std::chrono::system_clock::time_point startTime, std::shared_ptr<Entity> pTarget, std::shared_ptr<Entity> pEntity);
16 
17  ~AttackAction() = default;
18 
24  std::shared_ptr<Entity>& getTarget();
25 
30  void act();
31 
37  CurrentAction getActionInfo();
38 
39 private:
45  std::vector<std::pair<int, int>> findPathToTarget();
46 
47  std::shared_ptr<Entity> pTargetM;
48 
49  std::chrono::milliseconds actionTimeM;
50 
51  std::chrono::milliseconds moveTimeM;
52 
53  ActionType actionTypeM = ActionType::Attack;
54 
55  std::vector<std::pair<int, int>> pathToTargetM;
56  std::optional<Coordinates> nextMoveM;
57  bool targetInRangeM = false;
58 };
Represents an action that an entity can perform.
Definition: Action.hpp:15
Action used for attacks.
Definition: AttackAction.hpp:13
bool targetInRangeM
True if the target is in range.
Definition: AttackAction.hpp:57
ActionType actionTypeM
Definition: AttackAction.hpp:53
std::optional< Coordinates > nextMoveM
The next move to be taken, is defined if the target is not in range.
Definition: AttackAction.hpp:56
std::vector< std::pair< int, int > > pathToTargetM
Path to the target.
Definition: AttackAction.hpp:55
~AttackAction()=default
std::shared_ptr< Entity > pTargetM
Definition: AttackAction.hpp:47
std::shared_ptr< Entity > & getTarget()
Get the target Entity of the action.
Definition: AttackAction.cpp:11
AttackAction(std::chrono::system_clock::time_point startTime, std::shared_ptr< Entity > pTarget, std::shared_ptr< Entity > pEntity)
Definition: AttackAction.cpp:7
std::chrono::milliseconds moveTimeM
Definition: AttackAction.hpp:51
std::chrono::milliseconds actionTimeM
Definition: AttackAction.hpp:49
std::vector< std::pair< int, int > > findPathToTarget()
Finds a path to the target.
Definition: AttackAction.cpp:75
void act()
Attack functionality, which performs attacks against target and moves closer to the target if not in ...
Definition: AttackAction.cpp:16
CurrentAction getActionInfo()
Returns information about the current action.
Definition: AttackAction.cpp:84