]> git.localhorst.tv Git - l2e.git/blob - src/map/MapState.h
a6d292b78d757b4b694e587ca29716f2e79333fd
[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 "../common/fwd.h"
15 #include "../geometry/Vector.h"
16 #include "../graphics/Camera.h"
17
18 #include <vector>
19
20 namespace map {
21
22 class MapState
23 : public app::State {
24
25 public:
26         explicit MapState(common::GameConfig *, Map *);
27         virtual ~MapState() { }
28
29 public:
30         virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
31         virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
32         virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
33         virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
34         virtual void Resize(int width, int height);
35
36         virtual void HandleEvents(const app::Input &);
37         virtual void UpdateWorld(float deltaT);
38         virtual void Render(SDL_Surface *);
39
40 public:
41         void AddEntity(Entity *e) { entities.push_back(e); }
42         void ControlEntity(Entity *e) { controlled = e; camera.SetTarget(&e->Position()); }
43
44         void SetWalkingSpeed(float s) { walkingSpeed = s; }
45
46         void Transition(Map *, const geometry::Vector<int> &coordinates);
47
48 private:
49         static bool ZCompare(const Entity *lhs, const Entity *rhs);
50
51         void UnloadMap();
52         void LoadMap(Map *);
53
54         bool CheckBlocking() const;
55
56         void OnTileLock();
57         bool OnGridLock();
58         void OnMove(bool);
59
60         void UpdateFollower(Entity &);
61         void StopFollowers(Entity &);
62
63         void LockEntities();
64         bool CheckMonster();
65         bool CheckTrigger();
66
67 private:
68         common::GameConfig *game;
69         app::Application *ctrl;
70         Map *map;
71         Entity *controlled;
72         app::Timer<float> moveTimer;
73         geometry::Vector<float> tempTarget;
74         geometry::Vector<int> lastLock;
75         graphics::Camera camera;
76         std::vector<Entity *> entities;
77         float walkingSpeed;
78         int nextDirection;
79         bool afterLock;
80         bool skipLock;
81         bool debug;
82
83 };
84
85 }
86
87 #endif /* MAP_MAPSTATE_H_ */