From 52cd4a77dd944d337d54724a8834f926ac8c3856 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 20 Apr 2019 14:14:34 -0400 Subject: [PATCH] MechPad deselect / Flyer patrol tweak --- .../src/io/anuke/mindustry/entities/type/FlyingUnit.java | 2 +- .../src/io/anuke/mindustry/entities/type/GroundUnit.java | 5 +++-- core/src/io/anuke/mindustry/entities/type/Unit.java | 4 ++-- .../io/anuke/mindustry/world/blocks/units/MechPad.java | 3 ++- net/src/io/anuke/mindustry/net/ArcNetServer.java | 9 +++++++-- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/core/src/io/anuke/mindustry/entities/type/FlyingUnit.java b/core/src/io/anuke/mindustry/entities/type/FlyingUnit.java index 854cd51c3d..dc92379241 100644 --- a/core/src/io/anuke/mindustry/entities/type/FlyingUnit.java +++ b/core/src/io/anuke/mindustry/entities/type/FlyingUnit.java @@ -84,7 +84,7 @@ public abstract class FlyingUnit extends BaseUnit{ }); if(target != null){ - circle(60f + Mathf.absin(Time.time() + id * 23525, 70f, 1200f)); + circle(60f + Mathf.absin(Time.time() + Mathf.randomSeed(id) * 1200f, 70f, 1200f)); } } }; diff --git a/core/src/io/anuke/mindustry/entities/type/GroundUnit.java b/core/src/io/anuke/mindustry/entities/type/GroundUnit.java index 062231d760..0239f9bdf2 100644 --- a/core/src/io/anuke/mindustry/entities/type/GroundUnit.java +++ b/core/src/io/anuke/mindustry/entities/type/GroundUnit.java @@ -76,8 +76,9 @@ public abstract class GroundUnit extends BaseUnit{ @Override public void move(float x, float y){ - if(Mathf.dst(x, y) > 0.01f){ - baseRotation = Mathf.slerpDelta(baseRotation, Mathf.angle(x, y), type.baseRotateSpeed); + float dst = Mathf.dst(x, y); + if(dst > 0.01f){ + baseRotation = Mathf.slerp(baseRotation, Mathf.angle(x, y), type.baseRotateSpeed * (dst / type.speed)); } super.move(x, y); } diff --git a/core/src/io/anuke/mindustry/entities/type/Unit.java b/core/src/io/anuke/mindustry/entities/type/Unit.java index 910f8299ab..a4866b7484 100644 --- a/core/src/io/anuke/mindustry/entities/type/Unit.java +++ b/core/src/io/anuke/mindustry/entities/type/Unit.java @@ -8,8 +8,7 @@ import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Geometry; import io.anuke.arc.math.geom.Vector2; -import io.anuke.arc.util.Time; -import io.anuke.arc.util.Tmp; +import io.anuke.arc.util.*; import io.anuke.mindustry.content.Blocks; import io.anuke.mindustry.content.Fx; import io.anuke.mindustry.entities.Damage; @@ -250,6 +249,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ final int rad = 2; + //TODO fix units getting trapped on tile corners moveVector.setZero(); for(int cx = -rad; cx <= rad; cx++){ for(int cy = -rad; cy <= rad; cy++){ diff --git a/core/src/io/anuke/mindustry/world/blocks/units/MechPad.java b/core/src/io/anuke/mindustry/world/blocks/units/MechPad.java index a5b181bd4f..d0ce1b3609 100644 --- a/core/src/io/anuke/mindustry/world/blocks/units/MechPad.java +++ b/core/src/io/anuke/mindustry/world/blocks/units/MechPad.java @@ -126,7 +126,8 @@ public class MechPad extends Block{ if(checkValidTap(tile, player)){ Call.onMechFactoryTap(player, tile); }else if(player.isLocal && mobile && !player.isDead() && (entity.power.satisfaction >= requiredSatisfaction) && entity.player == null){ - player.moveTarget = tile.entity; + //deselect on double taps + player.moveTarget = player.moveTarget == tile.entity ? null : tile.entity; } } diff --git a/net/src/io/anuke/mindustry/net/ArcNetServer.java b/net/src/io/anuke/mindustry/net/ArcNetServer.java index 5b4c3baad8..0110523061 100644 --- a/net/src/io/anuke/mindustry/net/ArcNetServer.java +++ b/net/src/io/anuke/mindustry/net/ArcNetServer.java @@ -77,8 +77,13 @@ public class ArcNetServer implements ServerProvider{ Core.app.post(() -> { try{ Net.handleServerReceived(k.id, object); - }catch(ValidateException e){ - Log.err("Validation failed: {0} ({1})", e.player.name, e.getMessage()); + }catch(RuntimeException e){ + if(e.getCause() instanceof ValidateException){ + ValidateException v = (ValidateException)e.getCause(); + Log.err("Validation failed: {0} ({1})", v.player.name, v.getMessage()); + }else{ + e.printStackTrace(); + } }catch(Exception e){ e.printStackTrace(); }