summaryrefslogtreecommitdiffstats
path: root/src/model/Entity.hpp
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-09-25 20:53:17 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-09-25 20:53:17 +0200
commitd82f3b7665435abefe84c8dbc16483acd235b478 (patch)
tree473689f592085a076e45d1cade590ad207cc4840 /src/model/Entity.hpp
parenteb40e3de7226d0005ce0a41c67c9355e675a489b (diff)
downloadrpgedit-d82f3b7665435abefe84c8dbc16483acd235b478.tar
rpgedit-d82f3b7665435abefe84c8dbc16483acd235b478.zip
Move external entity state from Entity to Map
Diffstat (limited to 'src/model/Entity.hpp')
-rw-r--r--src/model/Entity.hpp51
1 files changed, 3 insertions, 48 deletions
diff --git a/src/model/Entity.hpp b/src/model/Entity.hpp
index 170f23a..eab6983 100644
--- a/src/model/Entity.hpp
+++ b/src/model/Entity.hpp
@@ -39,41 +39,12 @@ namespace RPGEdit {
namespace Model {
-class Map;
-
class Entity {
private:
- const std::string name;
+ std::string name;
- Position pos;
Direction direction;
- uint64_t transitionStart = 0;
- uint64_t transitionEnd = 0;
-
- Position translate(Direction dir, float amount) const {
- Position p = pos;
-
- switch (dir) {
- case NORTH:
- p.y -= amount;
- break;
-
- case EAST:
- p.x += amount;
- break;
-
- case SOUTH:
- p.y += amount;
- break;
-
- case WEST:
- p.x -= amount;
- }
-
- return p;
- }
-
public:
Entity(const std::string &name0)
: name(name0), direction(NORTH) {
@@ -83,29 +54,13 @@ public:
return name;
}
- Position getPosition(uint64_t time) const {
- if (hasTransition())
- if (time <= transitionStart)
- return pos;
- else if (time >= transitionEnd)
- return translate(direction, 1);
- else
- return translate(direction, float(time-transitionStart)/float(transitionEnd-transitionStart));
- else
- return pos;
- }
-
Direction getDirection() const {
return direction;
}
- bool hasTransition() const {
- return transitionEnd;
+ void setDirection(Direction dir) {
+ direction = dir;
}
-
- void moveTo(Map *map, Position newPos);
- bool move(Map *map, Direction dir, uint64_t start, uint64_t end);
- void finishTransition(Map *map);
};
}