]> git.localhorst.tv Git - l2e.git/blob - src/map/MapState.h
bf19f4d5d315b0e8750d0e544588a336083f59cd
[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();
55         bool CheckBlocking(const geometry::Vector<int> &position, Entity::Orientation direction) const;
56
57         void OnTileLock();
58         bool OnGridLock();
59         void OnMove(bool);
60
61         void UpdateFollower(Entity &);
62         void StopFollowers(Entity &);
63
64         void LockEntities();
65         bool CheckMonster();
66
67         bool CheckLockTrigger();
68         bool CheckMoveTrigger();
69         void RunTrigger(Trigger &);
70
71 private:
72         common::GameConfig *game;
73         app::Application *ctrl;
74         Map *map;
75         Entity *controlled;
76         Entity *pushed;
77         app::Timer<float> moveTimer;
78         geometry::Vector<int> lastLock;
79         graphics::Camera camera;
80         std::vector<Entity *> entities;
81         float walkingSpeed;
82         int nextDirection;
83         bool afterLock;
84         bool skipLock;
85         bool pushing;
86         bool debug;
87
88 };
89
90 }
91
92 #endif /* MAP_MAPSTATE_H_ */