]> git.localhorst.tv Git - l2e.git/blobdiff - src/map/Entity.h
closed the gap between battle and map state (yay)
[l2e.git] / src / map / Entity.h
index fd91f3eeb5ce2114a578ba6b9ffdfb61da02a774..13ecacac627eb021ee9f35ede96db8b739e6ea8f 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef MAP_ENTITY_H_
 #define MAP_ENTITY_H_
 
+#include "../battle/fwd.h"
+#include "../battle/Monster.h"
 #include "../geometry/Vector.h"
 #include "../graphics/fwd.h"
 #include "../graphics/Animation.h"
@@ -23,6 +25,17 @@ public:
        Entity();
        ~Entity() { }
 
+public:
+       enum Orientation {
+               ORIENTATION_NORTH = 0,
+               ORIENTATION_EAST = 1,
+               ORIENTATION_SOUTH = 2,
+               ORIENTATION_WEST = 3,
+       };
+       enum Flags {
+               FLAG_NONBLOCKING = 0x01,
+       };
+
 public:
        geometry::Vector<float> &Position() { return position; }
        const geometry::Vector<float> &Position() const { return position; }
@@ -30,19 +43,61 @@ public:
        geometry::Vector<float> &Velocity() { return velocity; }
        const geometry::Vector<float> &Velocity() const { return velocity; }
 
-       void SetSprite(const graphics::Sprite *s) { sprite = s; }
-       graphics::AnimationRunner &Animation() { return animation; }
-       const graphics::AnimationRunner &Animation() const { return animation; }
+       geometry::Vector<int> &SpriteOffset() { return spriteOffset; }
+       const geometry::Vector<int> &SpriteOffset() const { return spriteOffset; }
+
+       void SetAnimation(const graphics::Animation *a);
+       void StartAnimation(app::Application &ctrl);
+       void StartAnimation(app::State &ctrl);
+       void StopAnimation();
+       bool AnimationRunning() const { return runner.Running(); }
+
+       void SetOrientation(Orientation);
+       Orientation GetOrientation() const { return orientation; }
+       void SetSpeed(float);
+
+       void SetFlags(int f) { flags = f; }
+       bool Blocking() const { return !(flags & FLAG_NONBLOCKING); }
+       bool Hostile() const { return partyLayout && numMonsters > 0; }
+
+       void SetPartyLayout(battle::PartyLayout *l) { partyLayout = l; }
+       battle::PartyLayout *PartyLayout() { return partyLayout; }
+
+       void SetMonsters(battle::Monster *m, int num) { monsters = m; numMonsters = num; }
+       battle::Monster *MonstersBegin() { return monsters; }
+       battle::Monster *MonstersEnd() { return monsters + numMonsters; }
+
+       Entity *Follower() { return follower; }
+       const Entity *Follower() const { return follower; }
+       void AddFollower(Entity *);
+       void RemoveFollower(Entity *);
+
+       bool TileLock(const geometry::Vector<int> &tileSize) const;
 
        void Update(float deltaT);
 
        void Render(SDL_Surface *, const geometry::Vector<int> &offset) const;
 
+       static void CreateTypeDescription();
+       static void Construct(void *);
+       static void Load(void *);
+
+private:
+       void UpdateVelocity();
+
 private:
-       const graphics::Sprite *sprite;
-       graphics::AnimationRunner animation;
+       Entity *follower;
+       const graphics::Animation *animation;
+       battle::PartyLayout *partyLayout;
+       battle::Monster *monsters;
+       int numMonsters;
+       graphics::AnimationRunner runner;
+       geometry::Vector<int> spriteOffset;
        geometry::Vector<float> position;
        geometry::Vector<float> velocity;
+       Orientation orientation;
+       float speed;
+       int flags;
 
 };