More cleanup

This commit is contained in:
Anuken
2020-02-03 20:24:49 -05:00
parent 88d2ec5be8
commit a942ed2cad
141 changed files with 2213 additions and 1819 deletions

View File

@@ -143,12 +143,12 @@ public class ApplicationTests{
void blockInventories(){
multiblock();
Tile tile = world.tile(4, 4);
tile.entity.items.add(Items.coal, 5);
tile.entity.items.add(Items.titanium, 50);
assertEquals(tile.entity.items.total(), 55);
tile.entity.items.remove(Items.phasefabric, 10);
tile.entity.items.remove(Items.titanium, 10);
assertEquals(tile.entity.items.total(), 45);
tile.entity.getItems().add(Items.coal, 5);
tile.entity.getItems().add(Items.titanium, 50);
assertEquals(tile.entity.getItems().total(), 55);
tile.entity.getItems().remove(Items.phasefabric, 10);
tile.entity.getItems().remove(Items.titanium, 10);
assertEquals(tile.entity.getItems().total(), 45);
}
@Test
@@ -224,7 +224,7 @@ public class ApplicationTests{
world.tile(0, 0).setBlock(Blocks.itemSource);
world.tile(0, 0).configureAny(Items.copper.id);
Array<TileEntity> entities = Array.with(world.tile(0, 0).entity);
Array<Tilec> entities = Array.with(world.tile(0, 0).entity);
for(int i = 0; i < length; i++){
world.tile(i + 1, 0).setBlock(Blocks.conveyor);
@@ -246,12 +246,12 @@ public class ApplicationTests{
//warmup
for(int i = 0; i < 100000; i++){
entities.each(TileEntity::update);
entities.each(Tilec::update);
}
Time.mark();
for(int i = 0; i < 200000; i++){
entities.each(TileEntity::update);
entities.each(Tilec::update);
}
Log.info(Time.elapsed() + "ms to process " + items[0] + " items");
assertTrue(items[0] > 0);
@@ -422,7 +422,7 @@ public class ApplicationTests{
Tile core = world.tile(5, 5);
core.set(Blocks.coreShard, Team.sharded);
for(Item item : content.items()){
core.entity.items.set(item, 3000);
core.entity.getItems().set(item, 3000);
}
assertEquals(core.entity, state.teams.get(Team.sharded).core());
@@ -439,12 +439,12 @@ public class ApplicationTests{
assertEquals(capacity - 1, deposited);
tile.block().handleStack(item, capacity - 1, tile, unit);
assertEquals(tile.entity.items.get(item), capacity - 1);
assertEquals(tile.entity.getItems().get(item), capacity - 1);
int overflow = tile.block().acceptStack(item, 10, tile, unit);
assertEquals(1, overflow);
tile.block().handleStack(item, 1, tile, unit);
assertEquals(capacity, tile.entity.items.get(item));
assertEquals(capacity, tile.entity.getItems().get(item));
}
}

View File

@@ -37,8 +37,8 @@ public class DirectConsumerTests extends PowerTestFixture{
consumes.power(requestedPower);
consumes.items(new ItemStack(Items.silicon, 30), new ItemStack(Items.lead, 30));
}});
consumerTile.entity.items.add(Items.silicon, siliconAmount);
consumerTile.entity.items.add(Items.lead, leadAmount);
consumertile.entity.getItems().add(Items.silicon, siliconAmount);
consumertile.entity.getItems().add(Items.lead, leadAmount);
Tile producerTile = createFakeTile(2, 0, createFakeProducerBlock(producedPower));
producerTile.<PowerGenerator.GeneratorEntity>ent().productionEfficiency = 1f;
@@ -50,6 +50,6 @@ public class DirectConsumerTests extends PowerTestFixture{
consumerTile.entity.update();
graph.update();
assertEquals(expectedSatisfaction, consumerTile.entity.power.status);
assertEquals(expectedSatisfaction, consumertile.entity.getPower().status);
}
}

View File

@@ -87,13 +87,13 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
createGenerator(inputType);
assertTrue(generator.acceptLiquid(tile, null, liquid, availableLiquidAmount), inputType + " | " + parameterDescription + ": Liquids which will be declined by the generator don't need to be tested - The code won't be called for those cases.");
entity.liquids.add(liquid, availableLiquidAmount);
entity.getLiquids().add(liquid, availableLiquidAmount);
entity.cons.update();
// Perform an update on the generator once - This should use up any resource up to the maximum liquid usage
generator.update(tile);
assertEquals(expectedRemainingLiquidAmount, entity.liquids.get(liquid), inputType + " | " + parameterDescription + ": Remaining liquid amount mismatch.");
assertEquals(expectedRemainingLiquidAmount, entity.getLiquids().get(liquid), inputType + " | " + parameterDescription + ": Remaining liquid amount mismatch.");
assertEquals(expectedEfficiency, entity.productionEfficiency, inputType + " | " + parameterDescription + ": Efficiency mismatch.");
}
@@ -130,7 +130,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
assertTrue(generator.acceptItem(item, tile, null), inputType + " | " + parameterDescription + ": Items which will be declined by the generator don't need to be tested - The code won't be called for those cases.");
if(amount > 0){
entity.items.add(item, amount);
entity.getItems().add(item, amount);
}
entity.cons.update();
@@ -138,7 +138,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
try{
generator.update(tile);
assertEquals(expectedRemainingItemAmount, entity.items.get(item), inputType + " | " + parameterDescription + ": Remaining item amount mismatch.");
assertEquals(expectedRemainingItemAmount, entity.getItems().get(item), inputType + " | " + parameterDescription + ": Remaining item amount mismatch.");
assertEquals(expectedEfficiency, entity.productionEfficiency, inputType + " | " + parameterDescription + ": Efficiency mismatch.");
}catch(NullPointerException e){
e.printStackTrace();
@@ -162,7 +162,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
createGenerator(inputType);
// Burn a single coal and test for the duration
entity.items.add(Items.coal, 1);
entity.getItems().add(Items.coal, 1);
entity.cons.update();
generator.update(tile);

View File

@@ -87,19 +87,19 @@ public class PowerTestFixture{
// Simulate the "changed" method. Calling it through reflections would require half the game to be initialized.
tile.entity = block.newEntity().init(tile, false);
tile.entity.cons = new ConsumeModule(tile.entity);
if(block.hasItems) tile.entity.items = new ItemModule();
if(block.hasLiquids) tile.entity.liquids = new LiquidModule();
tile.entity.getCons() = new ConsumeModule(tile.entity);
if(block.hasItems) tile.entity.getItems() = new ItemModule();
if(block.hasLiquids) tile.entity.getLiquids() = new LiquidModule();
if(block.hasPower){
tile.entity.power = new PowerModule();
tile.entity.power.graph = new PowerGraph(){
tile.entity.getPower() = new PowerModule();
tile.entity.getPower().graph = new PowerGraph(){
//assume there's always something consuming power
@Override
public float getUsageFraction(){
return 1f;
}
};
tile.entity.power.graph.add(tile);
tile.entity.getPower().graph.add(tile);
}
// Assign incredibly high health so the block does not get destroyed on e.g. burning Blast Compound

View File

@@ -66,7 +66,7 @@ public class PowerTests extends PowerTestFixture{
// Update and check for the expected power status of the consumer
powerGraph.update();
assertEquals(expectedSatisfaction, directConsumerTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Satisfaction of direct consumer did not match");
assertEquals(expectedSatisfaction, directConsumertile.entity.getPower().status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Satisfaction of direct consumer did not match");
}
/**
@@ -104,14 +104,14 @@ public class PowerTests extends PowerTestFixture{
}
float maxCapacity = 100f;
Tile batteryTile = createFakeTile(0, 2, createFakeBattery(maxCapacity));
batteryTile.entity.power.status = initialBatteryCapacity / maxCapacity;
batterytile.entity.getPower().status = initialBatteryCapacity / maxCapacity;
powerGraph.add(batteryTile);
powerGraph.update();
assertEquals(expectedBatteryCapacity / maxCapacity, batteryTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Expected battery status did not match");
assertEquals(expectedBatteryCapacity / maxCapacity, batterytile.entity.getPower().status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Expected battery status did not match");
if(directConsumerTile != null){
assertEquals(expectedSatisfaction, directConsumerTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Satisfaction of direct consumer did not match");
assertEquals(expectedSatisfaction, directConsumertile.entity.getPower().status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Satisfaction of direct consumer did not match");
}
}
@@ -127,13 +127,13 @@ public class PowerTests extends PowerTestFixture{
powerGraph.add(consumerTile);
powerGraph.update();
assertEquals(1.0f, consumerTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR);
assertEquals(1.0f, consumertile.entity.getPower().status, Mathf.FLOAT_ROUNDING_ERROR);
powerGraph.remove(producerTile);
powerGraph.add(consumerTile);
powerGraph.update();
assertEquals(0.0f, consumerTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR);
assertEquals(0.0f, consumertile.entity.getPower().status, Mathf.FLOAT_ROUNDING_ERROR);
if(consumerTile.block().consumes.hasPower()){
ConsumePower consumePower = consumerTile.block().consumes.getPower();
assertFalse(consumePower.valid(consumerTile.ent()));