summaryrefslogtreecommitdiffstats
path: root/src/view
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/view
parenteb40e3de7226d0005ce0a41c67c9355e675a489b (diff)
downloadrpgedit-d82f3b7665435abefe84c8dbc16483acd235b478.tar
rpgedit-d82f3b7665435abefe84c8dbc16483acd235b478.zip
Move external entity state from Entity to Map
Diffstat (limited to 'src/view')
-rw-r--r--src/view/MapView.cpp10
-rw-r--r--src/view/MapView.hpp2
2 files changed, 6 insertions, 6 deletions
diff --git a/src/view/MapView.cpp b/src/view/MapView.cpp
index dbce5e4..4a6e552 100644
--- a/src/view/MapView.cpp
+++ b/src/view/MapView.cpp
@@ -76,11 +76,11 @@ MapView::~MapView() {
clearEntities();
}
-void MapView::updateEntities(const std::deque<Model::Entity> &entities) {
+void MapView::updateEntities(const std::vector<std::unique_ptr<Model::Entity>> &entities) {
SpriteCache *spriteCache = window->getSpriteCache();
for (auto &entity : entities) {
- const std::string &name = entity.getName();
+ const std::string &name = entity->getName();
if (!entitySprites[name])
entitySprites[name] = SDL_CreateTextureFromSurface(window->getRenderer(), spriteCache->get("entity", name));
@@ -137,8 +137,8 @@ void MapView::render(const Model::Map *map, Model::Position center, uint64_t tim
}
for (auto &entity : map->getEntities()) {
- Model::Position pos = entity.getPosition(time);
- Model::Direction dir = entity.getDirection();
+ Model::Position pos = map->getEntityPosition(entity.get(), time);
+ Model::Direction dir = entity->getDirection();
SDL_Rect src = {
.x = getTileSize()*dir,
@@ -154,7 +154,7 @@ void MapView::render(const Model::Map *map, Model::Position center, uint64_t tim
.h = tilePixels,
};
- SDL_RenderCopy(window->getRenderer(), entitySprites[entity.getName()], &src, &dst);
+ SDL_RenderCopy(window->getRenderer(), entitySprites[entity->getName()], &src, &dst);
}
}
diff --git a/src/view/MapView.hpp b/src/view/MapView.hpp
index f101c24..e813950 100644
--- a/src/view/MapView.hpp
+++ b/src/view/MapView.hpp
@@ -53,7 +53,7 @@ public:
MapView(const std::shared_ptr<Window> &window0, const std::vector<std::string> &tileset);
~MapView();
- void updateEntities(const std::deque<Model::Entity> &entities);
+ void updateEntities(const std::vector<std::unique_ptr<Model::Entity>> &entities);
void clearEntities();
void clear();