mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-03 13:30:25 +07:00
Bugfixes
This commit is contained in:
parent
8c6c4c2630
commit
66766b43c7
Before Width: | Height: | Size: 112 B After Width: | Height: | Size: 112 B |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
@ -749,6 +749,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
||||
dead = true;
|
||||
target = null;
|
||||
moveTarget = null;
|
||||
spawner = lastSpawner = null;
|
||||
health = maxHealth();
|
||||
boostHeat = drownTime = hitTime = 0f;
|
||||
mech = (isMobile ? Mechs.starterMobile : Mechs.starterDesktop);
|
||||
|
@ -128,17 +128,19 @@ public class PowerGraph{
|
||||
Consumers consumes = consumer.block().consumes;
|
||||
if(consumes.has(ConsumePower.class)){
|
||||
ConsumePower consumePower = consumes.get(ConsumePower.class);
|
||||
if(!otherConsumersAreValid(consumer, consumePower)){
|
||||
consumer.entity.power.satisfaction = 0.0f; // Only supply power if the consumer would get valid that way
|
||||
//if(!otherConsumersAreValid(consumer, consumePower)){
|
||||
// consumer.entity.power.satisfaction = 0.0f; // Only supply power if the consumer would get valid that way
|
||||
//}else{
|
||||
|
||||
//currently satisfies power even if it's not required yet
|
||||
if(consumePower.isBuffered){
|
||||
// Add an equal percentage of power to all buffers, based on the global power coverage in this graph
|
||||
float maximumRate = consumePower.requestedPower(consumer.block(), consumer.entity()) * coverage * consumer.entity.delta();
|
||||
consumer.entity.power.satisfaction = Mathf.clamp(consumer.entity.power.satisfaction + maximumRate / consumePower.powerCapacity);
|
||||
}else{
|
||||
if(consumePower.isBuffered){
|
||||
// Add an equal percentage of power to all buffers, based on the global power coverage in this graph
|
||||
float maximumRate = consumePower.requestedPower(consumer.block(), consumer.entity()) * coverage * consumer.entity.delta();
|
||||
consumer.entity.power.satisfaction = Mathf.clamp(consumer.entity.power.satisfaction + maximumRate / consumePower.powerCapacity);
|
||||
}else{
|
||||
consumer.entity.power.satisfaction = coverage;
|
||||
}
|
||||
consumer.entity.power.satisfaction = coverage;
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -246,14 +248,12 @@ public class PowerGraph{
|
||||
}
|
||||
}
|
||||
|
||||
//currently ignores all other consumers and consumes power anyway.
|
||||
private boolean otherConsumersAreValid(Tile tile, Consume consumePower){
|
||||
/*
|
||||
for(Consume cons : tile.block().consumes.all()){
|
||||
if(cons != consumePower && !cons.isOptional() && !cons.valid(tile.block(), tile.entity())){
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
public class IOTests{
|
||||
|
||||
@ -28,7 +29,7 @@ public class IOTests{
|
||||
ByteBuffer buffer = ByteBuffer.allocate(500);
|
||||
TypeIO.writeString(buffer, null);
|
||||
buffer.position(0);
|
||||
assertEquals(TypeIO.readString(buffer), null);
|
||||
assertNull(TypeIO.readString(buffer));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,13 +16,13 @@ public class DirectConsumerTests extends PowerTestFixture{
|
||||
|
||||
@Test
|
||||
void noPowerRequestedWithNoItems(){
|
||||
testUnitFactory(0, 0, 0.08f, 0.08f, 1f);
|
||||
testUnitFactory(0, 0, 0.08f, 0.08f, 0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
void noPowerRequestedWithInsufficientItems(){
|
||||
testUnitFactory(30, 0, 0.08f, 0.08f, 1f);
|
||||
testUnitFactory(0, 30, 0.08f, 0.08f, 1f);
|
||||
testUnitFactory(30, 0, 0.08f, 0.08f, 0f);
|
||||
testUnitFactory(0, 30, 0.08f, 0.08f, 0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -89,7 +89,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
||||
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.cons.update(tile.entity);
|
||||
entity.cons.update();
|
||||
assertTrue(entity.cons.valid());
|
||||
|
||||
// Perform an update on the generator once - This should use up any resource up to the maximum liquid usage
|
||||
@ -134,7 +134,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
||||
if(amount > 0){
|
||||
entity.items.add(item, amount);
|
||||
}
|
||||
entity.cons.update(tile.entity);
|
||||
entity.cons.update();
|
||||
assertTrue(entity.cons.valid());
|
||||
|
||||
// Perform an update on the generator once - This should use up one or zero items - dependent on if the item is accepted and available or not.
|
||||
@ -161,7 +161,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
||||
|
||||
// Burn a single coal and test for the duration
|
||||
entity.items.add(Items.coal, 1);
|
||||
entity.cons.update(tile.entity);
|
||||
entity.cons.update();
|
||||
generator.update(tile);
|
||||
|
||||
float expectedEfficiency = entity.productionEfficiency;
|
||||
|
@ -85,7 +85,7 @@ 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.cons = new ConsumeModule(tile.entity);
|
||||
if(block.hasItems) tile.entity.items = new ItemModule();
|
||||
if(block.hasLiquids) tile.entity.liquids = new LiquidModule();
|
||||
if(block.hasPower){
|
||||
|
Loading…
Reference in New Issue
Block a user