summaryrefslogtreecommitdiffstats
path: root/src/control
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/control
parenteb40e3de7226d0005ce0a41c67c9355e675a489b (diff)
downloadrpgedit-d82f3b7665435abefe84c8dbc16483acd235b478.tar
rpgedit-d82f3b7665435abefe84c8dbc16483acd235b478.zip
Move external entity state from Entity to Map
Diffstat (limited to 'src/control')
-rw-r--r--src/control/MapContext.cpp8
-rw-r--r--src/control/MapContext.hpp2
2 files changed, 4 insertions, 6 deletions
diff --git a/src/control/MapContext.cpp b/src/control/MapContext.cpp
index acad969..8900298 100644
--- a/src/control/MapContext.cpp
+++ b/src/control/MapContext.cpp
@@ -35,9 +35,7 @@ MapContext::MapContext(EventBus *eventBus0, InputHandler *inputHandler0, const s
: eventBus(eventBus0), inputHandler(inputHandler0), map(map0) {
view = std::unique_ptr<View::MapView>(new View::MapView(window, map.getTileset()));
- map.getEntities().emplace_back("square");
- playerEntity = &map.getEntities().back();
- playerEntity->moveTo(&map, Model::Position{8, 8});
+ playerEntity = map.addEntity("square", Model::Position{8, 8});
view->updateEntities(map.getEntities());
@@ -50,12 +48,12 @@ MapContext::MapContext(EventBus *eventBus0, InputHandler *inputHandler0, const s
}
void MapContext::movePlayer(Model::Direction dir, uint64_t time) {
- if (!playerEntity->move(&map, dir, time, time+250))
+ if (!map.moveEntity(playerEntity, dir, time, time+250))
return;
eventBus->enqueue(
[=] {
- playerEntity->finishTransition(&map);
+ map.finishEntityTransition(playerEntity);
movePlayerContinue(time+250);
},
time+250
diff --git a/src/control/MapContext.hpp b/src/control/MapContext.hpp
index a60bdfc..d9c34f3 100644
--- a/src/control/MapContext.hpp
+++ b/src/control/MapContext.hpp
@@ -54,7 +54,7 @@ private:
void keyPressed(uint16_t key, uint64_t time);
Model::Position getViewPosition(uint64_t time) {
- return playerEntity->getPosition(time);
+ return map.getEntityPosition(playerEntity, time);
}
public: