]> git.localhorst.tv Git - l2e.git/blob - src/map/MapState.h
added temporary map transition implementation
[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         void Transition(Map *, const geometry::Vector<int> &coordinates);
46
47 private:
48         static bool ZCompare(const Entity *lhs, const Entity *rhs);
49
50         bool CheckBlocking() const;
51
52         void OnTileLock();
53         void OnGridLock();
54         void OnMove(bool);
55
56         void UpdateFollower(Entity &);
57         void StopFollowers(Entity &);
58
59         void LockEntities();
60         void CheckMonster();
61         void CheckTrigger();
62
63 private:
64         Map *map;
65         Entity *controlled;
66         app::Timer<float> moveTimer;
67         geometry::Vector<float> tempTarget;
68         geometry::Vector<int> lastLock;
69         graphics::Camera camera;
70         std::vector<Entity *> entities;
71         float walkingSpeed;
72         int nextDirection;
73         bool afterLock;
74         bool skipLock;
75         bool debug;
76
77 };
78
79 }
80
81 #endif /* MAP_MAPSTATE_H_ */