From 83534176373bd05a13db88ffff095f52cca07a21 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Fri, 4 May 2018 11:08:48 -0400 Subject: Fixed behavior of frozen bodies Frozen bodies are now still ticked, but their velocities and positions are no longer changed. This change was made so that frozen bodies can still be ungrounded/unferried, and that passengers of frozen bodies can still be ticked. Also fixes a compile error. --- src/systems/pondering.cpp | 50 +++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'src/systems') diff --git a/src/systems/pondering.cpp b/src/systems/pondering.cpp index e6417eb..0be3add 100644 --- a/src/systems/pondering.cpp +++ b/src/systems/pondering.cpp @@ -91,9 +91,9 @@ void PonderingSystem::tickBody( auto& ponderable = game_.getEntityManager(). getComponent(entity); - if (!ponderable.active || ponderable.frozen) + if (!ponderable.active) { - continue; + return; } auto& realizable = game_.getEntityManager(). @@ -109,13 +109,16 @@ void PonderingSystem::tickBody( getComponent(entity); // Accelerate - ponderable.velX += ponderable.accelX * dt; - ponderable.velY += ponderable.accelY * dt; - - if ((ponderable.type == PonderableComponent::Type::freefalling) - && (ponderable.velY > TERMINAL_VELOCITY)) + if (!ponderable.frozen) { - ponderable.velY = TERMINAL_VELOCITY; + ponderable.velX += ponderable.accelX * dt; + ponderable.velY += ponderable.accelY * dt; + + if ((ponderable.type == PonderableComponent::Type::freefalling) + && (ponderable.velY > TERMINAL_VELOCITY)) + { + ponderable.velY = TERMINAL_VELOCITY; + } } const double oldX = transformable.x; @@ -124,21 +127,23 @@ void PonderingSystem::tickBody( const double oldBottom = oldY + transformable.h; CollisionResult result; + result.newX = transformable.x; + result.newY = transformable.y; - if (ponderable.ferried) + if (!ponderable.frozen) { - auto& ferryTrans = game_.getEntityManager(). - getComponent(ponderable.ferry); + if (ponderable.ferried) + { + auto& ferryTrans = game_.getEntityManager(). + getComponent(ponderable.ferry); - result.newX = ferryTrans.x + ponderable.relX; - result.newY = ferryTrans.y + ponderable.relY; - } else { - result.newX = transformable.x; - result.newY = transformable.y; - } + result.newX = ferryTrans.x + ponderable.relX; + result.newY = ferryTrans.y + ponderable.relY; + } - result.newX += ponderable.velX * dt; - result.newY += ponderable.velY * dt; + result.newX += ponderable.velX * dt; + result.newY += ponderable.velY * dt; + } bool oldGrounded = ponderable.grounded; ponderable.grounded = false; @@ -694,8 +699,11 @@ void PonderingSystem::tickBody( } // Move - transformable.x = result.newX; - transformable.y = result.newY; + if (!ponderable.frozen) + { + transformable.x = result.newX; + transformable.y = result.newY; + } // Perform cleanup for orientable entites if (game_.getEntityManager().hasComponent(entity)) -- cgit 1.4.1