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.arrow = Cursors.loadCursor("cursor");
|
||||||
Cursors.hand = Cursors.loadCursor("hand");
|
Cursors.hand = Cursors.loadCursor("hand");
|
||||||
Cursors.ibeam = Cursors.loadCursor("ibar");
|
Cursors.ibeam = Cursors.loadCursor("ibar");
|
||||||
|
Cursors.restoreCursor();
|
||||||
Cursors.loadCustom("drill");
|
Cursors.loadCustom("drill");
|
||||||
Cursors.loadCustom("unload");
|
Cursors.loadCustom("unload");
|
||||||
|
|
||||||
|
|||||||
@@ -495,8 +495,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
damage(health + 1); //die instantly
|
damage(health + 1); //die instantly
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ui.chatfrag.chatOpen()) return;
|
|
||||||
|
|
||||||
float speed = isBoosting && !mech.flying ? debug ? 5f : mech.boostSpeed : mech.speed;
|
float speed = isBoosting && !mech.flying ? debug ? 5f : mech.boostSpeed : mech.speed;
|
||||||
//fraction of speed when at max load
|
//fraction of speed when at max load
|
||||||
float carrySlowdown = 0.7f;
|
float carrySlowdown = 0.7f;
|
||||||
@@ -511,7 +509,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
}
|
}
|
||||||
|
|
||||||
//drop from carrier on key press
|
//drop from carrier on key press
|
||||||
if(Inputs.keyTap("drop_unit")){
|
if(!ui.chatfrag.chatOpen() && Inputs.keyTap("drop_unit")){
|
||||||
if(!mech.flying){
|
if(!mech.flying){
|
||||||
if(getCarrier() != null){
|
if(getCarrier() != null){
|
||||||
CallEntity.dropSelf(this);
|
CallEntity.dropSelf(this);
|
||||||
@@ -547,7 +545,9 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
movement.limit(speed * Timers.delta());
|
movement.limit(speed * Timers.delta());
|
||||||
|
|
||||||
if(getCarrier() == null){
|
if(getCarrier() == null){
|
||||||
velocity.add(movement);
|
if(!ui.chatfrag.chatOpen()){
|
||||||
|
velocity.add(movement);
|
||||||
|
}
|
||||||
float prex = x, prey = y;
|
float prex = x, prey = y;
|
||||||
updateVelocityStatus(mech.drag, 10f);
|
updateVelocityStatus(mech.drag, 10f);
|
||||||
moved = distanceTo(prex, prey) > 0.01f;
|
moved = distanceTo(prex, prey) > 0.01f;
|
||||||
@@ -557,13 +557,15 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
y = Mathf.lerpDelta(y, getCarrier().getY(), 0.1f);
|
y = Mathf.lerpDelta(y, getCarrier().getY(), 0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isShooting()){
|
if(!ui.chatfrag.chatOpen()){
|
||||||
if(!movement.isZero()){
|
if(!isShooting()){
|
||||||
rotation = Mathf.slerpDelta(rotation, movement.angle(), 0.13f);
|
if(!movement.isZero()){
|
||||||
|
rotation = Mathf.slerpDelta(rotation, movement.angle(), 0.13f);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
float angle = control.input(playerIndex).mouseAngle(x, y);
|
||||||
|
this.rotation = Mathf.slerpDelta(this.rotation, angle, 0.1f);
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
float angle = control.input(playerIndex).mouseAngle(x, y);
|
|
||||||
this.rotation = Mathf.slerpDelta(this.rotation, angle, 0.1f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import io.anuke.mindustry.entities.units.UnitState;
|
|||||||
import io.anuke.mindustry.game.EventType.BlockBuildEvent;
|
import io.anuke.mindustry.game.EventType.BlockBuildEvent;
|
||||||
import io.anuke.mindustry.gen.CallEntity;
|
import io.anuke.mindustry.gen.CallEntity;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.type.ItemStack;
|
import io.anuke.mindustry.type.ItemStack;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
@@ -47,9 +48,11 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
|||||||
protected Item targetItem;
|
protected Item targetItem;
|
||||||
protected Tile mineTile;
|
protected Tile mineTile;
|
||||||
protected Queue<BuildRequest> placeQueue = new ThreadQueue<>();
|
protected Queue<BuildRequest> placeQueue = new ThreadQueue<>();
|
||||||
|
|
||||||
public final UnitState
|
public final UnitState
|
||||||
|
|
||||||
build = new UnitState(){
|
build = new UnitState(){
|
||||||
|
|
||||||
public void entered(){
|
public void entered(){
|
||||||
if(!(target instanceof BuildEntity)){
|
if(!(target instanceof BuildEntity)){
|
||||||
target = null;
|
target = null;
|
||||||
@@ -90,6 +93,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
|||||||
},
|
},
|
||||||
|
|
||||||
repair = new UnitState(){
|
repair = new UnitState(){
|
||||||
|
|
||||||
public void entered(){
|
public void entered(){
|
||||||
target = null;
|
target = null;
|
||||||
}
|
}
|
||||||
@@ -118,141 +122,142 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mine = new UnitState(){
|
|
||||||
public void entered(){
|
mine = new UnitState(){
|
||||||
target = null;
|
public void entered(){
|
||||||
|
target = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(){
|
||||||
|
TileEntity entity = getClosestCore();
|
||||||
|
|
||||||
|
if(entity == null) return;
|
||||||
|
|
||||||
|
if(targetItem == null){
|
||||||
|
findItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
//core full
|
||||||
|
if(targetItem != null && entity.tile.block().acceptStack(targetItem, 1, entity.tile, Drone.this) == 0){
|
||||||
|
setState(repair);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if inventory is full, drop it off.
|
||||||
|
if(inventory.isFull()){
|
||||||
|
setState(drop);
|
||||||
|
}else{
|
||||||
|
if(targetItem != null && !inventory.canAcceptItem(targetItem)){
|
||||||
|
setState(drop);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(){
|
retarget(() -> {
|
||||||
TileEntity entity = getClosestCore();
|
if(findItemDrop()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(entity == null) return;
|
if(getMineTile() == null){
|
||||||
|
|
||||||
if(targetItem == null){
|
|
||||||
findItem();
|
findItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
//core full
|
if(targetItem == null) return;
|
||||||
if(targetItem != null && entity.tile.block().acceptStack(targetItem, 1, entity.tile, Drone.this) == 0){
|
|
||||||
setState(repair);
|
target = world.indexer().findClosestOre(x, y, targetItem);
|
||||||
return;
|
});
|
||||||
|
|
||||||
|
if(target instanceof Tile){
|
||||||
|
moveTo(type.range / 1.5f);
|
||||||
|
|
||||||
|
if(distanceTo(target) < type.range && mineTile != target){
|
||||||
|
setMineTile((Tile) target);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if inventory is full, drop it off.
|
if(((Tile) target).block() != Blocks.air){
|
||||||
if(inventory.isFull()){
|
|
||||||
setState(drop);
|
setState(drop);
|
||||||
}else{
|
|
||||||
if(targetItem != null && !inventory.canAcceptItem(targetItem)){
|
|
||||||
setState(drop);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
retarget(() -> {
|
|
||||||
if(findItemDrop()){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(getMineTile() == null){
|
|
||||||
findItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(targetItem == null) return;
|
|
||||||
|
|
||||||
target = world.indexer().findClosestOre(x, y, targetItem);
|
|
||||||
});
|
|
||||||
|
|
||||||
if(target instanceof Tile){
|
|
||||||
moveTo(type.range / 1.5f);
|
|
||||||
|
|
||||||
if(distanceTo(target) < type.range && mineTile != target){
|
|
||||||
setMineTile((Tile) target);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(((Tile) target).block() != Blocks.air){
|
|
||||||
setState(drop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void exited(){
|
public void exited(){
|
||||||
setMineTile(null);
|
setMineTile(null);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
pickup = new UnitState(){
|
||||||
|
public void entered(){
|
||||||
|
target = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(){
|
||||||
|
ItemDrop item = (ItemDrop) target;
|
||||||
|
|
||||||
|
if(inventory.isFull() || !inventory.canAcceptItem(item.getItem(), 1)){
|
||||||
|
setState(drop);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(distanceTo(item) < 4){
|
||||||
|
item.collision(Drone.this, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
//item has been picked up
|
||||||
|
if(item.getAmount() == 0){
|
||||||
|
if(!findItemDrop()){
|
||||||
|
setState(drop);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
pickup = new UnitState(){
|
|
||||||
public void entered(){
|
moveTo(0f);
|
||||||
target = null;
|
}
|
||||||
|
},
|
||||||
|
drop = new UnitState(){
|
||||||
|
public void entered(){
|
||||||
|
target = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(){
|
||||||
|
if(inventory.isEmpty()){
|
||||||
|
setState(mine);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
target = getClosestCore();
|
||||||
|
|
||||||
|
if(target == null) return;
|
||||||
|
|
||||||
|
TileEntity tile = (TileEntity) target;
|
||||||
|
|
||||||
|
if(distanceTo(target) < type.range){
|
||||||
|
if(tile.tile.block().acceptStack(inventory.getItem().item, inventory.getItem().amount, tile.tile, Drone.this) == inventory.getItem().amount){
|
||||||
|
CallEntity.transferItemTo(inventory.getItem().item, inventory.getItem().amount, x, y, tile.tile);
|
||||||
|
inventory.clearItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(){
|
setState(repair);
|
||||||
ItemDrop item = (ItemDrop) target;
|
}
|
||||||
|
|
||||||
if(inventory.isFull() || !inventory.canAcceptItem(item.getItem(), 1)){
|
circle(type.range / 1.8f);
|
||||||
setState(drop);
|
}
|
||||||
return;
|
},
|
||||||
}
|
retreat = new UnitState(){
|
||||||
|
public void entered(){
|
||||||
|
target = null;
|
||||||
|
}
|
||||||
|
|
||||||
if(distanceTo(item) < 4){
|
public void update(){
|
||||||
item.collision(Drone.this, x, y);
|
if(health >= health){
|
||||||
}
|
state.set(attack);
|
||||||
|
}else if(!targetHasFlag(BlockFlag.repair)){
|
||||||
//item has been picked up
|
if(timer.get(timerTarget, 20)){
|
||||||
if(item.getAmount() == 0){
|
Tile target = Geometry.findClosest(x, y, world.indexer().getAllied(team, BlockFlag.repair));
|
||||||
if(!findItemDrop()){
|
if(target != null) Drone.this.target = target.entity;
|
||||||
setState(drop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
moveTo(0f);
|
|
||||||
}
|
}
|
||||||
},
|
}else{
|
||||||
drop = new UnitState(){
|
circle(40f);
|
||||||
public void entered(){
|
}
|
||||||
target = null;
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
public void update(){
|
|
||||||
if(inventory.isEmpty()){
|
|
||||||
setState(mine);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
target = getClosestCore();
|
|
||||||
|
|
||||||
if(target == null) return;
|
|
||||||
|
|
||||||
TileEntity tile = (TileEntity) target;
|
|
||||||
|
|
||||||
if(distanceTo(target) < type.range){
|
|
||||||
if(tile.tile.block().acceptStack(inventory.getItem().item, inventory.getItem().amount, tile.tile, Drone.this) == inventory.getItem().amount){
|
|
||||||
CallEntity.transferItemTo(inventory.getItem().item, inventory.getItem().amount, x, y, tile.tile);
|
|
||||||
inventory.clearItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(repair);
|
|
||||||
}
|
|
||||||
|
|
||||||
circle(type.range / 1.8f);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
retreat = new UnitState(){
|
|
||||||
public void entered(){
|
|
||||||
target = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(){
|
|
||||||
if(health >= health){
|
|
||||||
state.set(attack);
|
|
||||||
}else if(!targetHasFlag(BlockFlag.repair)){
|
|
||||||
if(timer.get(timerTarget, 20)){
|
|
||||||
Tile target = Geometry.findClosest(x, y, world.indexer().getAllied(team, BlockFlag.repair));
|
|
||||||
if(target != null) Drone.this.target = target.entity;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
circle(40f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
{
|
{
|
||||||
initEvents();
|
initEvents();
|
||||||
@@ -323,6 +328,12 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
|||||||
public void update(){
|
public void update(){
|
||||||
super.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);
|
x += Mathf.sin(Timers.time() + id * 999, 25f, 0.07f);
|
||||||
y += Mathf.cos(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{
|
public void write(DataOutput data) throws IOException{
|
||||||
super.write(data);
|
super.write(data);
|
||||||
data.writeInt(mineTile == null ? -1 : mineTile.packedPosition());
|
data.writeInt(mineTile == null ? -1 : mineTile.packedPosition());
|
||||||
|
data.writeInt(state.is(repair) && target instanceof TileEntity ? ((TileEntity)target).tile.packedPosition() : -1);
|
||||||
writeBuilding(data);
|
writeBuilding(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,12 +437,21 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
|||||||
public void read(DataInput data, long time) throws IOException{
|
public void read(DataInput data, long time) throws IOException{
|
||||||
super.read(data, time);
|
super.read(data, time);
|
||||||
int mined = data.readInt();
|
int mined = data.readInt();
|
||||||
|
int repairing = data.readInt();
|
||||||
|
|
||||||
readBuilding(data);
|
readBuilding(data);
|
||||||
|
|
||||||
if(mined != -1){
|
if(mined != -1){
|
||||||
mineTile = world.tile(mined);
|
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