More movement

This commit is contained in:
Anuken
2020-02-07 18:55:53 -05:00
parent 4265d40024
commit 8a9c92227d
4 changed files with 13 additions and 8 deletions

View File

@@ -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;
}
}

View File

@@ -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,