More movement
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package mindustry.entities.def;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
@@ -13,7 +14,7 @@ abstract class LegsComp implements Posc, Flyingc, Hitboxc, DrawLayerGroundUnderc
|
||||
@Override
|
||||
public void update(){
|
||||
if(vel().len() > 0.5f){
|
||||
baseRotation = vel().angle();
|
||||
baseRotation = Angles.moveToward(baseRotation, vel().angle(), type().baseRotateSpeed);
|
||||
walkTime += Time.delta()*vel().len()/1f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import static mindustry.Vars.*;
|
||||
abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc{
|
||||
transient float x, y, rotation;
|
||||
|
||||
float mineTimer;
|
||||
@Nullable Tile mineTile;
|
||||
|
||||
abstract boolean canMine(Item item);
|
||||
@@ -48,11 +49,14 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc{
|
||||
if(mineTile == null || core == null || mineTile.block() != Blocks.air || dst(mineTile.worldx(), mineTile.worldy()) > miningRange
|
||||
|| mineTile.drop() == null || !acceptsItem(mineTile.drop()) || !canMine(mineTile.drop())){
|
||||
mineTile = null;
|
||||
mineTimer = 0f;
|
||||
}else{
|
||||
Item item = mineTile.drop();
|
||||
rotation(Mathf.slerpDelta(rotation(), angleTo(mineTile.worldx(), mineTile.worldy()), 0.4f));
|
||||
mineTimer += Time.delta()*miningSpeed();
|
||||
|
||||
if(Mathf.chance(Time.delta() * (0.06 - item.hardness * 0.01) * miningSpeed())){
|
||||
if(mineTimer >= 50f + item.hardness*10f){
|
||||
mineTimer = 0;
|
||||
|
||||
if(dst(core) < mineTransferRange && core.tile().block().acceptStack(item, 1, core.tile(), this) == 1 && offloadImmediately()){
|
||||
Call.transferItemTo(item, 1,
|
||||
|
||||
@@ -163,9 +163,8 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
}
|
||||
|
||||
//TODO implement
|
||||
if(!player.dead()){
|
||||
updateKeyboard(player.unit());
|
||||
if(!player.dead() && !state.isPaused()){
|
||||
updateMovement(player.unit());
|
||||
}
|
||||
|
||||
if(Core.input.keyRelease(Binding.select)){
|
||||
@@ -179,7 +178,8 @@ public class DesktopInput extends InputHandler{
|
||||
if(state.is(State.menu) || Core.scene.hasDialog()) return;
|
||||
|
||||
//zoom camera
|
||||
if((!Core.scene.hasScroll() || Core.input.keyDown(Binding.diagonal_placement)) && !ui.chatfrag.shown() && Math.abs(Core.input.axisTap(Binding.zoom)) > 0 && !Core.input.keyDown(Binding.rotateplaced) && (Core.input.keyDown(Binding.diagonal_placement) || ((!isPlacing() || !block.rotate) && selectRequests.isEmpty()))){
|
||||
if((!Core.scene.hasScroll() || Core.input.keyDown(Binding.diagonal_placement)) && !ui.chatfrag.shown() && Math.abs(Core.input.axisTap(Binding.zoom)) > 0
|
||||
&& !Core.input.keyDown(Binding.rotateplaced) && (Core.input.keyDown(Binding.diagonal_placement) || ((!isPlacing() || !block.rotate) && selectRequests.isEmpty()))){
|
||||
renderer.scaleCamera(Core.input.axisTap(Binding.zoom));
|
||||
}
|
||||
|
||||
@@ -494,7 +494,7 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateKeyboard(Unitc unit){
|
||||
protected void updateMovement(Unitc unit){
|
||||
boolean canMove = !(Core.scene.getKeyboardFocus() instanceof TextField);
|
||||
|
||||
float speed = unit.type().speed;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class UnitDef extends UnlockableContent{
|
||||
public @NonNull Prov<? extends UnitController> defaultController = AIController::new;
|
||||
public @NonNull Prov<? extends Unitc> constructor;
|
||||
public boolean flying;
|
||||
public float speed = 1.1f, boostSpeed = 0.75f, rotateSpeed = 10f, baseRotateSpeed = 0.1f;
|
||||
public float speed = 1.1f, boostSpeed = 0.75f, rotateSpeed = 10f, baseRotateSpeed = 10f;
|
||||
public float drag = 0.3f, mass = 1f, accel = 0.1f;
|
||||
public float health = 200f, range = -1;
|
||||
public boolean targetAir = false, targetGround = false;
|
||||
|
||||
Reference in New Issue
Block a user