1 #ifndef MAP_MAPSTATE_H_
2 #define MAP_MAPSTATE_H_
13 #include "../app/State.h"
14 #include "../app/Timer.h"
15 #include "../common/ScriptHost.h"
16 #include "../common/ScriptRunner.h"
17 #include "../math/Fixed.h"
18 #include "../math/Vector.h"
19 #include "../graphics/Camera.h"
25 /// Shows a map and its entities an optionally control a single entity.
28 , public common::ScriptHost {
31 explicit MapState(common::GameConfig *, Map *);
32 virtual ~MapState() { }
35 virtual void HandleEvents(const app::Input &);
36 virtual void UpdateWorld(Uint32 deltaT);
37 virtual void Render(SDL_Surface *);
40 void AddEntity(Entity *e) { entities.push_back(e); }
41 void ControlEntity(Entity *e) { controlled = e; camera.SetTarget(&e->Position()); }
43 void SetWalkingSpeed(math::Fixed<8> s) { walkingSpeed = s; }
45 void Transition(Map *, const math::Vector<int> &coordinates);
47 virtual void HandleSyscall(common::ScriptRunner &);
50 virtual void OnEnterState(SDL_Surface *screen);
51 virtual void OnExitState(SDL_Surface *screen);
52 virtual void OnResumeState(SDL_Surface *screen);
53 virtual void OnPauseState(SDL_Surface *screen);
55 virtual void OnResize(int width, int height);
58 static bool ZCompare(const Entity *lhs, const Entity *rhs);
64 bool CheckBlocking(const math::Vector<int> &position, Entity::Orientation direction) const;
70 void UpdateFollower(Entity &);
71 void StopFollowers(Entity &);
75 void LoadBattle(Entity &hero, Entity &monster);
77 bool CheckLockTrigger();
78 bool CheckMoveTrigger();
79 void RunTrigger(Trigger &);
87 common::GameConfig *game;
91 common::ScriptRunner runner;
92 app::Timer<Uint32> moveTimer;
93 math::Vector<int> lastLock;
94 graphics::Camera camera;
95 std::vector<Entity *> entities;
96 math::Fixed<8> walkingSpeed;
97 app::Timer<Uint32> tileAnimation;