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 "../geometry/Vector.h"
11 #include "../graphics/Camera.h"
17 /// Shows a map and its entities an optionally control a single entity.
20 , public common::ScriptHost {
23 explicit MapState(common::GameConfig *, Map *);
24 virtual ~MapState() { }
27 virtual void HandleEvents(const app::Input &);
28 virtual void UpdateWorld(float deltaT);
29 virtual void Render(SDL_Surface *);
32 void AddEntity(Entity *e) { entities.push_back(e); }
33 void ControlEntity(Entity *e) { controlled = e; camera.SetTarget(&e->Position()); }
35 void SetWalkingSpeed(float s) { walkingSpeed = s; }
37 void Transition(Map *, const geometry::Vector<int> &coordinates);
39 virtual void HandleSyscall(common::ScriptRunner &);
42 virtual void OnEnterState(SDL_Surface *screen);
43 virtual void OnExitState(SDL_Surface *screen);
44 virtual void OnResumeState(SDL_Surface *screen);
45 virtual void OnPauseState(SDL_Surface *screen);
47 virtual void OnResize(int width, int height);
50 static bool ZCompare(const Entity *lhs, const Entity *rhs);
56 bool CheckBlocking(const geometry::Vector<int> &position, Entity::Orientation direction) const;
62 void UpdateFollower(Entity &);
63 void StopFollowers(Entity &);
68 bool CheckLockTrigger();
69 bool CheckMoveTrigger();
70 void RunTrigger(Trigger &);
78 common::GameConfig *game;
82 common::ScriptRunner runner;
83 app::Timer<float> moveTimer;
84 geometry::Vector<int> lastLock;
85 graphics::Camera camera;
86 std::vector<Entity *> entities;
98 #endif /* MAP_MAPSTATE_H_ */