Fixed chat stopping velocity / Fixed drone repair not being synced
This commit is contained in:
@@ -110,6 +110,7 @@ public class Renderer extends RendererModule{
|
||||
Cursors.arrow = Cursors.loadCursor("cursor");
|
||||
Cursors.hand = Cursors.loadCursor("hand");
|
||||
Cursors.ibeam = Cursors.loadCursor("ibar");
|
||||
Cursors.restoreCursor();
|
||||
Cursors.loadCustom("drill");
|
||||
Cursors.loadCustom("unload");
|
||||
|
||||
|
||||
@@ -495,8 +495,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
damage(health + 1); //die instantly
|
||||
}
|
||||
|
||||
if(ui.chatfrag.chatOpen()) return;
|
||||
|
||||
float speed = isBoosting && !mech.flying ? debug ? 5f : mech.boostSpeed : mech.speed;
|
||||
//fraction of speed when at max load
|
||||
float carrySlowdown = 0.7f;
|
||||
@@ -511,7 +509,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
}
|
||||
|
||||
//drop from carrier on key press
|
||||
if(Inputs.keyTap("drop_unit")){
|
||||
if(!ui.chatfrag.chatOpen() && Inputs.keyTap("drop_unit")){
|
||||
if(!mech.flying){
|
||||
if(getCarrier() != null){
|
||||
CallEntity.dropSelf(this);
|
||||
@@ -547,7 +545,9 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
movement.limit(speed * Timers.delta());
|
||||
|
||||
if(getCarrier() == null){
|
||||
if(!ui.chatfrag.chatOpen()){
|
||||
velocity.add(movement);
|
||||
}
|
||||
float prex = x, prey = y;
|
||||
updateVelocityStatus(mech.drag, 10f);
|
||||
moved = distanceTo(prex, prey) > 0.01f;
|
||||
@@ -557,6 +557,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
y = Mathf.lerpDelta(y, getCarrier().getY(), 0.1f);
|
||||
}
|
||||
|
||||
if(!ui.chatfrag.chatOpen()){
|
||||
if(!isShooting()){
|
||||
if(!movement.isZero()){
|
||||
rotation = Mathf.slerpDelta(rotation, movement.angle(), 0.13f);
|
||||
@@ -566,6 +567,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
this.rotation = Mathf.slerpDelta(this.rotation, angle, 0.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateShooting(){
|
||||
if(isShooting()){
|
||||
|
||||
@@ -16,6 +16,7 @@ import io.anuke.mindustry.entities.units.UnitState;
|
||||
import io.anuke.mindustry.game.EventType.BlockBuildEvent;
|
||||
import io.anuke.mindustry.gen.CallEntity;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
@@ -47,9 +48,11 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
||||
protected Item targetItem;
|
||||
protected Tile mineTile;
|
||||
protected Queue<BuildRequest> placeQueue = new ThreadQueue<>();
|
||||
|
||||
public final UnitState
|
||||
|
||||
build = new UnitState(){
|
||||
|
||||
public void entered(){
|
||||
if(!(target instanceof BuildEntity)){
|
||||
target = null;
|
||||
@@ -90,6 +93,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
||||
},
|
||||
|
||||
repair = new UnitState(){
|
||||
|
||||
public void entered(){
|
||||
target = null;
|
||||
}
|
||||
@@ -118,6 +122,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
mine = new UnitState(){
|
||||
public void entered(){
|
||||
target = null;
|
||||
@@ -323,6 +328,12 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
||||
public void update(){
|
||||
super.update();
|
||||
|
||||
if(Net.client() && state.is(repair) && target instanceof TileEntity){
|
||||
TileEntity entity = (TileEntity) target;
|
||||
entity.health += type.healSpeed * Timers.delta();
|
||||
entity.health = Mathf.clamp(entity.health, 0, entity.tile.block().health);
|
||||
}
|
||||
|
||||
x += Mathf.sin(Timers.time() + id * 999, 25f, 0.07f);
|
||||
y += Mathf.cos(Timers.time() + id * 999, 25f, 0.07f);
|
||||
|
||||
@@ -418,6 +429,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
||||
public void write(DataOutput data) throws IOException{
|
||||
super.write(data);
|
||||
data.writeInt(mineTile == null ? -1 : mineTile.packedPosition());
|
||||
data.writeInt(state.is(repair) && target instanceof TileEntity ? ((TileEntity)target).tile.packedPosition() : -1);
|
||||
writeBuilding(data);
|
||||
}
|
||||
|
||||
@@ -425,12 +437,21 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
||||
public void read(DataInput data, long time) throws IOException{
|
||||
super.read(data, time);
|
||||
int mined = data.readInt();
|
||||
int repairing = data.readInt();
|
||||
|
||||
readBuilding(data);
|
||||
|
||||
if(mined != -1){
|
||||
mineTile = world.tile(mined);
|
||||
}
|
||||
|
||||
if(repairing != -1){
|
||||
Tile tile = world.tile(repairing);
|
||||
target = tile.entity;
|
||||
state.set(repair);
|
||||
}else{
|
||||
state.set(retreat);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user