X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmap%2FMapState.cpp;h=8c5ef6bcf1c53ec612c3ba86d043b003127563b8;hb=d8d0982340fc10e5161251a4b50223fabc7b4431;hp=350a1f48f8be2813585fef2fbc8233b5f4f06000;hpb=42e75a9b9341a7c0446e29431a08980eca7de8c1;p=l2e.git diff --git a/src/map/MapState.cpp b/src/map/MapState.cpp index 350a1f4..8c5ef6b 100644 --- a/src/map/MapState.cpp +++ b/src/map/MapState.cpp @@ -9,6 +9,7 @@ #include "Map.h" #include "Tile.h" +#include "Trigger.h" #include "../app/Application.h" #include "../app/Input.h" @@ -28,6 +29,7 @@ MapState::MapState(Map *map) , walkingSpeed(64) , nextDirection(-1) , afterLock(false) +, skipLock(false) , debug(false) { } @@ -183,9 +185,13 @@ bool MapState::CheckBlocking() const { } void MapState::OnGridLock() { - LockEntities(); - CheckMonster(); - CheckTrigger(); + if (skipLock) { + skipLock = false; + } else { + LockEntities(); + CheckMonster(); + CheckTrigger(); + } } void MapState::LockEntities() { @@ -223,7 +229,10 @@ void MapState::CheckMonster() { void MapState::CheckTrigger() { Trigger *trigger(map->TriggerAt(Vector(controlled->Position()))); if (trigger) { - // TODO: run trigger + // TODO: run trigger script + if (trigger->map) { + Transition(trigger->map, trigger->target); + } } } @@ -277,6 +286,19 @@ void MapState::StopFollowers(Entity &e) { } +void MapState::Transition(Map *newMap, const Vector &coordinates) { + Vector position(coordinates * map->Tileset()->Size()); + entities.clear(); + for (Entity *e(controlled); e; e = e->Follower()) { + e->Position() = position; + e->SetOrientation(controlled->GetOrientation()); + entities.push_back(e); + } + map = newMap; + skipLock = true; +} + + void MapState::Render(SDL_Surface *screen) { SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));