]> git.localhorst.tv Git - l2e.git/blob - src/map/Entity.h
added entity follower list
[l2e.git] / src / map / Entity.h
1 /*
2  * Entity.h
3  *
4  *  Created on: Sep 29, 2012
5  *      Author: holy
6  */
7
8 #ifndef MAP_ENTITY_H_
9 #define MAP_ENTITY_H_
10
11 #include "../geometry/Vector.h"
12 #include "../graphics/fwd.h"
13 #include "../graphics/Animation.h"
14
15 #include <functional>
16 #include <SDL.h>
17
18 namespace map {
19
20 class Entity {
21
22 public:
23         Entity();
24         ~Entity() { }
25
26 public:
27         enum Orientation {
28                 ORIENTATION_NORTH = 0,
29                 ORIENTATION_EAST = 1,
30                 ORIENTATION_SOUTH = 2,
31                 ORIENTATION_WEST = 3,
32         };
33
34 public:
35         geometry::Vector<float> &Position() { return position; }
36         const geometry::Vector<float> &Position() const { return position; }
37
38         geometry::Vector<float> &Velocity() { return velocity; }
39         const geometry::Vector<float> &Velocity() const { return velocity; }
40
41         void SetAnimation(const graphics::Animation *a);
42         void StartAnimation(app::Application &ctrl);
43         void StartAnimation(app::State &ctrl);
44         void StopAnimation();
45         bool AnimationRunning() const { return runner.Running(); }
46
47         void SetOrientation(Orientation);
48         Orientation GetOrientation() const { return orientation; }
49         void SetSpeed(float);
50
51         Entity *Follower() { return follower; }
52         const Entity *Follower() const { return follower; }
53         void AddFollower(Entity *);
54         void RemoveFollower(Entity *);
55
56         bool TileLock(int width, int height) const;
57
58         void Update(float deltaT);
59
60         void Render(SDL_Surface *, const geometry::Vector<int> &offset) const;
61
62 private:
63         void UpdateVelocity();;
64
65 private:
66         Entity *follower;
67         const graphics::Animation *animation;
68         graphics::AnimationRunner runner;
69         geometry::Vector<float> position;
70         geometry::Vector<float> velocity;
71         Orientation orientation;
72         float speed;
73
74 };
75
76 }
77
78 #endif /* MAP_ENTITY_H_ */