Fixed #11268
This commit is contained in:
@@ -97,6 +97,7 @@ public class Build{
|
||||
tile.build.enabled = true;
|
||||
if(tile.build.power != null){
|
||||
tile.build.power.links.clear();
|
||||
tile.build.powerGraphRemoved();
|
||||
}
|
||||
tile.build.checkAllowUpdate();
|
||||
tile.build.updateProximity();
|
||||
|
||||
@@ -38,6 +38,11 @@ public class BuildPayload implements Payload{
|
||||
build.dropped();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contentEquals(Payload other){
|
||||
return other instanceof BuildPayload bp && bp.block() == build.block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnlockableContent content(){
|
||||
return build.block;
|
||||
|
||||
@@ -36,6 +36,8 @@ public interface Payload extends Position{
|
||||
/** @return the time taken to build this payload. */
|
||||
float buildTime();
|
||||
|
||||
boolean contentEquals(Payload other);
|
||||
|
||||
/** update this payload inside a container unit or building. either can be null. */
|
||||
default void update(@Nullable Unit unitHolder, @Nullable Building buildingHolder){}
|
||||
|
||||
|
||||
@@ -42,6 +42,11 @@ public class UnitPayload implements Payload{
|
||||
showOverlay(icon.getRegion());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contentEquals(Payload other){
|
||||
return other instanceof UnitPayload up && up.unit.type == unit.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@Nullable Unit unitHolder, @Nullable Building buildingHolder){
|
||||
unit.type.updatePayload(unit, unitHolder, buildingHolder);
|
||||
|
||||
@@ -667,8 +667,10 @@ public class UnitAssembler extends PayloadBlock{
|
||||
@Override
|
||||
public boolean acceptPayload(Building source, Payload payload){
|
||||
var plan = plan();
|
||||
return (this.payload == null || source instanceof UnitAssemblerModuleBuild) &&
|
||||
plan.requirements.contains(b -> b.item == payload.content() && blocks.get(payload.content()) < Mathf.round(b.amount * state.rules.unitCost(team)));
|
||||
return (this.payload == null || (source instanceof UnitAssemblerModuleBuild)) &&
|
||||
plan.requirements.contains(b -> b.item == payload.content() &&
|
||||
blocks.get(payload.content()) < Mathf.round(b.amount * state.rules.unitCost(team)) -
|
||||
(source instanceof UnitAssemblerModuleBuild && (this.payload != null && this.payload.contentEquals(payload)) ? 1 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user