Fix block status of repair point and battery (#4187)

* Fix block status of repair point and battery

* Update Battery.java

* Update RepairPoint.java
This commit is contained in:
Patrick 'Quezler' Mounier
2020-12-30 21:30:49 +01:00
committed by GitHub
parent b672434e83
commit b79a6f6b32
3 changed files with 17 additions and 1 deletions

View File

@@ -358,6 +358,10 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
return power != null && (block.consumes.has(ConsumeType.power) && !block.consumes.getPower().buffered) ? power.status : 1f; return power != null && (block.consumes.has(ConsumeType.power) && !block.consumes.getPower().buffered) ? power.status : 1f;
} }
public BlockStatus status(){
return cons.status();
}
/** Call when nothing is happening to the entity. This increments the internal sleep timer. */ /** Call when nothing is happening to the entity. This increments the internal sleep timer. */
public void sleep(){ public void sleep(){
sleepTime += Time.delta; sleepTime += Time.delta;
@@ -812,7 +816,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
Draw.z(Layer.power + 1); Draw.z(Layer.power + 1);
Draw.color(Pal.gray); Draw.color(Pal.gray);
Fill.square(brcx, brcy, 2.5f, 45); Fill.square(brcx, brcy, 2.5f, 45);
Draw.color(cons.status().color); Draw.color(status().color);
Fill.square(brcx, brcy, 1.5f, 45); Fill.square(brcx, brcy, 1.5f, 45);
Draw.color(); Draw.color();
} }

View File

@@ -42,5 +42,12 @@ public class Battery extends PowerDistributor{
} }
} }
} }
@Override
public BlockStatus status(){
if(Mathf.equal(power.status, 0f, 0.01f)) return BlockStatus.noInput;
if(Mathf.equal(power.status, 1f, 0.01f)) return BlockStatus.active;
return BlockStatus.noOutput;
}
} }
} }

View File

@@ -118,5 +118,10 @@ public class RepairPoint extends Block{
public boolean shouldConsume(){ public boolean shouldConsume(){
return target != null && enabled; return target != null && enabled;
} }
@Override
public BlockStatus status(){
return Mathf.equal(efficiency(), 0f, 0.01f) ? BlockStatus.noInput : cons.status();
}
} }
} }