the refactoring continues
This commit is contained in:
@@ -56,7 +56,7 @@ public class Accelerator extends Block{
|
||||
@Override
|
||||
public void updateTile(){
|
||||
super.updateTile();
|
||||
heat = Mathf.lerpDelta(heat, consValid() ? 1f : 0f, 0.05f);
|
||||
heat = Mathf.lerpDelta(heat, consValid ? 1f : 0f, 0.05f);
|
||||
statusLerp = Mathf.lerpDelta(statusLerp, power.status, 0.05f);
|
||||
}
|
||||
|
||||
@@ -101,14 +101,14 @@ public class Accelerator extends Block{
|
||||
|
||||
@Override
|
||||
public Cursor getCursor(){
|
||||
return !state.isCampaign() || !consValid() ? SystemCursor.arrow : super.getCursor();
|
||||
return !state.isCampaign() || !consValid ? SystemCursor.arrow : super.getCursor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildConfiguration(Table table){
|
||||
deselect();
|
||||
|
||||
if(!state.isCampaign() || !consValid()) return;
|
||||
if(!state.isCampaign() || !consValid) return;
|
||||
|
||||
ui.planet.showPlanetLaunch(state.rules.sector, sector -> {
|
||||
//TODO cutscene, etc...
|
||||
|
||||
@@ -126,7 +126,7 @@ public class LaunchPad extends Block{
|
||||
if(!state.isCampaign()) return;
|
||||
|
||||
//increment launchCounter then launch when full and base conditions are met
|
||||
if((launchCounter += edelta()) >= launchTime && consValid() && items.total() >= itemCapacity){
|
||||
if((launchCounter += edelta()) >= launchTime && consValid && items.total() >= itemCapacity){
|
||||
//if there are item requirements, use those.
|
||||
consume();
|
||||
launchSound.at(x, y);
|
||||
|
||||
@@ -241,7 +241,7 @@ public class BuildTurret extends BaseTurret{
|
||||
super.write(write);
|
||||
write.f(rotation);
|
||||
//TODO queue can be very large due to logic?
|
||||
TypeIO.writeRequests(write, unit.plans().toArray(BuildPlan.class));
|
||||
TypeIO.writePlans(write, unit.plans().toArray(BuildPlan.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -250,7 +250,7 @@ public class BuildTurret extends BaseTurret{
|
||||
rotation = read.f();
|
||||
unit.rotation(rotation);
|
||||
unit.plans().clear();
|
||||
var reqs = TypeIO.readRequests(read);
|
||||
var reqs = TypeIO.readPlans(read);
|
||||
if(reqs != null){
|
||||
for(var req : reqs){
|
||||
unit.plans().add(req);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Door extends Wall{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion getRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public TextureRegion getPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
return plan.config == Boolean.TRUE ? openRegion : region;
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ public class ForceProjector extends Block{
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
boolean phaseValid = itemConsumer != null && itemConsumer.valid(this);
|
||||
boolean phaseValid = itemConsumer != null && itemConsumer.efficiency(this) > 0;
|
||||
|
||||
phaseHeat = Mathf.lerpDelta(phaseHeat, Mathf.num(phaseValid), 0.1f);
|
||||
|
||||
@@ -169,7 +169,7 @@ public class ForceProjector extends Block{
|
||||
|
||||
//TODO I hate this system
|
||||
if(coolantConsumer != null){
|
||||
if(coolantConsumer.valid(this)){
|
||||
if(coolantConsumer.efficiency(this) > 0){
|
||||
coolantConsumer.update(this);
|
||||
scale *= (cooldownLiquid * (1f + (liquids.current().heatCapacity - 0.4f) * 0.9f));
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class MendProjector extends Block{
|
||||
boolean canHeal = !checkSuppression();
|
||||
|
||||
smoothEfficiency = Mathf.lerpDelta(smoothEfficiency, efficiency(), 0.08f);
|
||||
heat = Mathf.lerpDelta(heat, consValid() && canHeal ? 1f : 0f, 0.08f);
|
||||
heat = Mathf.lerpDelta(heat, consValid && canHeal ? 1f : 0f, 0.08f);
|
||||
charge += heat * delta();
|
||||
|
||||
phaseHeat = Mathf.lerpDelta(phaseHeat, Mathf.num(consOptionalValid()), 0.1f);
|
||||
|
||||
@@ -98,7 +98,7 @@ public class OverdriveProjector extends Block{
|
||||
@Override
|
||||
public void updateTile(){
|
||||
smoothEfficiency = Mathf.lerpDelta(smoothEfficiency, efficiency(), 0.08f);
|
||||
heat = Mathf.lerpDelta(heat, consValid() ? 1f : 0f, 0.08f);
|
||||
heat = Mathf.lerpDelta(heat, consValid ? 1f : 0f, 0.08f);
|
||||
charge += heat * Time.delta;
|
||||
|
||||
if(hasBoost){
|
||||
@@ -112,13 +112,13 @@ public class OverdriveProjector extends Block{
|
||||
indexer.eachBlock(this, realRange, other -> other.block.canOverdrive, other -> other.applyBoost(realBoost(), reload + 1f));
|
||||
}
|
||||
|
||||
if(timer(timerUse, useTime) && efficiency() > 0 && consValid()){
|
||||
if(timer(timerUse, useTime) && efficiency() > 0 && consValid){
|
||||
consume();
|
||||
}
|
||||
}
|
||||
|
||||
public float realBoost(){
|
||||
return consValid() ? (speedBoost + phaseHeat * speedBoostPhase) * efficiency() : 0f;
|
||||
return consValid ? (speedBoost + phaseHeat * speedBoostPhase) * efficiency() : 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -62,7 +62,7 @@ public class RegenProjector extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawer.drawPlan(this, plan, list);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class RegenProjector extends Block{
|
||||
}
|
||||
|
||||
//TODO should warmup depend on didRegen?
|
||||
warmup = Mathf.approachDelta(warmup, consValid() && didRegen ? 1f : 0f, 1f / 70f);
|
||||
warmup = Mathf.approachDelta(warmup, consValid && didRegen ? 1f : 0f, 1f / 70f);
|
||||
totalTime += warmup * Time.delta;
|
||||
didRegen = false;
|
||||
|
||||
@@ -121,7 +121,7 @@ public class RegenProjector extends Block{
|
||||
return;
|
||||
}
|
||||
|
||||
if(consValid()){
|
||||
if(consValid){
|
||||
if(consOptionalValid() && (optionalTimer += Time.delta) >= optionalUseTime){
|
||||
consume();
|
||||
optionalUseTime = 0f;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class Thruster extends Wall{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(topRegion, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
}
|
||||
|
||||
@@ -41,21 +41,18 @@ public class ContinuousLiquidTurret extends ContinuousTurret{
|
||||
public void init(){
|
||||
//TODO display ammoMultiplier.
|
||||
consume(new ConsumeLiquidFilter(i -> ammoTypes.containsKey(i), liquidConsumed){
|
||||
@Override
|
||||
public boolean valid(Building build){
|
||||
return build.liquids.currentAmount() >= use(build);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Stats stats){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float use(Building entity){
|
||||
BulletType type = ammoTypes.get(entity.liquids.current());
|
||||
return Math.min(amount * entity.edelta(), entity.block.liquidCapacity) / (type == null ? 1f : type.ammoMultiplier);
|
||||
}
|
||||
//TODO
|
||||
//@Override
|
||||
//protected float use(Building entity){
|
||||
// BulletType type = ammoTypes.get(entity.liquids.current());
|
||||
// return Math.min(amount * entity.edelta(), entity.block.liquidCapacity) / (type == null ? 1f : type.ammoMultiplier);
|
||||
//}
|
||||
});
|
||||
|
||||
super.init();
|
||||
|
||||
@@ -69,9 +69,9 @@ public class ItemTurret extends Turret{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valid(Building build){
|
||||
public float efficiency(Building build){
|
||||
//valid when there's any ammo in the turret
|
||||
return build instanceof ItemTurretBuild it && !it.ammo.isEmpty();
|
||||
return build instanceof ItemTurretBuild it && !it.ammo.isEmpty() ? 1f : 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -93,7 +93,7 @@ public class LaserTurret extends PowerTurret{
|
||||
return;
|
||||
}
|
||||
|
||||
if(reload <= 0 && (consValid() || cheating()) && !charging && shootWarmup >= minWarmup){
|
||||
if(reload <= 0 && (consValid || cheating()) && !charging && shootWarmup >= minWarmup){
|
||||
BulletType type = peekAmmo();
|
||||
|
||||
shoot(type);
|
||||
|
||||
@@ -69,9 +69,9 @@ public class PayloadTurret extends Turret{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valid(Building build){
|
||||
public float efficiency(Building build){
|
||||
//valid when there's any ammo in the turret
|
||||
return build instanceof PayloadTurretBuild it && it.payloads.any();
|
||||
return build instanceof PayloadTurretBuild it && it.payloads.any() ? 1f : 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -66,7 +66,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
int[] bits = getTiling(plan, list);
|
||||
|
||||
if(bits == null) return;
|
||||
|
||||
@@ -48,13 +48,13 @@ public class DirectionBridge extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(dirRegion, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestConfigTop(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanConfigTop(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
otherReq = null;
|
||||
otherDst = range;
|
||||
Point2 d = Geometry.d4(plan.rotation);
|
||||
|
||||
@@ -47,15 +47,15 @@ public class DirectionalUnloader extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(topRegion, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
drawRequestConfig(plan, list);
|
||||
drawPlanConfig(plan, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestConfig(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawRequestConfigCenter(plan, plan.config, "duct-unloader-center");
|
||||
public void drawPlanConfig(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawPlanConfigCenter(plan, plan.config, "duct-unloader-center");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -50,7 +50,7 @@ public class Duct extends Block implements Autotiler{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
int[] bits = getTiling(plan, list);
|
||||
|
||||
if(bits == null) return;
|
||||
|
||||
@@ -53,7 +53,7 @@ public class DuctRouter extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(topRegion, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ItemBridge extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestConfigTop(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanConfigTop(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
otherReq = null;
|
||||
list.each(other -> {
|
||||
if(other.block == this && plan != other && plan.config instanceof Point2 p && p.equals(other.x - plan.x, other.y - plan.y)){
|
||||
|
||||
@@ -153,7 +153,7 @@ public class MassDriver extends Block{
|
||||
}
|
||||
|
||||
//skip when there's no power
|
||||
if(!consValid()){
|
||||
if(!consValid){
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ public class MassDriver extends Block{
|
||||
}
|
||||
|
||||
protected boolean shooterValid(Building other){
|
||||
return other instanceof MassDriverBuild entity && other.isValid() && other.consValid() && entity.block == block && entity.link == pos() && within(other, range);
|
||||
return other instanceof MassDriverBuild entity && other.isValid() && other.consValid && entity.block == block && entity.link == pos() && within(other, range);
|
||||
}
|
||||
|
||||
protected boolean linkValid(){
|
||||
|
||||
@@ -43,7 +43,7 @@ public class OverflowDuct extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(topRegion, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ public class Sorter extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestConfig(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawRequestConfigCenter(plan, plan.config, "center", true);
|
||||
public void drawPlanConfig(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawPlanConfigCenter(plan, plan.config, "center", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -84,7 +84,7 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
int[] bits = getTiling(plan, list);
|
||||
|
||||
if(bits == null) return;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class HeatConductor extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawer.drawPlan(this, plan, list);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class HeatProducer extends GenericCrafter{
|
||||
super.updateTile();
|
||||
|
||||
//heat approaches target at the same speed regardless of efficiency
|
||||
heat = Mathf.approachDelta(heat, heatOutput * efficiency() * Mathf.num(consValid()), warmupRate * delta());
|
||||
heat = Mathf.approachDelta(heat, heatOutput * efficiency() * Mathf.num(consValid), warmupRate * delta());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -97,7 +97,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
int[] bits = getTiling(plan, list);
|
||||
|
||||
if(bits == null) return;
|
||||
|
||||
@@ -484,7 +484,7 @@ public class LogicBlock extends Block{
|
||||
}
|
||||
|
||||
if(enabled && executor.initialized()){
|
||||
accumulator += edelta() * ipt * (consValid() ? 1 : 0);
|
||||
accumulator += edelta() * ipt * (consValid ? 1 : 0);
|
||||
|
||||
if(accumulator > maxInstructionScale * ipt) accumulator = maxInstructionScale * ipt;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public abstract class BlockProducer extends PayloadBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(outRegion, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
Draw.rect(topRegion, plan.drawx(), plan.drawy());
|
||||
@@ -88,7 +88,7 @@ public abstract class BlockProducer extends PayloadBlock{
|
||||
public void updateTile(){
|
||||
super.updateTile();
|
||||
var recipe = recipe();
|
||||
boolean produce = recipe != null && consValid() && payload == null;
|
||||
boolean produce = recipe != null && consValid && payload == null;
|
||||
|
||||
if(produce){
|
||||
progress += buildSpeed * edelta();
|
||||
|
||||
@@ -60,7 +60,7 @@ public class PayloadLoader extends PayloadBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(inRegion, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
Draw.rect(outRegion, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
|
||||
@@ -88,7 +88,7 @@ public class PayloadMassDriver extends PayloadBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(baseRegion, plan.drawx(), plan.drawy());
|
||||
Draw.rect(topRegion, plan.drawx(), plan.drawy());
|
||||
Draw.rect(outRegion, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
@@ -188,7 +188,7 @@ public class PayloadMassDriver extends PayloadBlock{
|
||||
!(
|
||||
current instanceof PayloadDriverBuild entity &&
|
||||
current.isValid() &&
|
||||
entity.consValid() && entity.block == block &&
|
||||
entity.consValid && entity.block == block &&
|
||||
entity.link == pos() && within(current, range)
|
||||
)){
|
||||
waitingShooters.removeFirst();
|
||||
@@ -219,7 +219,7 @@ public class PayloadMassDriver extends PayloadBlock{
|
||||
}
|
||||
|
||||
//skip when there's no power
|
||||
if(!consValid()){
|
||||
if(!consValid){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ public class PayloadRouter extends PayloadConveyor{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
super.drawRequestRegion(plan, list);
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
super.drawPlanRegion(plan, list);
|
||||
|
||||
Draw.rect(overRegion, plan.drawx(), plan.drawy());
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class PayloadSource extends PayloadBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(outRegion, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
Draw.rect(topRegion, plan.drawx(), plan.drawy());
|
||||
|
||||
@@ -56,7 +56,7 @@ public class PayloadVoid extends PayloadBlock{
|
||||
@Override
|
||||
public void updateTile(){
|
||||
super.updateTile();
|
||||
if(moveInPayload(false) && consValid()){
|
||||
if(moveInPayload(false) && consValid){
|
||||
payload = null;
|
||||
incinerateEffect.at(this);
|
||||
incinerateSound.at(this);
|
||||
|
||||
@@ -70,25 +70,25 @@ public class ConsumeGenerator extends PowerGenerator{
|
||||
|
||||
public class ConsumeGeneratorBuild extends GeneratorBuild{
|
||||
public float warmup, totalTime;
|
||||
public float itemMultiplier = 1f;
|
||||
|
||||
@Override
|
||||
public void updateEfficiencyMultiplier(){
|
||||
if(filterItem != null){
|
||||
float m = filterItem.efficiencyMultiplier(this);
|
||||
if(m > 0) efficiencyMultiplier = m;
|
||||
}else if(filterLiquid != null){
|
||||
float m = filterLiquid.efficiencyMultiplier(this);
|
||||
if(m > 0) efficiencyMultiplier = m;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
boolean valid = consValid();
|
||||
boolean valid = consValid;
|
||||
|
||||
warmup = Mathf.lerpDelta(warmup, enabled && valid ? 1f : 0f, 0.05f);
|
||||
warmup = Mathf.lerpDelta(warmup, valid ? 1f : 0f, 0.05f);
|
||||
|
||||
float multiplier = 1f;
|
||||
if(valid){
|
||||
if(filterItem != null && filterItem.getConsumed(this) != null){
|
||||
itemMultiplier = filterItem.efficiency(this);
|
||||
}
|
||||
|
||||
//efficiency is added together
|
||||
multiplier *= (itemMultiplier + (filterLiquid == null ? 0f : filterLiquid.efficiency(this)));
|
||||
}
|
||||
|
||||
productionEfficiency = (valid ? 1f : 0f) * multiplier;
|
||||
productionEfficiency = efficiency * efficiencyMultiplier;
|
||||
totalTime += warmup * Time.delta;
|
||||
|
||||
//randomly produce the effect
|
||||
@@ -97,7 +97,7 @@ public class ConsumeGenerator extends PowerGenerator{
|
||||
}
|
||||
|
||||
//take in items periodically
|
||||
if(hasItems && valid && generateTime <= 0f && items.any()){
|
||||
if(hasItems && valid && generateTime <= 0f){
|
||||
consume();
|
||||
consumeEffect.at(x + Mathf.range(generateEffectRange), y + Mathf.range(generateEffectRange));
|
||||
generateTime = 1f;
|
||||
@@ -110,7 +110,7 @@ public class ConsumeGenerator extends PowerGenerator{
|
||||
}
|
||||
|
||||
//generation time always goes down, but only at the end so consumeTriggerValid doesn't assume fake items
|
||||
generateTime -= Math.min(1f / itemDuration * delta(), generateTime);
|
||||
generateTime -= delta() / itemDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ImpactReactor extends PowerGenerator{
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
if(consValid() && power.status >= 0.99f){
|
||||
if(consValid && power.status >= 0.99f){
|
||||
boolean prevOut = getPowerProduction() <= consPower.requestedPower(this);
|
||||
|
||||
warmup = Mathf.lerpDelta(warmup, 1f, warmupSpeed * timeScale);
|
||||
|
||||
@@ -35,7 +35,7 @@ public class PowerDiode extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(fullIcon, plan.drawx(), plan.drawy());
|
||||
Draw.rect(arrow, plan.drawx(), plan.drawy(), !rotate ? 0 : plan.rotation * 90);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class PowerGenerator extends PowerDistributor{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawer.drawPlan(this, plan, list);
|
||||
}
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ public class PowerNode extends PowerBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestConfigTop(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanConfigTop(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
if(plan.config instanceof Point2[] ps){
|
||||
setupColor(1f);
|
||||
for(Point2 point : ps){
|
||||
|
||||
@@ -93,7 +93,7 @@ public class BeamDrill extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(topRegion, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
}
|
||||
@@ -213,7 +213,7 @@ public class BeamDrill extends Block{
|
||||
|
||||
if(lasers[0] == null) updateLasers();
|
||||
|
||||
warmup = Mathf.approachDelta(warmup, Mathf.num(consValid()), 1f / 60f);
|
||||
warmup = Mathf.approachDelta(warmup, Mathf.num(consValid), 1f / 60f);
|
||||
lastItem = null;
|
||||
boolean multiple = false;
|
||||
int dx = Geometry.d4x(rotation), dy = Geometry.d4y(rotation), facingAmount = 0;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class BurstDrill extends Drill{
|
||||
|
||||
smoothProgress = Mathf.lerpDelta(smoothProgress, progress / (drillTime - 20f), 0.1f);
|
||||
|
||||
if(items.total() <= itemCapacity - dominantItems && dominantItems > 0 && consValid()){
|
||||
if(items.total() <= itemCapacity - dominantItems && dominantItems > 0 && consValid){
|
||||
warmup = Mathf.approachDelta(warmup, progress / drillTime, 0.01f);
|
||||
|
||||
float speed = efficiency();
|
||||
|
||||
@@ -86,7 +86,7 @@ public class Drill extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestConfigTop(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanConfigTop(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
if(!plan.worldContext) return;
|
||||
Tile tile = plan.tile();
|
||||
if(tile == null) return;
|
||||
@@ -273,7 +273,7 @@ public class Drill extends Block{
|
||||
|
||||
timeDrilled += warmup * delta();
|
||||
|
||||
if(items.total() < itemCapacity && dominantItems > 0 && consValid()){
|
||||
if(items.total() < itemCapacity && dominantItems > 0 && consValid){
|
||||
|
||||
float speed = 1f;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Fracker extends SolidPump{
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
if(consValid()){
|
||||
if(consValid){
|
||||
if(accumulator >= itemUseTime){
|
||||
consume();
|
||||
accumulator -= itemUseTime;
|
||||
|
||||
@@ -119,7 +119,7 @@ public class GenericCrafter extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawer.drawPlan(this, plan, list);
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ public class GenericCrafter extends Block{
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
if(consValid()){
|
||||
if(consValid){
|
||||
|
||||
progress += getProgressIncrease(craftTime);
|
||||
warmup = Mathf.approachDelta(warmup, warmupTarget(), warmupSpeed);
|
||||
@@ -282,7 +282,7 @@ public class GenericCrafter extends Block{
|
||||
|
||||
@Override
|
||||
public boolean shouldAmbientSound(){
|
||||
return consValid();
|
||||
return consValid;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Incinerator extends Block{
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
heat = Mathf.approachDelta(heat, consValid() && efficiency() > 0.9f ? 1f : 0f, 0.04f);
|
||||
heat = Mathf.approachDelta(heat, consValid && efficiency() > 0.9f ? 1f : 0f, 0.04f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ItemIncinerator extends Block{
|
||||
|
||||
@Override
|
||||
public BlockStatus status(){
|
||||
return consValid() ? BlockStatus.active : BlockStatus.noInput;
|
||||
return consValid ? BlockStatus.active : BlockStatus.noInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,7 +62,7 @@ public class ItemIncinerator extends Block{
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return consValid();
|
||||
return consValid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public class Pump extends LiquidBlock{
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
if(consValid() && liquidDrop != null){
|
||||
if(consValid && liquidDrop != null){
|
||||
float maxPump = Math.min(liquidCapacity - liquids.get(liquidDrop), amount * pumpAmount * edelta());
|
||||
liquids.add(liquidDrop, maxPump);
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public class Separator extends Block{
|
||||
|
||||
@Override
|
||||
public boolean shouldAmbientSound(){
|
||||
return consValid();
|
||||
return consValid;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,7 +94,7 @@ public class Separator extends Block{
|
||||
public void updateTile(){
|
||||
totalProgress += warmup * delta();
|
||||
|
||||
if(consValid()){
|
||||
if(consValid){
|
||||
progress += getProgressIncrease(craftTime);
|
||||
warmup = Mathf.lerpDelta(warmup, 1f, 0.02f);
|
||||
}else{
|
||||
|
||||
@@ -121,7 +121,7 @@ public class SolidPump extends Pump{
|
||||
public void updateTile(){
|
||||
float fraction = Math.max(validTiles + boost + (attribute == null ? 0 : attribute.env()), 0);
|
||||
|
||||
if(consValid() && typeLiquid() < liquidCapacity - 0.001f){
|
||||
if(consValid && typeLiquid() < liquidCapacity - 0.001f){
|
||||
float maxPump = Math.min(liquidCapacity - typeLiquid(), pumpAmount * delta() * fraction * efficiency());
|
||||
liquids.add(result, maxPump);
|
||||
lastPump = maxPump / Time.delta;
|
||||
|
||||
@@ -82,7 +82,7 @@ public class WallCrafter extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(topRegion, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class WallCrafter extends Block{
|
||||
|
||||
boolean cons = shouldConsume();
|
||||
|
||||
warmup = Mathf.approachDelta(warmup, Mathf.num(consValid()), 1f / 40f);
|
||||
warmup = Mathf.approachDelta(warmup, Mathf.num(consValid), 1f / 40f);
|
||||
float dx = Geometry.d4x(rotation) * 0.5f, dy = Geometry.d4y(rotation) * 0.5f;
|
||||
|
||||
float eff = getEfficiency(tile.x, tile.y, rotation, dest -> {
|
||||
|
||||
@@ -46,8 +46,8 @@ public class ItemSource extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestConfig(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawRequestConfigCenter(plan, plan.config, "center", true);
|
||||
public void drawPlanConfig(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawPlanConfigCenter(plan, plan.config, "center", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,8 +46,8 @@ public class LiquidSource extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestConfig(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawRequestConfigCenter(plan, plan.config, "center", true);
|
||||
public void drawPlanConfig(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawPlanConfigCenter(plan, plan.config, "center", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,8 +47,8 @@ public class Unloader extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestConfig(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawRequestConfigCenter(plan, plan.config, "unloader-center");
|
||||
public void drawPlanConfig(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawPlanConfigCenter(plan, plan.config, "unloader-center");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Reconstructor extends UnitBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(inRegion, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
Draw.rect(outRegion, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
@@ -219,7 +219,7 @@ public class Reconstructor extends UnitBlock{
|
||||
moveOutPayload();
|
||||
}else{ //update progress
|
||||
if(moveInPayload()){
|
||||
if(consValid()){
|
||||
if(consValid){
|
||||
valid = true;
|
||||
progress += edelta() * state.rules.unitBuildSpeed(team);
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ public class RepairPoint extends Block{
|
||||
|
||||
boolean healed = false;
|
||||
|
||||
if(target != null && consValid()){
|
||||
if(target != null && consValid){
|
||||
float angle = Angles.angle(x, y, target.x + offset.x, target.y + offset.y);
|
||||
if(Angles.angleDist(angle, rotation) < 30f){
|
||||
healed = true;
|
||||
|
||||
@@ -106,7 +106,7 @@ public class UnitAssembler extends PayloadBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(plan.rotation >= 2 ? sideRegion2 : sideRegion1, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
Draw.rect(topRegion, plan.drawx(), plan.drawy());
|
||||
@@ -261,7 +261,7 @@ public class UnitAssembler extends PayloadBlock{
|
||||
@Override
|
||||
public boolean shouldConsume(){
|
||||
//liquid is only consumed when building is being done
|
||||
return enabled && !wasOccupied && Units.canCreate(team, plan().unit) && consPayload.valid(this);
|
||||
return enabled && !wasOccupied && Units.canCreate(team, plan().unit) && consPayload.efficiency(this) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -375,7 +375,7 @@ public class UnitAssembler extends PayloadBlock{
|
||||
var plan = plan();
|
||||
|
||||
//check if all requirements are met
|
||||
if(!wasOccupied && consValid() && Units.canCreate(team, plan.unit)){
|
||||
if(!wasOccupied && consValid && Units.canCreate(team, plan.unit)){
|
||||
warmup = Mathf.lerpDelta(warmup, efficiency(), 0.1f);
|
||||
|
||||
if((progress += edelta() * eff / plan.time) >= 1f){
|
||||
@@ -523,7 +523,7 @@ public class UnitAssembler extends PayloadBlock{
|
||||
|
||||
/** @return true if this block is ready to produce units, e.g. requirements met */
|
||||
public boolean ready(){
|
||||
return consValid() && !wasOccupied;
|
||||
return consValid && !wasOccupied;
|
||||
}
|
||||
|
||||
public void yeetPayload(Payload payload){
|
||||
|
||||
@@ -44,7 +44,7 @@ public class UnitAssemblerModule extends PayloadBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(plan.rotation >= 2 ? sideRegion2 : sideRegion1, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
Draw.rect(topRegion, plan.drawx(), plan.drawy());
|
||||
@@ -128,7 +128,7 @@ public class UnitAssemblerModule extends PayloadBlock{
|
||||
findLink();
|
||||
}
|
||||
|
||||
if(moveInPayload() && link != null && link.moduleFits(block, x, y, rotation) && !link.wasOccupied && link.acceptPayload(this, payload) && consValid()){
|
||||
if(moveInPayload() && link != null && link.moduleFits(block, x, y, rotation) && !link.wasOccupied && link.acceptPayload(this, payload) && consValid){
|
||||
link.yeetPayload(payload);
|
||||
payload = null;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public class UnitFactory extends UnitBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(outRegion, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
Draw.rect(topRegion, plan.drawx(), plan.drawy());
|
||||
@@ -244,7 +244,7 @@ public class UnitFactory extends UnitBlock{
|
||||
currentPlan = -1;
|
||||
}
|
||||
|
||||
if(consValid() && currentPlan != -1){
|
||||
if(consValid && currentPlan != -1){
|
||||
time += edelta() * speedScl * Vars.state.rules.unitBuildSpeed(team);
|
||||
progress += edelta() * Vars.state.rules.unitBuildSpeed(team);
|
||||
speedScl = Mathf.lerpDelta(speedScl, 1f, 0.05f);
|
||||
@@ -263,7 +263,7 @@ public class UnitFactory extends UnitBlock{
|
||||
return;
|
||||
}
|
||||
|
||||
if(progress >= plan.time && consValid()){
|
||||
if(progress >= plan.time && consValid){
|
||||
progress %= 1f;
|
||||
|
||||
Unit unit = plan.unit.create(team);
|
||||
|
||||
Reference in New Issue
Block a user