diff --git a/core/src/io/anuke/mindustry/input/MobileInput.java b/core/src/io/anuke/mindustry/input/MobileInput.java index ab33b78716..53146adda4 100644 --- a/core/src/io/anuke/mindustry/input/MobileInput.java +++ b/core/src/io/anuke/mindustry/input/MobileInput.java @@ -452,7 +452,6 @@ public class MobileInput extends InputHandler implements GestureListener{ } //endregion - //region input events @Override @@ -591,6 +590,7 @@ public class MobileInput extends InputHandler implements GestureListener{ @Override public void update(){ + clampCamera(); if(state.is(State.menu) || player.isDead()){ selection.clear(); removals.clear(); @@ -730,6 +730,20 @@ public class MobileInput extends InputHandler implements GestureListener{ return true; } + void clampCamera(){ + if(player.isDead()) return; + + Vector2 v = Core.camera.position; + + v.x = clerp(v.x, player.x - Core.camera.width/2f, player.x + Core.camera.width/2f); + v.y = clerp(v.y, player.y - Core.camera.height/2f, player.y + Core.camera.height/2f); + } + + float clerp(float value, float min, float max){ + final float alpha = 0.07f; + return value < min ? Mathf.lerpDelta(value, min, alpha) : value > max ? Mathf.lerpDelta(value, max, alpha) : value; + } + //endregion private class PlaceRequest{ 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 d4564e5eae..a5b181bd4f 100644 --- a/core/src/io/anuke/mindustry/world/blocks/units/MechPad.java +++ b/core/src/io/anuke/mindustry/world/blocks/units/MechPad.java @@ -31,7 +31,7 @@ import static io.anuke.mindustry.Vars.tilesize; public class MechPad extends Block{ protected Mech mech; protected float buildTime = 60 * 5; - protected float requiredSatisfaction = 1f; + protected float requiredSatisfaction = 0.999f; protected TextureRegion openRegion; @@ -125,7 +125,7 @@ public class MechPad extends Block{ if(checkValidTap(tile, player)){ Call.onMechFactoryTap(player, tile); - }else if(player.isLocal && mobile && !player.isDead() && entity.cons.valid() && entity.player == null){ + }else if(player.isLocal && mobile && !player.isDead() && (entity.power.satisfaction >= requiredSatisfaction) && entity.player == null){ player.moveTarget = tile.entity; } }