An experiment

This commit is contained in:
Anuken
2021-10-20 10:45:15 -04:00
parent a21f6d335f
commit 4436a5ced9
10 changed files with 55 additions and 9 deletions

View File

@@ -120,6 +120,8 @@ public class Block extends UnlockableContent{
public boolean autoResetEnabled = true;
/** if true, the block stops updating when disabled */
public boolean noUpdateDisabled = false;
/** if true, this block updates when a payload of a unit. Currently unused! */
public boolean updateInUnits = true;
/** Whether to use this block's color in the minimap. Only used for overlays. */
public boolean useColor = true;
/** item that drops from this block, used for drills */

View File

@@ -31,6 +31,7 @@ public class BaseTurret extends Block{
priority = TargetPriority.turret;
group = BlockGroup.turrets;
flags = EnumSet.of(BlockFlag.turret);
updateInUnits = false;
}
@Override

View File

@@ -127,7 +127,7 @@ public class PayloadConveyor extends Block{
if(!enabled) return;
if(item != null){
item.update();
item.update(false);
}
lastInterp = curInterp;

View File

@@ -37,7 +37,9 @@ public class BuildPayload implements Payload{
}
@Override
public void update(){
public void update(boolean inUnit){
if(inUnit && !build.block.updateInUnits) return;
if(build.tile == null) build.tile = emptyTile;
build.update();
}

View File

@@ -36,8 +36,9 @@ public interface Payload extends Position{
/** @return the time taken to build this payload. */
float buildTime();
/** update this payload if it is a block */
default void update(){}
/** update this payload if it is a block
* @param inUnit whether this payload is in a unit */
default void update(boolean inUnit){}
/** @return whether this payload was dumped. */
default boolean dump(){

View File

@@ -138,7 +138,7 @@ public class PayloadBlock extends Block{
@Override
public void updateTile(){
if(payload != null){
payload.update();
payload.update(false);
}
}

View File

@@ -49,6 +49,7 @@ public class NuclearReactor extends PowerGenerator{
public NuclearReactor(String name){
super(name);
updateInUnits = false;
itemCapacity = 30;
liquidCapacity = 30;
hasItems = true;
@@ -138,7 +139,7 @@ public class NuclearReactor extends PowerGenerator{
if((fuel < 5 && heat < 0.5f) || !state.rules.reactorExplosions) return;
Effect.shake(6f, 16f, x, y);
Damage.damage(x, y, explosionRadius * tilesize, explosionDamage * 4);
Damage.damage(x, y, explosionRadius * tilesize * (float)(fuel / itemCapacity), explosionDamage * 4);
explodeEffect.at(x, y);
}

View File

@@ -280,6 +280,13 @@ public class PowerGraph{
}
}
public void clear(){
all.clear();
producers.clear();
consumers.clear();
batteries.clear();
}
public void reflow(Building tile){
queue.clear();
queue.addLast(tile);

View File

@@ -68,7 +68,8 @@ public class ConsumePower extends Consume{
* @return The amount of power which is requested per tick.
*/
public float requestedPower(Building entity){
if(entity.tile == null || entity.tile.build == null) return 0f;
if(entity == null) return 0f;
if(buffered){
return (1f-entity.power.status)*capacity;
}else{