4 * Created on: Sep 29, 2012
11 #include "../battle/fwd.h"
12 #include "../battle/Monster.h"
13 #include "../geometry/Vector.h"
14 #include "../graphics/fwd.h"
15 #include "../graphics/Animation.h"
30 ORIENTATION_NORTH = 0,
32 ORIENTATION_SOUTH = 2,
36 FLAG_NONBLOCKING = 0x01,
38 FLAG_FIXED_ORIENTATION = 0x04,
42 geometry::Vector<float> &Position() { return position; }
43 const geometry::Vector<float> &Position() const { return position; }
45 geometry::Vector<float> &Velocity() { return velocity; }
46 const geometry::Vector<float> &Velocity() const { return velocity; }
48 geometry::Vector<int> &SpriteOffset() { return spriteOffset; }
49 const geometry::Vector<int> &SpriteOffset() const { return spriteOffset; }
51 void ResetPosition(const geometry::Vector<int> &tileSize) { position = tilePosition * tileSize; }
53 void SetAnimation(const graphics::Animation *a);
54 void StartAnimation(app::Application &ctrl);
55 void StartAnimation(app::State &ctrl);
57 bool AnimationRunning() const { return runner.Running(); }
59 void SetSprite(const graphics::Sprite *s) { sprite = s; }
61 void SetOrientation(Orientation);
62 Orientation GetOrientation() const { return orientation; }
69 void SetFlags(int f) { flags = f; }
70 bool Blocking() const { return !(flags & FLAG_NONBLOCKING); }
71 bool Hostile() const { return partyLayout && numMonsters > 0; }
72 bool Pushable() const { return flags & FLAG_PUSHABLE; }
73 bool CanTurn() const { return !(flags & FLAG_FIXED_ORIENTATION); }
75 void SetPartyLayout(battle::PartyLayout *l) { partyLayout = l; }
76 battle::PartyLayout *PartyLayout() { return partyLayout; }
78 void SetMonsters(battle::Monster *m, int num) { monsters = m; numMonsters = num; }
79 battle::Monster *MonstersBegin() { return monsters; }
80 battle::Monster *MonstersEnd() { return monsters + numMonsters; }
82 Entity *Follower() { return follower; }
83 const Entity *Follower() const { return follower; }
84 void AddFollower(Entity *);
85 void RemoveFollower(Entity *);
87 bool TileLock(const geometry::Vector<int> &tileSize) const;
89 void Update(float deltaT);
91 void Render(SDL_Surface *, const geometry::Vector<int> &offset) const;
93 static void CreateTypeDescription();
94 static void Construct(void *);
95 static void Load(void *);
98 void UpdateVelocity();
102 const graphics::Animation *animation;
103 const graphics::Sprite *sprite;
104 battle::PartyLayout *partyLayout;
105 battle::Monster *monsters;
107 graphics::AnimationRunner runner;
108 geometry::Vector<int> spriteOffset;
109 geometry::Vector<int> tilePosition;
110 geometry::Vector<float> position;
111 geometry::Vector<float> velocity;
112 Orientation orientation;
120 #endif /* MAP_ENTITY_H_ */