type.speed -> speed()

This commit is contained in:
DeltaNedas 2020-11-07 11:59:37 +00:00
parent 29b8db0a85
commit 7ec50fb800
8 changed files with 13 additions and 23 deletions

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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()));
}
}

View file

@ -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();
}

View file

@ -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. */

View file

@ -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){

View file

@ -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);

View file

@ -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;