]> git.localhorst.tv Git - l2e.git/blob - src/map/MapState.h
removed useless comments
[l2e.git] / src / map / MapState.h
1 #ifndef MAP_MAPSTATE_H_
2 #define MAP_MAPSTATE_H_
3
4 namespace common {
5         struct GameConfig;
6 }
7 namespace map {
8         class Map;
9         class Trigger;
10 }
11
12 #include "Entity.h"
13 #include "../app/State.h"
14 #include "../common/ScriptHost.h"
15 #include "../common/ScriptRunner.h"
16 #include "../math/Fixed.h"
17 #include "../math/Vector.h"
18 #include "../graphics/Camera.h"
19
20 #include <vector>
21
22 namespace map {
23
24 /// Shows a map and its entities an optionally control a single entity.
25 class MapState
26 : public app::State
27 , public common::ScriptHost {
28
29 public:
30         explicit MapState(common::GameConfig *, Map *);
31         virtual ~MapState() { }
32
33 public:
34         virtual void HandleEvents(const app::Input &);
35         virtual void UpdateWorld(Uint32 deltaT);
36         virtual void Render(SDL_Surface *);
37
38 public:
39         void AddEntity(Entity *e) { entities.push_back(e); }
40         void ControlEntity(Entity *e) { controlled = e; camera.SetTarget(&e->Position()); }
41
42         void SetWalkingSpeed(math::Fixed<8> s) { walkingSpeed = s; }
43
44         void Transition(Map *, const math::Vector<int> &coordinates);
45
46         virtual void HandleSyscall(common::ScriptRunner &);
47
48 private:
49         virtual void OnEnterState(SDL_Surface *screen);
50         virtual void OnExitState(SDL_Surface *screen);
51         virtual void OnResumeState(SDL_Surface *screen);
52         virtual void OnPauseState(SDL_Surface *screen);
53
54         virtual void OnResize(int width, int height);
55
56 private:
57         static bool ZCompare(const Entity *lhs, const Entity *rhs);
58
59         void UnloadMap();
60         void LoadMap(Map *);
61
62         bool CheckBlocking();
63         bool CheckBlocking(const math::Vector<int> &position, Entity::Orientation direction) const;
64
65         void OnTileLock();
66         bool OnGridLock();
67         void OnMove(bool);
68
69         void UpdateFollower(Entity &);
70         void StopFollowers(Entity &);
71
72         void LockEntities();
73         bool CheckMonster();
74
75         bool CheckLockTrigger();
76         bool CheckMoveTrigger();
77         void RunTrigger(Trigger &);
78
79         enum Syscalls {
80                 TRANSITION = 1,
81                 WARP = 2,
82         };
83
84 private:
85         common::GameConfig *game;
86         Map *map;
87         Entity *controlled;
88         Entity *pushed;
89         common::ScriptRunner runner;
90         app::Timer<Uint32> moveTimer;
91         math::Vector<int> lastLock;
92         graphics::Camera camera;
93         std::vector<Entity *> entities;
94         math::Fixed<8> walkingSpeed;
95         int nextDirection;
96         bool afterLock;
97         bool skipLock;
98         bool pushing;
99         bool debug;
100
101 };
102
103 }
104
105 #endif