From d9f829f10a8310f53d945cd96ecce28193b792d8 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 26 Sep 2014 01:42:49 +0200 Subject: Add support for interactions with entities --- src/model/Entity.hpp | 4 ++++ src/model/Map.hpp | 12 ++++++++++++ 2 files changed, 16 insertions(+) (limited to 'src/model') diff --git a/src/model/Entity.hpp b/src/model/Entity.hpp index 331cb4f..677eeb5 100644 --- a/src/model/Entity.hpp +++ b/src/model/Entity.hpp @@ -61,6 +61,10 @@ public: void setDirection(Direction dir) { direction = dir; } + + void interact(uint64_t time) { + std::fprintf(stderr, "Tried to interact with `%s' entity at %llu\n", name.c_str(), (unsigned long long)time); + } }; } diff --git a/src/model/Map.hpp b/src/model/Map.hpp index 0343709..acf93b1 100644 --- a/src/model/Map.hpp +++ b/src/model/Map.hpp @@ -223,6 +223,18 @@ public: return tiles[layer][p.y*width + p.x]; } + Entity * getEntityAt(const Position &p) { + auto it = positions.find(p); + if (it == positions.end()) + return nullptr; + + return *it->second.begin(); + } + + Position getEntityPosition(const Entity *entity) const { + return entityStates.at(entity).position; + } + Position getEntityPosition(const Entity *entity, uint64_t time) const; bool moveEntity(Entity *entity, Direction dir, uint64_t start, uint64_t end); void moveEntityTo(Entity *entity, Position pos); -- cgit v1.2.3