This commit is contained in:
Anuken
2020-08-19 10:35:24 -04:00
parent 7ebe84cc0e
commit 819835fbc0
11 changed files with 34 additions and 12 deletions

View File

@@ -45,6 +45,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
static final ObjectSet<Building> tmpTiles = new ObjectSet<>(); static final ObjectSet<Building> tmpTiles = new ObjectSet<>();
static final Seq<Building> tempTileEnts = new Seq<>(); static final Seq<Building> tempTileEnts = new Seq<>();
static final Seq<Tile> tempTiles = new Seq<>(); static final Seq<Tile> tempTiles = new Seq<>();
static final float timeToUncontrol = 60f * 4;
static int sleepingEntities = 0; static int sleepingEntities = 0;
@Import float x, y, health; @Import float x, y, health;
@@ -57,6 +58,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
transient byte dump; transient byte dump;
transient int rotation; transient int rotation;
transient boolean enabled = true; transient boolean enabled = true;
transient float enabledControlTime;
PowerModule power; PowerModule power;
ItemModule items; ItemModule items;
@@ -338,7 +340,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
public void created(){} public void created(){}
public boolean shouldConsume(){ public boolean shouldConsume(){
return true; return enabled;
} }
public boolean productionValid(){ public boolean productionValid(){
@@ -751,6 +753,16 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
public void drawSelect(){ public void drawSelect(){
} }
public void drawDisabled(){
Draw.color(Color.scarlet);
Draw.alpha(0.8f);
float size = 6f;
Draw.rect(Icon.cancel.getRegion(), x, y, size, size);
Draw.reset();
}
public void draw(){ public void draw(){
Draw.rect(block.region, x, y, block.rotate ? rotdeg() : 0); Draw.rect(block.region, x, y, block.rotate ? rotdeg() : 0);
@@ -1203,6 +1215,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
public void control(LAccess type, double p1, double p2, double p3, double p4){ public void control(LAccess type, double p1, double p2, double p3, double p4){
if(type == LAccess.enabled){ if(type == LAccess.enabled){
enabled = !Mathf.zero((float)p1); enabled = !Mathf.zero((float)p1);
enabledControlTime = timeToUncontrol;
} }
} }
@@ -1230,6 +1243,12 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
timeScale = 1f; timeScale = 1f;
} }
enabledControlTime -= Time.delta;
if(enabledControlTime <= 0){
enabled = true;
}
if(sound != null){ if(sound != null){
sound.update(x, y, shouldActiveSound()); sound.update(x, y, shouldActiveSound());
} }

View File

@@ -136,6 +136,9 @@ public class OverlayRenderer{
if(tile != null && tile.team() == player.team()){ if(tile != null && tile.team() == player.team()){
tile.drawSelect(); tile.drawSelect();
if(!tile.enabled){
tile.drawDisabled();
}
if(Core.input.keyDown(Binding.rotateplaced) && tile.block().rotate && tile.interactable(player.team())){ if(Core.input.keyDown(Binding.rotateplaced) && tile.block().rotate && tile.interactable(player.team())){
control.input.drawArrow(tile.block(), tile.tileX(), tile.tileY(), tile.rotation, true); control.input.drawArrow(tile.block(), tile.tileX(), tile.tileY(), tile.rotation, true);

View File

@@ -391,7 +391,7 @@ public class ItemBridge extends Block{
@Override @Override
public boolean shouldConsume(){ public boolean shouldConsume(){
return linkValid(tile, world.tile(link)); return linkValid(tile, world.tile(link)) && super.shouldConsume();
} }
@Override @Override

View File

@@ -217,7 +217,7 @@ public class Drill extends Block{
@Override @Override
public boolean shouldConsume(){ public boolean shouldConsume(){
return items.total() < itemCapacity; return items.total() < itemCapacity && super.shouldConsume();
} }
@Override @Override

View File

@@ -93,7 +93,7 @@ public class GenericCrafter extends Block{
if(outputItem != null && items.get(outputItem.item) >= itemCapacity){ if(outputItem != null && items.get(outputItem.item) >= itemCapacity){
return false; return false;
} }
return outputLiquid == null || !(liquids.get(outputLiquid.liquid) >= liquidCapacity - 0.001f); return (outputLiquid == null || !(liquids.get(outputLiquid.liquid) >= liquidCapacity - 0.001f)) && super.shouldConsume();
} }
@Override @Override

View File

@@ -108,7 +108,7 @@ public class Pump extends LiquidBlock{
@Override @Override
public boolean shouldConsume(){ public boolean shouldConsume(){
return liquidDrop != null && liquids.get(liquidDrop) < liquidCapacity - 0.01f; return liquidDrop != null && liquids.get(liquidDrop) < liquidCapacity - 0.01f && super.shouldConsume();
} }
@Override @Override

View File

@@ -71,7 +71,7 @@ public class Separator extends Block{
total -= items.get(stack.item); total -= items.get(stack.item);
} }
} }
return total < itemCapacity; return total < itemCapacity && super.shouldConsume();
} }
@Override @Override

View File

@@ -97,7 +97,7 @@ public class SolidPump extends Pump{
@Override @Override
public boolean shouldConsume(){ public boolean shouldConsume(){
return liquids.get(result) < liquidCapacity - 0.01f; return liquids.get(result) < liquidCapacity - 0.01f && super.shouldConsume();
} }
@Override @Override

View File

@@ -42,7 +42,7 @@ public abstract class StorageBlock extends Block{
@Override @Override
public boolean canPickup(){ public boolean canPickup(){
return linkedCore != null; return linkedCore == null;
} }
} }
} }

View File

@@ -115,7 +115,7 @@ public class RepairPoint extends Block{
@Override @Override
public boolean shouldConsume(){ public boolean shouldConsume(){
return target != null; return target != null && super.shouldConsume();
} }
} }
} }

View File

@@ -63,11 +63,11 @@ public class ConsumeModule extends BlockModule{
} }
public boolean valid(){ public boolean valid(){
return valid && entity.shouldConsume(); return valid && entity.shouldConsume() && entity.enabled;
} }
public boolean optionalValid(){ public boolean optionalValid(){
return valid() && optionalValid; return valid() && optionalValid && entity.enabled;
} }
@Override @Override