X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmap%2FMapState.cpp;h=2ae4bb362082c00a62fb3c0a6f70404cd7d56a92;hb=242bdb40a032306ad2bf57487e7f23a0c308fe44;hp=51e99869f618588b2bb09b3b76dfdde1b9cbc687;hpb=5d1a76ae7725af998c6ee46adfe492c68ee1d34f;p=l2e.git diff --git a/src/map/MapState.cpp b/src/map/MapState.cpp index 51e9986..2ae4bb3 100644 --- a/src/map/MapState.cpp +++ b/src/map/MapState.cpp @@ -118,17 +118,19 @@ void MapState::OnTileLock() { return; } + const Tile *tile(map->TileAt(nowLock)); + if (nextDirection >= 0) { if (afterLock) { bool blocked(CheckBlocking()); OnMove(!blocked); - controlled->SetOrientation(Entity::Orientation(nextDirection)); + controlled->SetDirection(Entity::Orientation(nextDirection)); if (!blocked) { afterLock = false; controlled->SetSpeed(walkingSpeed); moveTimer.Clear(); if (pushed) { - pushed->SetOrientation(Entity::Orientation(nextDirection)); + pushed->SetDirection(Entity::Orientation(nextDirection)); pushed->SetSpeed(walkingSpeed); controlled->SetPushing(); } else { @@ -138,8 +140,10 @@ void MapState::OnTileLock() { controlled->SetSpeed(0); StopFollowers(*controlled); if (!moveTimer.Running()) { - int tileSize((controlled->GetOrientation() % 2) ? map->Tileset()->Width() : map->Tileset()->Height()); - moveTimer = PhysicsTimers().StartInterval(tileSize/walkingSpeed.Int()); + int tileSize((controlled->GetDirection() % 2) ? map->Tileset()->Width() : map->Tileset()->Height()); + Fixed<8> walkingInterval(tileSize); + walkingInterval /= walkingSpeed; + moveTimer = PhysicsTimers().StartInterval(walkingInterval.Int()); } pushed = 0; } @@ -158,6 +162,11 @@ void MapState::OnTileLock() { } } + if (controlled->GetDirection() == Entity::ORIENTATION_SOUTH + && tile && tile->IsLadder()) { + controlled->SetOrientation(Entity::ORIENTATION_NORTH); + } + lastLock = nowLock; } @@ -363,19 +372,19 @@ void MapState::UpdateFollower(Entity &e) { Vector direction(coords - fCoords); if (direction.Y() < 0) { - f.SetOrientation(Entity::ORIENTATION_NORTH); + f.SetDirection(Entity::ORIENTATION_NORTH); f.SetSpeed(walkingSpeed); f.StartAnimation(*this); } else if (direction.X() > 0) { - f.SetOrientation(Entity::ORIENTATION_EAST); + f.SetDirection(Entity::ORIENTATION_EAST); f.SetSpeed(walkingSpeed); f.StartAnimation(*this); } else if (direction.Y() > 0) { - f.SetOrientation(Entity::ORIENTATION_SOUTH); + f.SetDirection(Entity::ORIENTATION_SOUTH); f.SetSpeed(walkingSpeed); f.StartAnimation(*this); } else if (direction.X() < 0) { - f.SetOrientation(Entity::ORIENTATION_WEST); + f.SetDirection(Entity::ORIENTATION_WEST); f.SetSpeed(walkingSpeed); f.StartAnimation(*this); } else { @@ -397,7 +406,7 @@ void MapState::Transition(Map *newMap, const Vector &coordinates) { Vector position(coordinates * map->Tileset()->Size()); for (Entity *e(controlled); e; e = e->Follower()) { e->Position() = position; - e->SetOrientation(controlled->GetOrientation()); + e->SetDirection(controlled->GetDirection()); } LoadMap(newMap); skipLock = true;