MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / getVelocity

Method getVelocity

game/state/battle/battleunit.cpp:266–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264}
265
266Vec3<float> BattleUnit::getVelocity() const
267{
268 Vec3<float> targetVelocity = velocity;
269 // If moving instead use movement speed
270 if (!atGoal && isMoving())
271 {
272 // Normalized Vector towards target position
273 targetVelocity = goalPosition - position;
274 if (targetVelocity.x != 0.0f || targetVelocity.y != 0.0f || targetVelocity.z != 0.0f)
275 {
276 targetVelocity = glm::normalize(targetVelocity);
277 // Account for unit speed and movement state
278 float speedMult = agent->modified_stats.getMovementSpeed();
279 if (current_movement_state == MovementState::Running)
280 {
281 speedMult *= 2.0f;
282 }
283 else if (current_body_state == BodyState::Prone)
284 {
285 speedMult *= 0.666f;
286 }
287 targetVelocity *= speedMult;
288 targetVelocity *= (float)TICK_SCALE / (float)TICKS_PER_UNIT_TRAVELLED_BATTLEUNIT;
289 }
290 }
291 return targetVelocity;
292}
293
294void BattleUnit::refreshUnitVisibility(GameState &state)
295{

Callers 2

updateFiringMethod · 0.80
useBrainsuckerMethod · 0.80

Calls 1

getMovementSpeedMethod · 0.80

Tested by

no test coverage detected