Merge branch 'master' of https://github.com/Anuken/Mindustry into 7.0-features

 Conflicts:
	core/src/mindustry/entities/comp/FlyingComp.java
This commit is contained in:
Anuken
2021-08-22 15:53:33 -04:00
11 changed files with 41 additions and 18 deletions

View File

@@ -53,7 +53,7 @@ public class FormationAI extends AIController implements FormationMember{
Vec2 realtarget = vec.set(target).add(leader.vel);
float speed = unit.realSpeed() * Time.delta;
float speed = unit.speed() * Time.delta;
unit.approach(Mathf.arrive(unit.x, unit.y, realtarget.x, realtarget.y, unit.vel, speed, 0f, speed, 1f).scl(1f / Time.delta));
if(unit.canMine() && leader.canMine()){

View File

@@ -121,7 +121,7 @@ public class LogicAI extends AIController{
float length = circleLength <= 0.001f ? 1f : Mathf.clamp((unit.dst(target) - circleLength) / smooth, -1f, 1f);
vec.setLength(unit.realSpeed() * length);
vec.setLength(unit.speed() * length);
if(length < -0.5f){
vec.rotate(180f);
}else if(length < 0){

View File

@@ -647,7 +647,7 @@ public class NetServer implements ApplicationListener{
Unit unit = player.unit();
long elapsed = Math.min(Time.timeSinceMillis(con.lastReceivedClientTime), 1500);
float maxSpeed = unit.realSpeed();
float maxSpeed = unit.speed();
float maxMove = elapsed / 1000f * 60f * maxSpeed * 1.2f;

View File

@@ -48,6 +48,10 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
return canDrown() ? floorOn() : null;
}
boolean emitWalkSound(){
return true;
}
void landed(){
}
@@ -59,7 +63,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
void moveAt(Vec2 vector, float acceleration){
Vec2 t = tmp1.set(vector); //target vector
tmp2.set(t).sub(vel).limit(acceleration * vector.len() * Time.delta * floorSpeedMultiplier()); //delta vector
tmp2.set(t).sub(vel).limit(acceleration * vector.len() * Time.delta); //delta vector
vel.add(tmp2);
}
@@ -87,7 +91,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
floor.walkEffect.at(x, y, hitSize() / 8f, floor.mapColor);
splashTimer = 0f;
if(!(this instanceof WaterMovec)){
if(emitWalkSound()){
floor.walkSound.at(x, y, Mathf.random(floor.walkSoundPitchMin, floor.walkSoundPitchMax), floor.walkSoundVolume);
}
}

View File

@@ -104,15 +104,18 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
return type.hasWeapons();
}
/** @return speed with boost & floor multipliers factored in. */
public float speed(){
float strafePenalty = isGrounded() || !isPlayer() ? 1f : Mathf.lerp(1f, type.strafePenalty, Angles.angleDist(vel().angle(), rotation) / 180f);
float boost = Mathf.lerp(1f, type.canBoost ? type.boostMultiplier : 1f, elevation);
//limit speed to minimum formation speed to preserve formation
return (isCommanding() ? minFormationSpeed * 0.98f : type.speed) * strafePenalty;
return (isCommanding() ? minFormationSpeed * 0.98f : type.speed) * strafePenalty * boost * floorSpeedMultiplier();
}
/** @return speed with boost multipliers factored in. */
/** @deprecated use speed() instead */
@Deprecated
public float realSpeed(){
return Mathf.lerp(1f, type.canBoost ? type.boostMultiplier : 1f, elevation) * speed() * floorSpeedMultiplier();
return speed();
}
/** Iterates through this unit and everything it is controlling. */

View File

@@ -44,6 +44,13 @@ abstract class WaterMoveComp implements Posc, Velc, Hitboxc, Flyingc, Unitc{
return Pathfinder.costNaval;
}
//don't want obnoxious splashing
@Override
@Replace
public boolean emitWalkSound(){
return false;
}
@Override
public void add(){
tleft.clear();

View File

@@ -238,7 +238,7 @@ public class AIController implements UnitController{
float length = circleLength <= 0.001f ? 1f : Mathf.clamp((unit.dst(target) - circleLength) / smooth, -1f, 1f);
vec.setLength(unit.realSpeed() * length);
vec.setLength(unit.speed() * length);
if(length < -0.5f){
vec.rotate(180f);
}else if(length < 0){

View File

@@ -623,7 +623,7 @@ public class DesktopInput extends InputHandler{
protected void updateMovement(Unit unit){
boolean omni = unit.type.omniMovement;
float speed = unit.realSpeed();
float speed = unit.speed();
float xa = Core.input.axis(Binding.move_x);
float ya = Core.input.axis(Binding.move_y);
boolean boosted = (unit instanceof Mechc && unit.isFlying());

View File

@@ -872,7 +872,7 @@ public class MobileInput extends InputHandler implements GestureListener{
targetPos.set(Core.camera.position);
float attractDst = 15f;
float speed = unit.realSpeed();
float speed = unit.speed();
float range = unit.hasWeapons() ? unit.range() : 0f;
float bulletSpeed = unit.hasWeapons() ? type.weapons.first().bullet.speed : 0f;
float mouseAngle = unit.angleTo(unit.aimX(), unit.aimY());

View File

@@ -487,13 +487,22 @@ public class LExecutor{
case itemDrop -> {
if(ai.itemTimer > 0) return;
Building build = exec.building(p1);
int dropped = Math.min(unit.stack.amount, exec.numi(p2));
if(build != null && build.team == unit.team && build.isValid() && dropped > 0 && unit.within(build, logicItemTransferRange + build.block.size * tilesize/2f)){
int accepted = build.acceptStack(unit.item(), dropped, unit);
if(accepted > 0){
Call.transferItemTo(unit, unit.item(), accepted, unit.x, unit.y, build);
ai.itemTimer = LogicAI.transferDelay;
//clear item when dropping to @air
if(exec.obj(p1) == Blocks.air){
//only server-side; no need to call anything, as items are synced in snapshots
if(!net.client()){
unit.clearItem();
}
ai.itemTimer = LogicAI.transferDelay;
}else{
Building build = exec.building(p1);
int dropped = Math.min(unit.stack.amount, exec.numi(p2));
if(build != null && build.team == unit.team && build.isValid() && dropped > 0 && unit.within(build, logicItemTransferRange + build.block.size * tilesize/2f)){
int accepted = build.acceptStack(unit.item(), dropped, unit);
if(accepted > 0){
Call.transferItemTo(unit, unit.item(), accepted, unit.x, unit.y, build);
ai.itemTimer = LogicAI.transferDelay;
}
}
}
}