Sensor types
This commit is contained in:
@@ -17,6 +17,7 @@ public class Router extends Block{
|
||||
itemCapacity = 1;
|
||||
group = BlockGroup.transportation;
|
||||
unloadable = false;
|
||||
noUpdateDisabled = true;
|
||||
}
|
||||
|
||||
public class RouterEntity extends Building{
|
||||
|
||||
@@ -96,7 +96,7 @@ public class Sorter extends Block{
|
||||
if(dir == -1) return null;
|
||||
Building to;
|
||||
|
||||
if((item == sortItem) != invert){
|
||||
if(((item == sortItem) != invert) == enabled){
|
||||
//prevent 3-chains
|
||||
if(isSame(source) && isSame(nearby(dir))){
|
||||
return null;
|
||||
|
||||
@@ -13,6 +13,7 @@ import mindustry.entities.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.consumers.*;
|
||||
@@ -107,6 +108,12 @@ public class NuclearReactor extends PowerGenerator{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double sense(LSensor sensor){
|
||||
if(sensor == LSensor.heat) return heat;
|
||||
return super.sense(sensor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyed(){
|
||||
super.onDestroyed();
|
||||
|
||||
@@ -39,7 +39,7 @@ public class PowerDiode extends Block{
|
||||
|
||||
// battery % of the graph on either side, defaults to zero
|
||||
public float bar(Building tile){
|
||||
return (tile != null && tile.block().hasPower) ? tile.power.graph.getBatteryStored() / tile.power.graph.getTotalBatteryCapacity() : 0f;
|
||||
return (tile != null && tile.block().hasPower) ? tile.power.graph.getLastPowerStored() / tile.power.graph.getTotalBatteryCapacity() : 0f;
|
||||
}
|
||||
|
||||
public class PowerDiodeEntity extends Building{
|
||||
|
||||
@@ -19,7 +19,7 @@ public class PowerGraph{
|
||||
private final ObjectSet<Building> all = new ObjectSet<>();
|
||||
|
||||
private final WindowedMean powerBalance = new WindowedMean(60);
|
||||
private float lastPowerProduced, lastPowerNeeded, lastUsageFraction;
|
||||
private float lastPowerProduced, lastPowerNeeded, lastUsageFraction, lastPowerStored;
|
||||
|
||||
private long lastFrameUpdated = -1;
|
||||
private final int graphID;
|
||||
@@ -45,6 +45,10 @@ public class PowerGraph{
|
||||
return lastPowerProduced;
|
||||
}
|
||||
|
||||
public float getLastPowerStored(){
|
||||
return lastPowerStored;
|
||||
}
|
||||
|
||||
public float getSatisfaction(){
|
||||
if(Mathf.zero(lastPowerProduced)){
|
||||
return 0f;
|
||||
@@ -196,6 +200,7 @@ public class PowerGraph{
|
||||
|
||||
lastPowerNeeded = powerNeeded;
|
||||
lastPowerProduced = powerProduced;
|
||||
lastPowerStored = getBatteryStored();
|
||||
|
||||
powerBalance.add((lastPowerProduced - lastPowerNeeded) / Time.delta);
|
||||
|
||||
|
||||
@@ -109,9 +109,9 @@ public class PowerNode extends PowerBlock{
|
||||
|
||||
bars.add("batteries", entity -> new Bar(() ->
|
||||
Core.bundle.format("bar.powerstored",
|
||||
(UI.formatAmount((int)entity.power.graph.getBatteryStored())), UI.formatAmount((int)entity.power.graph.getTotalBatteryCapacity())),
|
||||
(UI.formatAmount((int)entity.power.graph.getLastPowerStored())), UI.formatAmount((int)entity.power.graph.getTotalBatteryCapacity())),
|
||||
() -> Pal.powerBar,
|
||||
() -> Mathf.clamp(entity.power.graph.getBatteryStored() / entity.power.graph.getTotalBatteryCapacity())));
|
||||
() -> Mathf.clamp(entity.power.graph.getLastPowerStored() / entity.power.graph.getTotalBatteryCapacity())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user