Consumption bugfixes

This commit is contained in:
Anuken
2022-02-23 11:02:37 -05:00
parent e4fcf3ad5b
commit 9383bb4b30
5 changed files with 7 additions and 13 deletions

View File

@@ -3360,6 +3360,7 @@ public class Blocks{
shootWarmupSpeed = 0.07f;
coolant = consume(new ConsumeLiquid(Liquids.water, 30f / 60f));
coolantMultiplier = 2.5f;
draw = new DrawTurret("reinforced-"){{
parts.addAll(

View File

@@ -70,7 +70,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
transient float enabledControlTime;
transient String lastAccessed;
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;
@Nullable PowerModule power;
@@ -78,9 +78,9 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
@Nullable LiquidModule liquids;
/** Base efficiency. Takes the minimum value of all consumers. */
transient float efficiency = 1f;
transient float efficiency;
/** Same as efficiency, but for optional consumers only. */
transient float optionalEfficiency = 1f;
transient float optionalEfficiency;
public transient float healSuppressionTime = -1f;
public transient float lastHealTime = -120f * 10f;
@@ -189,8 +189,6 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
boolean legacy = true;
byte version = 0;
//TODO new version with efficiency instead of consValid
//new version
if((rot & 0b10000000) != 0){
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 & 4) != 0) (liquids == null ? new LiquidModule() : liquids).read(read, legacy);
//unnecessary consume module read in version 2
if(version == 2) read.bool();
//unnecessary consume module read in version 2 and below
if(version <= 2) read.bool();
//version 3 has efficiency numbers instead of bools
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 rotation -> rotation;
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 totalPower -> power == null || block.consPower == null ? 0 : power.status * (block.consPower.buffered ? block.consPower.capacity : 1f);
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();
//TODO just handle per-block instead

View File

@@ -15,7 +15,6 @@ public class ConsumeItemCharged extends ConsumeItemFilter{
@Override
public float efficiencyMultiplier(Building build){
if(build.consumeTriggerValid()) return 1f;
var item = getConsumed(build);
return item == null ? 0f : item.charge;
}

View File

@@ -14,8 +14,6 @@ public class ConsumeItemFlammable extends ConsumeItemFilter{
@Override
public float efficiencyMultiplier(Building build){
//TODO ugh
if(build.consumeTriggerValid()) return 1f;
var item = getConsumed(build);
return item == null ? 0f : item.flammability;
}

View File

@@ -14,7 +14,6 @@ public class ConsumeItemRadioactive extends ConsumeItemFilter{
@Override
public float efficiencyMultiplier(Building build){
if(build.consumeTriggerValid()) return 1f;
var item = getConsumed(build);
return item == null ? 0f : item.radioactivity;
}