diff options
Diffstat (limited to 'src/systems')
-rw-r--r-- | src/systems/pondering.cpp | 50 |
1 files changed, 29 insertions, 21 deletions
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( | |||
91 | auto& ponderable = game_.getEntityManager(). | 91 | auto& ponderable = game_.getEntityManager(). |
92 | getComponent<PonderableComponent>(entity); | 92 | getComponent<PonderableComponent>(entity); |
93 | 93 | ||
94 | if (!ponderable.active || ponderable.frozen) | 94 | if (!ponderable.active) |
95 | { | 95 | { |
96 | continue; | 96 | return; |
97 | } | 97 | } |
98 | 98 | ||
99 | auto& realizable = game_.getEntityManager(). | 99 | auto& realizable = game_.getEntityManager(). |
@@ -109,13 +109,16 @@ void PonderingSystem::tickBody( | |||
109 | getComponent<TransformableComponent>(entity); | 109 | getComponent<TransformableComponent>(entity); |
110 | 110 | ||
111 | // Accelerate | 111 | // Accelerate |
112 | ponderable.velX += ponderable.accelX * dt; | 112 | if (!ponderable.frozen) |
113 | ponderable.velY += ponderable.accelY * dt; | ||
114 | |||
115 | if ((ponderable.type == PonderableComponent::Type::freefalling) | ||
116 | && (ponderable.velY > TERMINAL_VELOCITY)) | ||
117 | { | 113 | { |
118 | ponderable.velY = TERMINAL_VELOCITY; | 114 | ponderable.velX += ponderable.accelX * dt; |
115 | ponderable.velY += ponderable.accelY * dt; | ||
116 | |||
117 | if ((ponderable.type == PonderableComponent::Type::freefalling) | ||
118 | && (ponderable.velY > TERMINAL_VELOCITY)) | ||
119 | { | ||
120 | ponderable.velY = TERMINAL_VELOCITY; | ||
121 | } | ||
119 | } | 122 | } |
120 | 123 | ||
121 | const double oldX = transformable.x; | 124 | const double oldX = transformable.x; |
@@ -124,21 +127,23 @@ void PonderingSystem::tickBody( | |||
124 | const double oldBottom = oldY + transformable.h; | 127 | const double oldBottom = oldY + transformable.h; |
125 | 128 | ||
126 | CollisionResult result; | 129 | CollisionResult result; |
130 | result.newX = transformable.x; | ||
131 | result.newY = transformable.y; | ||
127 | 132 | ||
128 | if (ponderable.ferried) | 133 | if (!ponderable.frozen) |
129 | { | 134 | { |
130 | auto& ferryTrans = game_.getEntityManager(). | 135 | if (ponderable.ferried) |
131 | getComponent<TransformableComponent>(ponderable.ferry); | 136 | { |
137 | auto& ferryTrans = game_.getEntityManager(). | ||
138 | getComponent<TransformableComponent>(ponderable.ferry); | ||
132 | 139 | ||
133 | result.newX = ferryTrans.x + ponderable.relX; | 140 | result.newX = ferryTrans.x + ponderable.relX; |
134 | result.newY = ferryTrans.y + ponderable.relY; | 141 | result.newY = ferryTrans.y + ponderable.relY; |
135 | } else { | 142 | } |
136 | result.newX = transformable.x; | ||
137 | result.newY = transformable.y; | ||
138 | } | ||
139 | 143 | ||
140 | result.newX += ponderable.velX * dt; | 144 | result.newX += ponderable.velX * dt; |
141 | result.newY += ponderable.velY * dt; | 145 | result.newY += ponderable.velY * dt; |
146 | } | ||
142 | 147 | ||
143 | bool oldGrounded = ponderable.grounded; | 148 | bool oldGrounded = ponderable.grounded; |
144 | ponderable.grounded = false; | 149 | ponderable.grounded = false; |
@@ -694,8 +699,11 @@ void PonderingSystem::tickBody( | |||
694 | } | 699 | } |
695 | 700 | ||
696 | // Move | 701 | // Move |
697 | transformable.x = result.newX; | 702 | if (!ponderable.frozen) |
698 | transformable.y = result.newY; | 703 | { |
704 | transformable.x = result.newX; | ||
705 | transformable.y = result.newY; | ||
706 | } | ||
699 | 707 | ||
700 | // Perform cleanup for orientable entites | 708 | // Perform cleanup for orientable entites |
701 | if (game_.getEntityManager().hasComponent<OrientableComponent>(entity)) | 709 | if (game_.getEntityManager().hasComponent<OrientableComponent>(entity)) |