X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmap%2FMapState.cpp;h=62e480267ca092f31a178f2ffe2274f8792fc229;hb=d7befe3a14be8f01d6d7288a6970358a4749368d;hp=98e9b2848b5a947f2643d1257ade0a17375ee732;hpb=5519942fa584ee30a0fde3752adff030c3dc42b8;p=l2e.git diff --git a/src/map/MapState.cpp b/src/map/MapState.cpp index 98e9b28..62e4802 100644 --- a/src/map/MapState.cpp +++ b/src/map/MapState.cpp @@ -179,12 +179,8 @@ bool MapState::CheckBlocking() const { void MapState::OnGridLock() { LockEntities(); - Trigger *trigger(map->TriggerAt(Vector(controlled->Position()))); - if (trigger) { - // TODO: run trigger - } - // TODO: check for adjacent monsters - // TODO: force all entities into their grid positions? + CheckMonster(); + CheckTrigger(); } void MapState::LockEntities() { @@ -197,6 +193,31 @@ void MapState::LockEntities() { } } +void MapState::CheckMonster() { + Vector coords(map->TileCoordinates(controlled->Position())); + Vector neighbor[4]; + neighbor[0] = Vector(coords.X() - 1, coords.Y()); // W + neighbor[1] = Vector(coords.X(), coords.Y() + 1); // S + neighbor[2] = Vector(coords.X() + 1, coords.Y()); // E + neighbor[3] = Vector(coords.X(), coords.Y() - 1); // N + + for (int i(0); i < 4; ++i) { + for (std::vector::iterator e(entities.begin()), end(entities.end()); e != end; ++e) { + if ((*e)->Hostile() && map->TileCoordinates((*e)->Position()) == neighbor[i]) { + // remove entity, push battle state and transition and halt all other activity + } + } + } +} + +void MapState::CheckTrigger() { + Trigger *trigger(map->TriggerAt(Vector(controlled->Position()))); + if (trigger) { + // TODO: run trigger + } + +} + void MapState::OnMove(bool realMove) { // TODO: evaluate monster movements if (realMove) {