mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-10 07:07:03 +07:00
Fixed some tests failing
This commit is contained in:
parent
671823b4fa
commit
6b074ed4b2
@ -159,6 +159,9 @@ public class Vars{
|
||||
Version.init();
|
||||
|
||||
content = new ContentLoader();
|
||||
if(!headless){
|
||||
content.setVerbose();
|
||||
}
|
||||
|
||||
playerGroup = Entities.addGroup(Player.class).enableMapping();
|
||||
tileGroup = Entities.addGroup(TileEntity.class, false);
|
||||
|
@ -34,7 +34,7 @@ import static io.anuke.arc.Core.files;
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ContentLoader{
|
||||
private boolean loaded = false;
|
||||
private boolean verbose = true;
|
||||
private boolean verbose = false;
|
||||
|
||||
private ObjectMap<String, MappableContent>[] contentNameMap = new ObjectMap[ContentType.values().length];
|
||||
private Array<Content>[] contentMap = new Array[ContentType.values().length];
|
||||
@ -57,6 +57,10 @@ public class ContentLoader{
|
||||
new LegacyColorMapper(),
|
||||
};
|
||||
|
||||
public void setVerbose(){
|
||||
verbose = true;
|
||||
}
|
||||
|
||||
/**Creates all content types.*/
|
||||
public void load(){
|
||||
if(loaded){
|
||||
|
@ -106,7 +106,7 @@ public class PowerGraph{
|
||||
|
||||
public float chargeBatteries(float excess){
|
||||
float capacity = getBatteryCapacity();
|
||||
if(Mathf.isEqual(capacity, 0f)){ return 0f; }
|
||||
if(Mathf.isEqual(capacity, 0f)) return 0f;
|
||||
|
||||
for(Tile battery : batteries){
|
||||
Consumers consumes = battery.block().consumes;
|
||||
@ -123,7 +123,7 @@ public class PowerGraph{
|
||||
|
||||
public void distributePower(float needed, float produced){
|
||||
//distribute even if not needed. this is because some might be requiring power but not requesting it; it updates consumers
|
||||
float coverage = Math.min(1, produced / (Mathf.isZero(needed) ? 1f : needed));
|
||||
float coverage = Mathf.isZero(needed) ? 1f : Math.min(1, produced / needed);
|
||||
for(Tile consumer : consumers){
|
||||
Consumers consumes = consumer.block().consumes;
|
||||
if(consumes.has(ConsumePower.class)){
|
||||
|
@ -16,13 +16,13 @@ public class DirectConsumerTests extends PowerTestFixture{
|
||||
|
||||
@Test
|
||||
void noPowerRequestedWithNoItems(){
|
||||
testUnitFactory(0, 0, 0.08f, 0.08f, 0f);
|
||||
testUnitFactory(0, 0, 0.08f, 0.08f, 1f);
|
||||
}
|
||||
|
||||
@Test
|
||||
void noPowerRequestedWithInsufficientItems(){
|
||||
testUnitFactory(30, 0, 0.08f, 0.08f, 0f);
|
||||
testUnitFactory(0, 30, 0.08f, 0.08f, 0f);
|
||||
testUnitFactory(30, 0, 0.08f, 0.08f, 1f);
|
||||
testUnitFactory(0, 30, 0.08f, 0.08f, 1f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user