mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-12 03:37:27 +07:00
Added mobile camera clamping / Mech pad tap power validation
This commit is contained in:
parent
9d67c36c32
commit
8a1da3c0ed
@ -452,7 +452,6 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region input events
|
//region input events
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -591,6 +590,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
|
clampCamera();
|
||||||
if(state.is(State.menu) || player.isDead()){
|
if(state.is(State.menu) || player.isDead()){
|
||||||
selection.clear();
|
selection.clear();
|
||||||
removals.clear();
|
removals.clear();
|
||||||
@ -730,6 +730,20 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
return true;
|
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
|
//endregion
|
||||||
|
|
||||||
private class PlaceRequest{
|
private class PlaceRequest{
|
||||||
|
@ -31,7 +31,7 @@ import static io.anuke.mindustry.Vars.tilesize;
|
|||||||
public class MechPad extends Block{
|
public class MechPad extends Block{
|
||||||
protected Mech mech;
|
protected Mech mech;
|
||||||
protected float buildTime = 60 * 5;
|
protected float buildTime = 60 * 5;
|
||||||
protected float requiredSatisfaction = 1f;
|
protected float requiredSatisfaction = 0.999f;
|
||||||
|
|
||||||
protected TextureRegion openRegion;
|
protected TextureRegion openRegion;
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ public class MechPad extends Block{
|
|||||||
|
|
||||||
if(checkValidTap(tile, player)){
|
if(checkValidTap(tile, player)){
|
||||||
Call.onMechFactoryTap(player, tile);
|
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;
|
player.moveTarget = tile.entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user