mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-24 21:48:25 +07:00
Fixed unit payload pickup/drop spam
This commit is contained in:
parent
cfbbee8746
commit
575965e295
@ -37,6 +37,7 @@ public class CommandAI extends AIController{
|
|||||||
protected Vec2 lastTargetPos;
|
protected Vec2 lastTargetPos;
|
||||||
protected boolean blockingUnit;
|
protected boolean blockingUnit;
|
||||||
protected float timeSpentBlocked;
|
protected float timeSpentBlocked;
|
||||||
|
protected float payloadPickupCooldown;
|
||||||
protected int transferState = transferStateNone;
|
protected int transferState = transferStateNone;
|
||||||
|
|
||||||
/** Stance, usually related to firing mode. */
|
/** Stance, usually related to firing mode. */
|
||||||
@ -125,6 +126,8 @@ public class CommandAI extends AIController{
|
|||||||
public void defaultBehavior(){
|
public void defaultBehavior(){
|
||||||
|
|
||||||
if(!net.client() && unit instanceof Payloadc pay){
|
if(!net.client() && unit instanceof Payloadc pay){
|
||||||
|
payloadPickupCooldown -= Time.delta;
|
||||||
|
|
||||||
//auto-drop everything
|
//auto-drop everything
|
||||||
if(command == UnitCommand.unloadPayloadCommand && pay.hasPayload()){
|
if(command == UnitCommand.unloadPayloadCommand && pay.hasPayload()){
|
||||||
Call.payloadDropped(unit, unit.x, unit.y);
|
Call.payloadDropped(unit, unit.x, unit.y);
|
||||||
@ -350,6 +353,8 @@ public class CommandAI extends AIController{
|
|||||||
transferState = pay.hasPayload() ? transferStateUnload : transferStateLoad;
|
transferState = pay.hasPayload() ? transferStateUnload : transferStateLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(payloadPickupCooldown > 0f) return;
|
||||||
|
|
||||||
if(transferState == transferStateUnload){
|
if(transferState == transferStateUnload){
|
||||||
//drop until there's a failure
|
//drop until there's a failure
|
||||||
int prev = -1;
|
int prev = -1;
|
||||||
@ -362,6 +367,7 @@ public class CommandAI extends AIController{
|
|||||||
if(pay.hasPayload()){
|
if(pay.hasPayload()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
payloadPickupCooldown = 60f;
|
||||||
}else if(transferState == transferStateLoad){
|
}else if(transferState == transferStateLoad){
|
||||||
//pick up units until there's a failure
|
//pick up units until there's a failure
|
||||||
int prev = -1;
|
int prev = -1;
|
||||||
@ -374,6 +380,7 @@ public class CommandAI extends AIController{
|
|||||||
if(!pay.hasPayload()){
|
if(!pay.hasPayload()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
payloadPickupCooldown = 60f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//it will never finish
|
//it will never finish
|
||||||
|
Loading…
Reference in New Issue
Block a user