]> git.localhorst.tv Git - l2e.git/blob - src/map/MapState.h
c565632569a766552ee4c693d6b8f963eea23f15
[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         bool CheckTrigger();
67
68 private:
69         common::GameConfig *game;
70         app::Application *ctrl;
71         Map *map;
72         Entity *controlled;
73         Entity *pushed;
74         app::Timer<float> moveTimer;
75         geometry::Vector<float> tempTarget;
76         geometry::Vector<int> lastLock;
77         graphics::Camera camera;
78         std::vector<Entity *> entities;
79         float walkingSpeed;
80         int nextDirection;
81         bool afterLock;
82         bool skipLock;
83         bool pushing;
84         bool debug;
85
86 };
87
88 }
89
90 #endif /* MAP_MAPSTATE_H_ */