Consumption bugfixes
This commit is contained in:
@@ -3360,6 +3360,7 @@ public class Blocks{
|
|||||||
shootWarmupSpeed = 0.07f;
|
shootWarmupSpeed = 0.07f;
|
||||||
|
|
||||||
coolant = consume(new ConsumeLiquid(Liquids.water, 30f / 60f));
|
coolant = consume(new ConsumeLiquid(Liquids.water, 30f / 60f));
|
||||||
|
coolantMultiplier = 2.5f;
|
||||||
|
|
||||||
draw = new DrawTurret("reinforced-"){{
|
draw = new DrawTurret("reinforced-"){{
|
||||||
parts.addAll(
|
parts.addAll(
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
transient float enabledControlTime;
|
transient float enabledControlTime;
|
||||||
transient String lastAccessed;
|
transient String lastAccessed;
|
||||||
transient boolean wasDamaged; //used only by the indexer
|
transient boolean wasDamaged; //used only by the indexer
|
||||||
transient boolean wasVisible; //used only by the block renderer when fog is on
|
transient boolean wasVisible; //used only by the block renderer when fog is on (TODO replace with discovered check?)
|
||||||
transient float visualLiquid;
|
transient float visualLiquid;
|
||||||
|
|
||||||
@Nullable PowerModule power;
|
@Nullable PowerModule power;
|
||||||
@@ -78,9 +78,9 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
@Nullable LiquidModule liquids;
|
@Nullable LiquidModule liquids;
|
||||||
|
|
||||||
/** Base efficiency. Takes the minimum value of all consumers. */
|
/** Base efficiency. Takes the minimum value of all consumers. */
|
||||||
transient float efficiency = 1f;
|
transient float efficiency;
|
||||||
/** Same as efficiency, but for optional consumers only. */
|
/** Same as efficiency, but for optional consumers only. */
|
||||||
transient float optionalEfficiency = 1f;
|
transient float optionalEfficiency;
|
||||||
|
|
||||||
public transient float healSuppressionTime = -1f;
|
public transient float healSuppressionTime = -1f;
|
||||||
public transient float lastHealTime = -120f * 10f;
|
public transient float lastHealTime = -120f * 10f;
|
||||||
@@ -189,8 +189,6 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
boolean legacy = true;
|
boolean legacy = true;
|
||||||
byte version = 0;
|
byte version = 0;
|
||||||
|
|
||||||
//TODO new version with efficiency instead of consValid
|
|
||||||
|
|
||||||
//new version
|
//new version
|
||||||
if((rot & 0b10000000) != 0){
|
if((rot & 0b10000000) != 0){
|
||||||
version = read.b(); //version of entity save
|
version = read.b(); //version of entity save
|
||||||
@@ -213,8 +211,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
if((moduleBits & 2) != 0) (power == null ? new PowerModule() : power).read(read, legacy);
|
if((moduleBits & 2) != 0) (power == null ? new PowerModule() : power).read(read, legacy);
|
||||||
if((moduleBits & 4) != 0) (liquids == null ? new LiquidModule() : liquids).read(read, legacy);
|
if((moduleBits & 4) != 0) (liquids == null ? new LiquidModule() : liquids).read(read, legacy);
|
||||||
|
|
||||||
//unnecessary consume module read in version 2
|
//unnecessary consume module read in version 2 and below
|
||||||
if(version == 2) read.bool();
|
if(version <= 2) read.bool();
|
||||||
|
|
||||||
//version 3 has efficiency numbers instead of bools
|
//version 3 has efficiency numbers instead of bools
|
||||||
if(version >= 3){
|
if(version >= 3){
|
||||||
@@ -1765,7 +1763,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
case range -> this instanceof Ranged r ? r.range() / tilesize : 0;
|
case range -> this instanceof Ranged r ? r.range() / tilesize : 0;
|
||||||
case rotation -> rotation;
|
case rotation -> rotation;
|
||||||
case totalItems -> items == null ? 0 : items.total();
|
case totalItems -> items == null ? 0 : items.total();
|
||||||
//TODO will give wildly fluctuating amounts due to switching of current() for multi-liquid blocks. totalLiquids is inherently bad design, but unfortunately it is useful for conduits/tanks
|
//totalLiquids is inherently bad design, but unfortunately it is useful for conduits/tanks
|
||||||
case totalLiquids -> liquids == null ? 0 : liquids.currentAmount();
|
case totalLiquids -> liquids == null ? 0 : liquids.currentAmount();
|
||||||
case totalPower -> power == null || block.consPower == null ? 0 : power.status * (block.consPower.buffered ? block.consPower.capacity : 1f);
|
case totalPower -> power == null || block.consPower == null ? 0 : power.status * (block.consPower.buffered ? block.consPower.capacity : 1f);
|
||||||
case itemCapacity -> block.hasItems ? block.itemCapacity : 0;
|
case itemCapacity -> block.hasItems ? block.itemCapacity : 0;
|
||||||
@@ -1893,7 +1891,6 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO updating consumption is not necessary for every building, e.g. conveyors should not have it
|
|
||||||
updateConsumption();
|
updateConsumption();
|
||||||
|
|
||||||
//TODO just handle per-block instead
|
//TODO just handle per-block instead
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ public class ConsumeItemCharged extends ConsumeItemFilter{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float efficiencyMultiplier(Building build){
|
public float efficiencyMultiplier(Building build){
|
||||||
if(build.consumeTriggerValid()) return 1f;
|
|
||||||
var item = getConsumed(build);
|
var item = getConsumed(build);
|
||||||
return item == null ? 0f : item.charge;
|
return item == null ? 0f : item.charge;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ public class ConsumeItemFlammable extends ConsumeItemFilter{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float efficiencyMultiplier(Building build){
|
public float efficiencyMultiplier(Building build){
|
||||||
//TODO ugh
|
|
||||||
if(build.consumeTriggerValid()) return 1f;
|
|
||||||
var item = getConsumed(build);
|
var item = getConsumed(build);
|
||||||
return item == null ? 0f : item.flammability;
|
return item == null ? 0f : item.flammability;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ public class ConsumeItemRadioactive extends ConsumeItemFilter{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float efficiencyMultiplier(Building build){
|
public float efficiencyMultiplier(Building build){
|
||||||
if(build.consumeTriggerValid()) return 1f;
|
|
||||||
var item = getConsumed(build);
|
var item = getConsumed(build);
|
||||||
return item == null ? 0f : item.radioactivity;
|
return item == null ? 0f : item.radioactivity;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user