mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-27 06:51:30 -08:00
argh
This commit is contained in:
parent
eabc5c15c7
commit
fdf7c88083
228 changed files with 1219 additions and 1163 deletions
|
|
@ -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.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);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -243,8 +243,8 @@ public class ApplicationTests{
|
|||
|
||||
updateBlocks(10);
|
||||
|
||||
assertTrue(world.tile(2, 1).entity.liquids().currentAmount() >= 1);
|
||||
assertTrue(world.tile(2, 1).entity.liquids().current() == Liquids.water);
|
||||
assertTrue(world.tile(2, 1).entity.liquids.currentAmount() >= 1);
|
||||
assertTrue(world.tile(2, 1).entity.liquids.current() == Liquids.water);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -265,8 +265,8 @@ public class ApplicationTests{
|
|||
|
||||
updateBlocks(10);
|
||||
|
||||
assertTrue(tank.entity.liquids().currentAmount() >= 1, "Liquid not moved through junction");
|
||||
assertTrue(tank.entity.liquids().current() == Liquids.water, "Tank has no water");
|
||||
assertTrue(tank.entity.liquids.currentAmount() >= 1, "Liquid not moved through junction");
|
||||
assertTrue(tank.entity.liquids.current() == Liquids.water, "Tank has no water");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -300,9 +300,9 @@ public class ApplicationTests{
|
|||
|
||||
//test basic method.
|
||||
Rand r = new Rand(0);
|
||||
Tilec[] res = {null};
|
||||
Building[] res = {null};
|
||||
|
||||
Cons<Tilec> assigner = t -> res[0] = t;
|
||||
Cons<Building> assigner = t -> res[0] = t;
|
||||
|
||||
int iterations = 100;
|
||||
|
||||
|
|
@ -369,7 +369,7 @@ public class ApplicationTests{
|
|||
world.tile(0, 0).setBlock(Blocks.itemSource);
|
||||
world.tile(0, 0).entity.configureAny(Items.copper);
|
||||
|
||||
Seq<Tilec> entities = Seq.with(world.tile(0, 0).entity);
|
||||
Seq<Building> entities = Seq.with(world.tile(0, 0).entity);
|
||||
|
||||
for(int i = 0; i < length; i++){
|
||||
world.tile(i + 1, 0).setBlock(Blocks.conveyor);
|
||||
|
|
@ -380,29 +380,29 @@ public class ApplicationTests{
|
|||
world.tile(length + 1, 0).setBlock(new Block("___"){{
|
||||
hasItems = true;
|
||||
destructible = true;
|
||||
entityType = () -> new TileEntity(){
|
||||
entityType = () -> new Building(){
|
||||
@Override
|
||||
public void handleItem(Tilec source, Item item){
|
||||
public void handleItem(Building source, Item item){
|
||||
itemsa[0] ++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}});
|
||||
|
||||
entities.each(Tilec::updateProximity);
|
||||
entities.each(Building::updateProximity);
|
||||
|
||||
//warmup
|
||||
for(int i = 0; i < 100000; i++){
|
||||
entities.each(Tilec::update);
|
||||
entities.each(Building::update);
|
||||
}
|
||||
|
||||
Time.mark();
|
||||
for(int i = 0; i < 200000; i++){
|
||||
entities.each(Tilec::update);
|
||||
entities.each(Building::update);
|
||||
}
|
||||
Log.info(Time.elapsed() + "ms to process " + itemsa[0] + " items");
|
||||
assertNotEquals(0, itemsa[0]);
|
||||
|
|
@ -584,14 +584,14 @@ public class ApplicationTests{
|
|||
Tile core = world.tile(5, 5);
|
||||
core.setBlock(Blocks.coreShard, Team.sharded, 0);
|
||||
for(Item item : content.items()){
|
||||
core.entity.items().set(item, 3000);
|
||||
core.entity.items.set(item, 3000);
|
||||
}
|
||||
|
||||
assertEquals(core.entity, state.teams.get(Team.sharded).core());
|
||||
}
|
||||
|
||||
void depositTest(Block block, Item item){
|
||||
Unitc unit = UnitTypes.spirit.create(Team.derelict);
|
||||
Unit unit = UnitTypes.spirit.create(Team.derelict);
|
||||
Tile tile = new Tile(0, 0, Blocks.air, Blocks.air, block);
|
||||
int capacity = tile.block().itemCapacity;
|
||||
|
||||
|
|
@ -601,12 +601,12 @@ public class ApplicationTests{
|
|||
assertEquals(capacity - 1, deposited);
|
||||
|
||||
tile.entity.handleStack(item, capacity - 1, unit);
|
||||
assertEquals(tile.entity.items().get(item), capacity - 1);
|
||||
assertEquals(tile.entity.items.get(item), capacity - 1);
|
||||
|
||||
int overflow = tile.entity.acceptStack(item, 10, unit);
|
||||
assertEquals(1, overflow);
|
||||
|
||||
tile.entity.handleStack(item, 1, unit);
|
||||
assertEquals(capacity, tile.entity.items().get(item));
|
||||
assertEquals(capacity, tile.entity.items.get(item));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,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.items.add(Items.silicon, siliconAmount);
|
||||
consumerTile.entity.items.add(Items.lead, leadAmount);
|
||||
|
||||
Tile producerTile = createFakeTile(2, 0, createFakeProducerBlock(producedPower));
|
||||
producerTile.<PowerGenerator.GeneratorEntity>ent().productionEfficiency = 1f;
|
||||
|
|
@ -41,6 +41,6 @@ public class DirectConsumerTests extends PowerTestFixture{
|
|||
consumerTile.entity.update();
|
||||
graph.update();
|
||||
|
||||
assertEquals(expectedSatisfaction, consumerTile.entity.power().status);
|
||||
assertEquals(expectedSatisfaction, consumerTile.entity.power.status);
|
||||
}*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,13 +88,13 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
|||
createGenerator(inputType);
|
||||
assertTrue(entity.acceptLiquid(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.liquids.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
|
||||
entity.updateTile();
|
||||
|
||||
assertEquals(expectedRemainingLiquidAmount, entity.liquids().get(liquid), inputType + " | " + parameterDescription + ": Remaining liquid amount mismatch.");
|
||||
assertEquals(expectedRemainingLiquidAmount, entity.liquids.get(liquid), inputType + " | " + parameterDescription + ": Remaining liquid amount mismatch.");
|
||||
assertEquals(expectedEfficiency, entity.productionEfficiency, inputType + " | " + parameterDescription + ": Efficiency mismatch.");
|
||||
}
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
|||
assertTrue(entity.acceptItem(null, item), 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.items.add(item, amount);
|
||||
}
|
||||
entity.cons().update();
|
||||
|
||||
|
|
@ -139,7 +139,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
|||
try{
|
||||
entity.updateTile();
|
||||
|
||||
assertEquals(expectedRemainingItemAmount, entity.items().get(item), inputType + " | " + parameterDescription + ": Remaining item amount mismatch.");
|
||||
assertEquals(expectedRemainingItemAmount, entity.items.get(item), inputType + " | " + parameterDescription + ": Remaining item amount mismatch.");
|
||||
assertEquals(expectedEfficiency, entity.productionEfficiency, inputType + " | " + parameterDescription + ": Efficiency mismatch.");
|
||||
}catch(NullPointerException e){
|
||||
e.printStackTrace();
|
||||
|
|
@ -163,7 +163,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
|||
createGenerator(inputType);
|
||||
|
||||
// Burn a single coal and test for the duration
|
||||
entity.items().add(Items.coal, 1);
|
||||
entity.items.add(Items.coal, 1);
|
||||
entity.cons().update();
|
||||
entity.updateTile();
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class PowerTestFixture{
|
|||
|
||||
protected static Block createFakeDirectConsumer(float powerPerTick){
|
||||
return new PowerBlock("fakedirectconsumer"){{
|
||||
entityType = TileEntity::create;
|
||||
entityType = Building::create;
|
||||
consumes.power(powerPerTick);
|
||||
}};
|
||||
}
|
||||
|
|
@ -89,14 +89,14 @@ 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, Team.sharded, false);
|
||||
if(block.hasPower){
|
||||
tile.entity.power().graph = new PowerGraph(){
|
||||
tile.entity.power.graph = new PowerGraph(){
|
||||
//assume there's always something consuming power
|
||||
@Override
|
||||
public float getUsageFraction(){
|
||||
return 1f;
|
||||
}
|
||||
};
|
||||
tile.entity.power().graph.add(tile.entity);
|
||||
tile.entity.power.graph.add(tile.entity);
|
||||
}
|
||||
|
||||
// Assign incredibly high health so the block does not get destroyed on e.g. burning Blast Compound
|
||||
|
|
|
|||
|
|
@ -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.power.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.power.status = initialBatteryCapacity / maxCapacity;
|
||||
|
||||
powerGraph.add(batteryTile.entity);
|
||||
|
||||
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.power.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.power.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.entity);
|
||||
powerGraph.update();
|
||||
|
||||
assertEquals(1.0f, consumerTile.entity.power().status, Mathf.FLOAT_ROUNDING_ERROR);
|
||||
assertEquals(1.0f, consumerTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR);
|
||||
|
||||
powerGraph.remove(producerTile.entity);
|
||||
powerGraph.add(consumerTile.entity);
|
||||
powerGraph.update();
|
||||
|
||||
assertEquals(0.0f, consumerTile.entity.power().status, Mathf.FLOAT_ROUNDING_ERROR);
|
||||
assertEquals(0.0f, consumerTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR);
|
||||
if(consumerTile.block().consumes.hasPower()){
|
||||
ConsumePower consumePower = consumerTile.block().consumes.getPower();
|
||||
assertFalse(consumePower.valid(consumerTile.ent()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue