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"
26 , public common::ScriptHost {
29 explicit MapState(common::GameConfig *, Map *);
30 virtual ~MapState() { }
33 virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
34 virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
35 virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
36 virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
37 virtual void Resize(int width, int height);
39 virtual void HandleEvents(const app::Input &);
40 virtual void UpdateWorld(float deltaT);
41 virtual void Render(SDL_Surface *);
44 void AddEntity(Entity *e) { entities.push_back(e); }
45 void ControlEntity(Entity *e) { controlled = e; camera.SetTarget(&e->Position()); }
47 void SetWalkingSpeed(float s) { walkingSpeed = s; }
49 void Transition(Map *, const geometry::Vector<int> &coordinates);
51 virtual void HandleSyscall(common::ScriptRunner &);
54 static bool ZCompare(const Entity *lhs, const Entity *rhs);
60 bool CheckBlocking(const geometry::Vector<int> &position, Entity::Orientation direction) const;
66 void UpdateFollower(Entity &);
67 void StopFollowers(Entity &);
72 bool CheckLockTrigger();
73 bool CheckMoveTrigger();
74 void RunTrigger(Trigger &);
82 common::GameConfig *game;
83 app::Application *ctrl;
87 common::ScriptRunner runner;
88 app::Timer<float> moveTimer;
89 geometry::Vector<int> lastLock;
90 graphics::Camera camera;
91 std::vector<Entity *> entities;
103 #endif /* MAP_MAPSTATE_H_ */