4 * Created on: Sep 29, 2012
8 #ifndef MAP_MAPSTATE_H_
9 #define MAP_MAPSTATE_H_
13 #include "../app/State.h"
14 #include "../common/fwd.h"
15 #include "../common/ScriptHost.h"
16 #include "../common/ScriptRunner.h"
17 #include "../geometry/Vector.h"
18 #include "../graphics/Camera.h"
24 /// Shows a map and its entities an optionally control a single entity.
27 , public common::ScriptHost {
30 explicit MapState(common::GameConfig *, Map *);
31 virtual ~MapState() { }
34 virtual void HandleEvents(const app::Input &);
35 virtual void UpdateWorld(float deltaT);
36 virtual void Render(SDL_Surface *);
39 void AddEntity(Entity *e) { entities.push_back(e); }
40 void ControlEntity(Entity *e) { controlled = e; camera.SetTarget(&e->Position()); }
42 void SetWalkingSpeed(float s) { walkingSpeed = s; }
44 void Transition(Map *, const geometry::Vector<int> &coordinates);
46 virtual void HandleSyscall(common::ScriptRunner &);
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);
54 virtual void OnResize(int width, int height);
57 static bool ZCompare(const Entity *lhs, const Entity *rhs);
63 bool CheckBlocking(const geometry::Vector<int> &position, Entity::Orientation direction) const;
69 void UpdateFollower(Entity &);
70 void StopFollowers(Entity &);
75 bool CheckLockTrigger();
76 bool CheckMoveTrigger();
77 void RunTrigger(Trigger &);
85 common::GameConfig *game;
89 common::ScriptRunner runner;
90 app::Timer<float> moveTimer;
91 geometry::Vector<int> lastLock;
92 graphics::Camera camera;
93 std::vector<Entity *> entities;
105 #endif /* MAP_MAPSTATE_H_ */