]> git.localhorst.tv Git - l2e.git/blob - src/map/MapState.h
added debug mode for maps
[l2e.git] / src / map / MapState.h
1 /*
2  * MapState.h
3  *
4  *  Created on: Sep 29, 2012
5  *      Author: holy
6  */
7
8 #ifndef MAP_MAPSTATE_H_
9 #define MAP_MAPSTATE_H_
10
11 #include "Entity.h"
12 #include "fwd.h"
13 #include "../app/State.h"
14 #include "../geometry/Vector.h"
15 #include "../graphics/Camera.h"
16
17 #include <vector>
18
19 namespace map {
20
21 class MapState
22 : public app::State {
23
24 public:
25         explicit MapState(Map *);
26         virtual ~MapState() { }
27
28 public:
29         virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
30         virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
31         virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
32         virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
33         virtual void Resize(int width, int height);
34
35         virtual void HandleEvents(const app::Input &);
36         virtual void UpdateWorld(float deltaT);
37         virtual void Render(SDL_Surface *);
38
39 public:
40         void AddEntity(Entity *e) { entities.push_back(e); }
41         void ControlEntity(Entity *e) { controlled = e; camera.SetTarget(&e->Position()); }
42
43         void SetWalkingSpeed(float s) { walkingSpeed = s; }
44
45 private:
46         static bool ZCompare(const Entity *lhs, const Entity *rhs);
47
48         bool CheckBlocking() const;
49
50         void OnTileLock();
51         void OnGridLock();
52         void OnMove(bool);
53
54         void UpdateFollower(Entity &);
55         void StopFollowers(Entity &);
56
57         void LockEntities();
58         void CheckMonster();
59         void CheckTrigger();
60
61 private:
62         Map *map;
63         Entity *controlled;
64         app::Timer<float> moveTimer;
65         geometry::Vector<float> tempTarget;
66         geometry::Vector<int> lastLock;
67         graphics::Camera camera;
68         std::vector<Entity *> entities;
69         float walkingSpeed;
70         int nextDirection;
71         bool afterLock;
72         bool debug;
73
74 };
75
76 }
77
78 #endif /* MAP_MAPSTATE_H_ */