forked from Dzejrou/tdt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMovementSystem.hpp
77 lines (68 loc) · 2.19 KB
/
MovementSystem.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#pragma once
#include <Ogre.h>
#include <stdexcept>
#include <limits>
#include <cstdlib>
#include "System.hpp"
#include "EntitySystem.hpp"
#include "Components.hpp"
#include "PhysicsHelper.hpp"
#include "GraphicsHelper.hpp"
#include "MovementHelper.hpp"
/**
* System handling movement related updates and containing movement & physics related methods.
*/
class MovementSystem : public System
{
public:
/**
* Constructor.
* Param: Reference to the game's entity system.
*/
MovementSystem(EntitySystem&);
/**
* Destructor.
*/
~MovementSystem() {}
/**
* Brief: Updates the movement system.
* Param: Time since the last frame.
*/
void update(Ogre::Real);
/**
* Brief: Returns true if a given entity can move to a given point in space, false otherwise.
* Param: ID of the entity.
* Param: Target coordinate.
*/
bool can_move_to(std::size_t, Ogre::Vector3);
/**
* Brief: Sets a given entity to move in a given direction, returns true if such movement is possible and
* false otherwise. The move will then be applied in the update method.
* Param: ID of the entity.
* Param: Directional vector.
* Note: Every vector passed to this method should be normalised and the length of the move will be
* increased by the entity's speed modifier. This is not enforced though.
* Note: Checks for collisions.
*/
bool checked_move(std::size_t, Ogre::Vector3);
/**
* Brief: Sets a given entity to move in a given direction, returns true if such movement is possible and
* false otherwise. The move will then be applied in the update method.
* Param: ID of the entity.
* Param: Directional vector.
* Note: Every vector passed to this method should be normalised and the length of the move will be
* increased by the entity's speed modifier. This is not enforced though.
* Note: Does not check for collisions.
*/
bool move(std::size_t, Ogre::Vector3);
private:
/**
* Reference to the game's entity system.
*/
EntitySystem& entities_;
/**
* Time between the last frame and this frame, used so that lua calls to the move functions
* still use the time of this frame.
*/
Ogre::Real last_delta_;
};