Bugfixes
This commit is contained in:
|
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;
|
dead = true;
|
||||||
target = null;
|
target = null;
|
||||||
moveTarget = null;
|
moveTarget = null;
|
||||||
|
spawner = lastSpawner = null;
|
||||||
health = maxHealth();
|
health = maxHealth();
|
||||||
boostHeat = drownTime = hitTime = 0f;
|
boostHeat = drownTime = hitTime = 0f;
|
||||||
mech = (isMobile ? Mechs.starterMobile : Mechs.starterDesktop);
|
mech = (isMobile ? Mechs.starterMobile : Mechs.starterDesktop);
|
||||||
|
|||||||
@@ -128,17 +128,19 @@ public class PowerGraph{
|
|||||||
Consumers consumes = consumer.block().consumes;
|
Consumers consumes = consumer.block().consumes;
|
||||||
if(consumes.has(ConsumePower.class)){
|
if(consumes.has(ConsumePower.class)){
|
||||||
ConsumePower consumePower = consumes.get(ConsumePower.class);
|
ConsumePower consumePower = consumes.get(ConsumePower.class);
|
||||||
if(!otherConsumersAreValid(consumer, consumePower)){
|
//if(!otherConsumersAreValid(consumer, consumePower)){
|
||||||
consumer.entity.power.satisfaction = 0.0f; // Only supply power if the consumer would get valid that way
|
// 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{
|
}else{
|
||||||
if(consumePower.isBuffered){
|
consumer.entity.power.satisfaction = coverage;
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,14 +248,12 @@ public class PowerGraph{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//currently ignores all other consumers and consumes power anyway.
|
|
||||||
private boolean otherConsumersAreValid(Tile tile, Consume consumePower){
|
private boolean otherConsumersAreValid(Tile tile, Consume consumePower){
|
||||||
/*
|
|
||||||
for(Consume cons : tile.block().consumes.all()){
|
for(Consume cons : tile.block().consumes.all()){
|
||||||
if(cons != consumePower && !cons.isOptional() && !cons.valid(tile.block(), tile.entity())){
|
if(cons != consumePower && !cons.isOptional() && !cons.valid(tile.block(), tile.entity())){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
public class IOTests{
|
public class IOTests{
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ public class IOTests{
|
|||||||
ByteBuffer buffer = ByteBuffer.allocate(500);
|
ByteBuffer buffer = ByteBuffer.allocate(500);
|
||||||
TypeIO.writeString(buffer, null);
|
TypeIO.writeString(buffer, null);
|
||||||
buffer.position(0);
|
buffer.position(0);
|
||||||
assertEquals(TypeIO.readString(buffer), null);
|
assertNull(TypeIO.readString(buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ public class DirectConsumerTests extends PowerTestFixture{
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void noPowerRequestedWithNoItems(){
|
void noPowerRequestedWithNoItems(){
|
||||||
testUnitFactory(0, 0, 0.08f, 0.08f, 1f);
|
testUnitFactory(0, 0, 0.08f, 0.08f, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void noPowerRequestedWithInsufficientItems(){
|
void noPowerRequestedWithInsufficientItems(){
|
||||||
testUnitFactory(30, 0, 0.08f, 0.08f, 1f);
|
testUnitFactory(30, 0, 0.08f, 0.08f, 0f);
|
||||||
testUnitFactory(0, 30, 0.08f, 0.08f, 1f);
|
testUnitFactory(0, 30, 0.08f, 0.08f, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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.");
|
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.liquids.add(liquid, availableLiquidAmount);
|
||||||
entity.cons.update(tile.entity);
|
entity.cons.update();
|
||||||
assertTrue(entity.cons.valid());
|
assertTrue(entity.cons.valid());
|
||||||
|
|
||||||
// Perform an update on the generator once - This should use up any resource up to the maximum liquid usage
|
// 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){
|
if(amount > 0){
|
||||||
entity.items.add(item, amount);
|
entity.items.add(item, amount);
|
||||||
}
|
}
|
||||||
entity.cons.update(tile.entity);
|
entity.cons.update();
|
||||||
assertTrue(entity.cons.valid());
|
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.
|
// 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
|
// Burn a single coal and test for the duration
|
||||||
entity.items.add(Items.coal, 1);
|
entity.items.add(Items.coal, 1);
|
||||||
entity.cons.update(tile.entity);
|
entity.cons.update();
|
||||||
generator.update(tile);
|
generator.update(tile);
|
||||||
|
|
||||||
float expectedEfficiency = entity.productionEfficiency;
|
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.
|
// 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 = 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.hasItems) tile.entity.items = new ItemModule();
|
||||||
if(block.hasLiquids) tile.entity.liquids = new LiquidModule();
|
if(block.hasLiquids) tile.entity.liquids = new LiquidModule();
|
||||||
if(block.hasPower){
|
if(block.hasPower){
|
||||||
|
|||||||
Reference in New Issue
Block a user