1 #ifndef MAP_MAPSTATE_H_
2 #define MAP_MAPSTATE_H_
6 #include "../app/State.h"
7 #include "../common/fwd.h"
8 #include "../common/ScriptHost.h"
9 #include "../common/ScriptRunner.h"
10 #include "../math/Fixed.h"
11 #include "../math/Vector.h"
12 #include "../graphics/Camera.h"
18 /// Shows a map and its entities an optionally control a single entity.
21 , public common::ScriptHost {
24 explicit MapState(common::GameConfig *, Map *);
25 virtual ~MapState() { }
28 virtual void HandleEvents(const app::Input &);
29 virtual void UpdateWorld(Uint32 deltaT);
30 virtual void Render(SDL_Surface *);
33 void AddEntity(Entity *e) { entities.push_back(e); }
34 void ControlEntity(Entity *e) { controlled = e; camera.SetTarget(&e->Position()); }
36 void SetWalkingSpeed(math::Fixed<8> s) { walkingSpeed = s; }
38 void Transition(Map *, const math::Vector<int> &coordinates);
40 virtual void HandleSyscall(common::ScriptRunner &);
43 virtual void OnEnterState(SDL_Surface *screen);
44 virtual void OnExitState(SDL_Surface *screen);
45 virtual void OnResumeState(SDL_Surface *screen);
46 virtual void OnPauseState(SDL_Surface *screen);
48 virtual void OnResize(int width, int height);
51 static bool ZCompare(const Entity *lhs, const Entity *rhs);
57 bool CheckBlocking(const math::Vector<int> &position, Entity::Orientation direction) const;
63 void UpdateFollower(Entity &);
64 void StopFollowers(Entity &);
69 bool CheckLockTrigger();
70 bool CheckMoveTrigger();
71 void RunTrigger(Trigger &);
79 common::GameConfig *game;
83 common::ScriptRunner runner;
84 app::Timer<Uint32> moveTimer;
85 math::Vector<int> lastLock;
86 graphics::Camera camera;
87 std::vector<Entity *> entities;
88 math::Fixed<8> walkingSpeed;
99 #endif /* MAP_MAPSTATE_H_ */