Fixed #7310
This commit is contained in:
@@ -15,7 +15,7 @@ public class LogicAI extends AIController{
|
|||||||
|
|
||||||
public LUnitControl control = LUnitControl.idle;
|
public LUnitControl control = LUnitControl.idle;
|
||||||
public float moveX, moveY, moveRad;
|
public float moveX, moveY, moveRad;
|
||||||
public float itemTimer, payTimer, controlTimer = logicControlTimeout, targetTimer;
|
public float controlTimer = logicControlTimeout, targetTimer;
|
||||||
@Nullable
|
@Nullable
|
||||||
public Building controller;
|
public Building controller;
|
||||||
public BuildPlan plan = new BuildPlan();
|
public BuildPlan plan = new BuildPlan();
|
||||||
@@ -39,8 +39,6 @@ public class LogicAI extends AIController{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMovement(){
|
public void updateMovement(){
|
||||||
if(itemTimer >= 0) itemTimer -= Time.delta;
|
|
||||||
if(payTimer >= 0) payTimer -= Time.delta;
|
|
||||||
|
|
||||||
if(targetTimer > 0f){
|
if(targetTimer > 0f){
|
||||||
targetTimer -= Time.delta;
|
targetTimer -= Time.delta;
|
||||||
|
|||||||
@@ -2159,10 +2159,8 @@ public class Blocks{
|
|||||||
|
|
||||||
//reinforced stuff
|
//reinforced stuff
|
||||||
|
|
||||||
//TODO different name
|
|
||||||
reinforcedPump = new Pump("reinforced-pump"){{
|
reinforcedPump = new Pump("reinforced-pump"){{
|
||||||
requirements(Category.liquid, with(Items.beryllium, 40, Items.tungsten, 30, Items.silicon, 20));
|
requirements(Category.liquid, with(Items.beryllium, 40, Items.tungsten, 30, Items.silicon, 20));
|
||||||
//TODO CUSTOM DRAW ANIMATION - pistons - repurpose DrawBlock?
|
|
||||||
consumeLiquid(Liquids.hydrogen, 1.5f / 60f);
|
consumeLiquid(Liquids.hydrogen, 1.5f / 60f);
|
||||||
|
|
||||||
pumpAmount = 80f / 60f / 4f;
|
pumpAmount = 80f / 60f / 4f;
|
||||||
|
|||||||
@@ -57,6 +57,17 @@ public class LExecutor{
|
|||||||
public Team team = Team.derelict;
|
public Team team = Team.derelict;
|
||||||
public boolean privileged = false;
|
public boolean privileged = false;
|
||||||
|
|
||||||
|
//yes, this is a minor memory leak, but it's probably not significant enough to matter
|
||||||
|
protected IntFloatMap unitTimeouts = new IntFloatMap();
|
||||||
|
|
||||||
|
boolean timeoutDone(Unit unit, float delay){
|
||||||
|
return Time.time >= unitTimeouts.get(unit.id) + delay;
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateTimeout(Unit unit){
|
||||||
|
unitTimeouts.put(unit.id, Time.time);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean initialized(){
|
public boolean initialized(){
|
||||||
return instructions.length > 0;
|
return instructions.length > 0;
|
||||||
}
|
}
|
||||||
@@ -428,15 +439,15 @@ public class LExecutor{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case payDrop -> {
|
case payDrop -> {
|
||||||
if(ai.payTimer > 0) return;
|
if(!exec.timeoutDone(unit, LogicAI.transferDelay)) return;
|
||||||
|
|
||||||
if(unit instanceof Payloadc pay && pay.hasPayload()){
|
if(unit instanceof Payloadc pay && pay.hasPayload()){
|
||||||
Call.payloadDropped(unit, unit.x, unit.y);
|
Call.payloadDropped(unit, unit.x, unit.y);
|
||||||
ai.payTimer = LogicAI.transferDelay;
|
exec.updateTimeout(unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case payTake -> {
|
case payTake -> {
|
||||||
if(ai.payTimer > 0) return;
|
if(!exec.timeoutDone(unit, LogicAI.transferDelay)) return;
|
||||||
|
|
||||||
if(unit instanceof Payloadc pay){
|
if(unit instanceof Payloadc pay){
|
||||||
//units
|
//units
|
||||||
@@ -460,7 +471,7 @@ public class LExecutor{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ai.payTimer = LogicAI.transferDelay;
|
exec.updateTimeout(unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case payEnter -> {
|
case payEnter -> {
|
||||||
@@ -508,7 +519,7 @@ public class LExecutor{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case itemDrop -> {
|
case itemDrop -> {
|
||||||
if(ai.itemTimer > 0) return;
|
if(!exec.timeoutDone(unit, LogicAI.transferDelay)) return;
|
||||||
|
|
||||||
//clear item when dropping to @air
|
//clear item when dropping to @air
|
||||||
if(exec.obj(p1) == Blocks.air){
|
if(exec.obj(p1) == Blocks.air){
|
||||||
@@ -516,7 +527,7 @@ public class LExecutor{
|
|||||||
if(!net.client()){
|
if(!net.client()){
|
||||||
unit.clearItem();
|
unit.clearItem();
|
||||||
}
|
}
|
||||||
ai.itemTimer = LogicAI.transferDelay;
|
exec.updateTimeout(unit);
|
||||||
}else{
|
}else{
|
||||||
Building build = exec.building(p1);
|
Building build = exec.building(p1);
|
||||||
int dropped = Math.min(unit.stack.amount, exec.numi(p2));
|
int dropped = Math.min(unit.stack.amount, exec.numi(p2));
|
||||||
@@ -524,13 +535,13 @@ public class LExecutor{
|
|||||||
int accepted = build.acceptStack(unit.item(), dropped, unit);
|
int accepted = build.acceptStack(unit.item(), dropped, unit);
|
||||||
if(accepted > 0){
|
if(accepted > 0){
|
||||||
Call.transferItemTo(unit, unit.item(), accepted, unit.x, unit.y, build);
|
Call.transferItemTo(unit, unit.item(), accepted, unit.x, unit.y, build);
|
||||||
ai.itemTimer = LogicAI.transferDelay;
|
exec.updateTimeout(unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case itemTake -> {
|
case itemTake -> {
|
||||||
if(ai.itemTimer > 0) return;
|
if(!exec.timeoutDone(unit, LogicAI.transferDelay)) return;
|
||||||
|
|
||||||
Building build = exec.building(p1);
|
Building build = exec.building(p1);
|
||||||
int amount = exec.numi(p3);
|
int amount = exec.numi(p3);
|
||||||
@@ -541,7 +552,7 @@ public class LExecutor{
|
|||||||
|
|
||||||
if(taken > 0){
|
if(taken > 0){
|
||||||
Call.takeItems(build, item, taken, unit);
|
Call.takeItems(build, item, taken, unit);
|
||||||
ai.itemTimer = LogicAI.transferDelay;
|
exec.updateTimeout(unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user