From d82f3b7665435abefe84c8dbc16483acd235b478 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 25 Sep 2014 20:53:17 +0200 Subject: Move external entity state from Entity to Map --- src/control/MapContext.cpp | 8 +++----- src/control/MapContext.hpp | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src/control') 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(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: -- cgit v1.2.3