From 7ec50fb800d3ef9d67ac5308a201f0886a2610b7 Mon Sep 17 00:00:00 2001 From: DeltaNedas Date: Sat, 7 Nov 2020 11:59:37 +0000 Subject: [PATCH] type.speed -> speed() --- core/src/mindustry/ai/types/BuilderAI.java | 2 +- core/src/mindustry/ai/types/FlyingAI.java | 2 +- core/src/mindustry/ai/types/SuicideAI.java | 2 +- core/src/mindustry/core/NetServer.java | 2 +- core/src/mindustry/entities/comp/UnitComp.java | 7 ++++++- core/src/mindustry/entities/units/AIController.java | 4 ++-- core/src/mindustry/input/DesktopInput.java | 7 ------- core/src/mindustry/input/MobileInput.java | 10 +--------- 8 files changed, 13 insertions(+), 23 deletions(-) diff --git a/core/src/mindustry/ai/types/BuilderAI.java b/core/src/mindustry/ai/types/BuilderAI.java index c3558ca58a..abaffecd40 100644 --- a/core/src/mindustry/ai/types/BuilderAI.java +++ b/core/src/mindustry/ai/types/BuilderAI.java @@ -79,7 +79,7 @@ public class BuilderAI extends AIController{ float dist = Math.min(cons.dst(unit) - buildingRange, 0); //make sure you can reach the request in time - if(dist / unit.type.speed < cons.buildCost * 0.9f){ + if(dist / unit.speed() < cons.buildCost * 0.9f){ following = b; found = true; } diff --git a/core/src/mindustry/ai/types/FlyingAI.java b/core/src/mindustry/ai/types/FlyingAI.java index 7262ae216a..bf7367731d 100644 --- a/core/src/mindustry/ai/types/FlyingAI.java +++ b/core/src/mindustry/ai/types/FlyingAI.java @@ -55,7 +55,7 @@ public class FlyingAI extends AIController{ vec.setAngle(Mathf.slerpDelta(unit.vel().angle(), vec.angle(), 0.6f)); } - vec.setLength(unit.type.speed); + vec.setLength(unit.speed()); unit.moveAt(vec); } diff --git a/core/src/mindustry/ai/types/SuicideAI.java b/core/src/mindustry/ai/types/SuicideAI.java index 0ef3ece228..1bda2c4b81 100644 --- a/core/src/mindustry/ai/types/SuicideAI.java +++ b/core/src/mindustry/ai/types/SuicideAI.java @@ -65,7 +65,7 @@ public class SuicideAI extends GroundAI{ if(!blocked){ moveToTarget = true; //move towards target directly - unit.moveAt(vec.set(target).sub(unit).limit(unit.type.speed)); + unit.moveAt(vec.set(target).sub(unit).limit(unit.speed())); } } diff --git a/core/src/mindustry/core/NetServer.java b/core/src/mindustry/core/NetServer.java index 00f0bc78e8..c6709d2259 100644 --- a/core/src/mindustry/core/NetServer.java +++ b/core/src/mindustry/core/NetServer.java @@ -640,7 +640,7 @@ public class NetServer implements ApplicationListener{ Unit unit = player.unit(); long elapsed = Time.timeSinceMillis(con.lastReceivedClientTime); - float maxSpeed = ((player.unit().type.canBoost && player.unit().isFlying()) ? player.unit().type.boostMultiplier : 1f) * player.unit().type.speed; + float maxSpeed = ((player.unit().type.canBoost && player.unit().isFlying()) ? player.unit().type.boostMultiplier : 1f) * player.unit().speed(); if(unit.isGrounded()){ maxSpeed *= unit.floorSpeedMultiplier(); } diff --git a/core/src/mindustry/entities/comp/UnitComp.java b/core/src/mindustry/entities/comp/UnitComp.java index 3cba913fbb..8e0298c584 100644 --- a/core/src/mindustry/entities/comp/UnitComp.java +++ b/core/src/mindustry/entities/comp/UnitComp.java @@ -67,9 +67,14 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I return type.hasWeapons(); } + public float speed(){ + //limit speed to minimum formation speed to preserve formation + return isCommanding() ? minFormationSpeed * 0.98f : type.speed; + } + /** @return speed with boost multipliers factored in. */ public float realSpeed(){ - return Mathf.lerp(1f, type.canBoost ? type.boostMultiplier : 1f, elevation) * type.speed; + return Mathf.lerp(1f, type.canBoost ? type.boostMultiplier : 1f, elevation) * speed(); } /** Iterates through this unit and everything it is controlling. */ diff --git a/core/src/mindustry/entities/units/AIController.java b/core/src/mindustry/entities/units/AIController.java index 5df9db4a60..a861c81060 100644 --- a/core/src/mindustry/entities/units/AIController.java +++ b/core/src/mindustry/entities/units/AIController.java @@ -95,7 +95,7 @@ public class AIController implements UnitController{ if(tile == targetTile || (costType == Pathfinder.costWater && !targetTile.floor().isLiquid)) return; - unit.moveAt(vec.trns(unit.angleTo(targetTile), unit.type.speed)); + unit.moveAt(vec.trns(unit.angleTo(targetTile), unit.speed())); } protected void updateWeapons(){ @@ -176,7 +176,7 @@ public class AIController implements UnitController{ } protected void circle(Position target, float circleLength){ - circle(target, circleLength, unit.type.speed); + circle(target, circleLength, unit.speed()); } protected void circle(Position target, float circleLength, float speed){ diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index b6a424f866..45dbfb6bea 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -604,13 +604,6 @@ public class DesktopInput extends InputHandler{ boolean ground = unit.isGrounded(); float strafePenalty = ground ? 1f : Mathf.lerp(1f, unit.type.strafePenalty, Angles.angleDist(unit.vel().angle(), unit.rotation()) / 180f); - float baseSpeed = unit.type.speed; - - //limit speed to minimum formation speed to preserve formation - if(unit.isCommanding()){ - //add a tiny multiplier to let units catch up just in case - baseSpeed = unit.minFormationSpeed * 0.95f; - } float speed = unit.realSpeed() * strafePenalty; float xa = Core.input.axis(Binding.move_x); diff --git a/core/src/mindustry/input/MobileInput.java b/core/src/mindustry/input/MobileInput.java index 87f0eaf851..3e1aadd2f7 100644 --- a/core/src/mindustry/input/MobileInput.java +++ b/core/src/mindustry/input/MobileInput.java @@ -857,14 +857,6 @@ public class MobileInput extends InputHandler implements GestureListener{ float attractDst = 15f; float strafePenalty = legs ? 1f : Mathf.lerp(1f, type.strafePenalty, Angles.angleDist(unit.vel.angle(), unit.rotation) / 180f); - float baseSpeed = unit.type.speed; - - //limit speed to minimum formation speed to preserve formation - if(unit.isCommanding()){ - //add a tiny multiplier to let units catch up just in case - baseSpeed = unit.minFormationSpeed * 0.98f; - } - float speed = unit.realSpeed() * strafePenalty; float range = unit.hasWeapons() ? unit.range() : 0f; float bulletSpeed = unit.hasWeapons() ? type.weapons.first().bullet.speed : 0f; @@ -906,7 +898,7 @@ public class MobileInput extends InputHandler implements GestureListener{ if(player.within(targetPos, attractDst)){ movement.setZero(); - unit.vel.approachDelta(Vec2.ZERO, type.speed * type.accel / 2f); + unit.vel.approachDelta(Vec2.ZERO, unit.speed() * type.accel / 2f); } float expansion = 3f;