TODO cleanup / Test fixes

This commit is contained in:
Anuken 2019-02-08 16:29:10 -05:00
parent 66c27fab13
commit adf5189541
18 changed files with 43 additions and 71 deletions

View File

@ -73,7 +73,7 @@ public class StructAnnotationProcessor extends AbstractProcessor{
Class<?> structType = typeForSize(structSize);
//[constructor] get(fields...) : structType
MethodSpec.Builder constructor = MethodSpec.methodBuilder("get") //TODO 'get'..?
MethodSpec.Builder constructor = MethodSpec.methodBuilder("get")
.addModifiers(Modifier.STATIC, Modifier.PUBLIC)
.returns(structType);

View File

@ -17,8 +17,6 @@ import io.anuke.mindustry.world.meta.BlockFlag;
import static io.anuke.mindustry.Vars.*;
//TODO consider using quadtrees for finding specific types of blocks within an area
/**Class used for indexing special target blocks for AI.*/
@SuppressWarnings("unchecked")
public class BlockIndexer{

View File

@ -51,7 +51,7 @@ public class Blocks implements ContentList{
copperWall, copperWallLarge, titaniumWall, titaniumWallLarge, thoriumWall, thoriumWallLarge, door, doorLarge,
phaseWall, phaseWallLarge, surgeWall, surgeWallLarge, mendProjector, overdriveProjector, forceProjector, shockMine,
//transpor
//transport
conveyor, titaniumConveyor, distributor, junction, itemBridge, phaseConveyor, sorter, router, overflowGate, massDriver,
//liquids
@ -992,7 +992,7 @@ public class Blocks implements ContentList{
alwaysUnlocked = true;
health = 1100;
itemCapacity = 5000;
itemCapacity = 3000;
size = 3;
}};
@ -1000,7 +1000,7 @@ public class Blocks implements ContentList{
requirements(Category.effect, () -> false, ItemStack.with(Items.titanium, 4000, Items.silicon, 2000));
health = 2000;
itemCapacity = 8000;
itemCapacity = 6000;
size = 4;
}};
@ -1008,7 +1008,7 @@ public class Blocks implements ContentList{
requirements(Category.effect, () -> false, ItemStack.with(Items.titanium, 8000, Items.silicon, 4000, Items.surgealloy, 2000));
health = 4000;
itemCapacity = 12000;
itemCapacity = 10000;
size = 5;
}};

View File

@ -266,7 +266,7 @@ public class TechTree implements ContentList{
private TechNode node(Block block, Runnable children){
ItemStack[] requirements = new ItemStack[block.buildRequirements.length];
for(int i = 0; i < requirements.length; i++){
requirements[i] = new ItemStack(block.buildRequirements[i].item, block.buildRequirements[i].amount * 50);
requirements[i] = new ItemStack(block.buildRequirements[i].item, block.buildRequirements[i].amount * 40);
}
return new TechNode(block, requirements, children);
@ -288,7 +288,6 @@ public class TechTree implements ContentList{
context.children.add(this);
}
//TODO remove requirements... for now
this.block = block;
this.requirements = requirements;

View File

@ -29,7 +29,7 @@ public class Zones implements ContentList{
waveSpacing = 60 * 60 * 2; //2 mins
spawns = Array.with(
new SpawnGroup(UnitTypes.dagger){{
unitScaling = 2;
unitScaling = 1.5f;
}},
new SpawnGroup(UnitTypes.dagger){{
@ -73,7 +73,7 @@ public class Zones implements ContentList{
waveSpacing = 60 * 60 * 1.5f;
spawns = Array.with(
new SpawnGroup(UnitTypes.dagger){{
unitScaling = 2;
unitScaling = 1.5f;
}},
new SpawnGroup(UnitTypes.crawler){{
@ -109,7 +109,8 @@ public class Zones implements ContentList{
}};
frozenForest = new Zone("frozenForest", new MapGenerator("frozenForest", 2)
.decor(new Decoration(Blocks.snow, Blocks.sporeCluster, 0.02))){{
.decor(new Decoration(Blocks.snow, Blocks.sporeCluster, 0.02))
.core(Blocks.coreFoundation)){{
deployCost = ItemStack.with(Items.copper, 500);
startingItems = ItemStack.with(Items.copper, 400);
conditionWave = 10;
@ -168,7 +169,8 @@ public class Zones implements ContentList{
}};
}};
ruinousShores = new Zone("ruinousShores", new MapGenerator("ruinousShores", 1)){{
ruinousShores = new Zone("ruinousShores", new MapGenerator("ruinousShores", 1)
.core(Blocks.coreFoundation)){{
deployCost = ItemStack.with(Items.copper, 600, Items.graphite, 50);
startingItems = ItemStack.with(Items.copper, 400);
conditionWave = 20;
@ -242,7 +244,8 @@ public class Zones implements ContentList{
stainedMountains = new Zone("stainedMountains", new MapGenerator("stainedMountains", 2)
.dist(2.5f, true)
.decor(new Decoration(Blocks.stainedStone, Blocks.stainedBoulder, 0.01))){{
.decor(new Decoration(Blocks.stainedStone, Blocks.stainedBoulder, 0.01))
.core(Blocks.coreFoundation)){{
deployCost = ItemStack.with(Items.copper, 500, Items.lead, 300, Items.silicon, 100);
startingItems = ItemStack.with(Items.copper, 400, Items.lead, 100);
conditionWave = 10;
@ -386,7 +389,8 @@ public class Zones implements ContentList{
}};
}};
desolateRift = new Zone("desolateRift", new MapGenerator("desolateRift").dist(2f)){{
desolateRift = new Zone("desolateRift", new MapGenerator("desolateRift")
.core(Blocks.coreFoundation).dist(2f)){{
deployCost = ItemStack.with(Items.copper, 2000);
startingItems = ItemStack.with(Items.copper, 1500);
itemRequirements = ItemStack.with(Items.copper, 8000, Items.metaglass, 2000, Items.graphite, 3000);

View File

@ -200,8 +200,6 @@ public class Renderer implements ApplicationListener{
overlays.drawBottom();
drawAndInterpolate(playerGroup, p -> true, Player::drawBuildRequests);
//TODO shield
if(EntityDraw.countInBounds(shieldGroup) > 0){
if(graphics.getWidth() >= 2 && graphics.getHeight() >= 2 && (shieldBuffer.getWidth() != graphics.getWidth() || shieldBuffer.getHeight() != graphics.getHeight())){
shieldBuffer.resize(graphics.getWidth(), graphics.getHeight());
@ -232,9 +230,6 @@ public class Renderer implements ApplicationListener{
}
private void drawFlyerShadows(){
//TODO fix flyer shadows
//Graphics.surface(effectSurface, true, false);
float trnsX = -12, trnsY = -13;
Draw.color(0, 0, 0, 0.15f);
@ -248,8 +243,6 @@ public class Renderer implements ApplicationListener{
drawAndInterpolate(playerGroup, unit -> unit.isFlying() && !unit.isDead(), player -> player.drawShadow(trnsX, trnsY));
}
//Draw.color(0, 0, 0, 0.15f);
//Graphics.flushSurface();
Draw.color();
}

View File

@ -1,22 +1,10 @@
package io.anuke.mindustry.graphics;
//TODO implement effects again
public enum CacheLayer{
water{
public void begin(){
//Draw.shader(Shaders.water);
}
public void end(){
//Draw.shader();
}
},
lava{
},
oil{
},
space{
},
water,
lava,
oil,
space,
normal,
walls;
@ -27,11 +15,4 @@ public enum CacheLayer{
public void end(){
}
protected void beginShader(){
}
public void endShader(){
}
}

View File

@ -29,12 +29,8 @@ public class OverlayRenderer{
if(!input.isDrawing() || player.isDead()) continue;
Shaders.outline.color.set(Pal.accent);
//TODO draw outlined version
//Graphics.beginShaders(Shaders.outline);
input.drawOutlined();
//Graphics.endShaders();
}
}

View File

@ -21,7 +21,6 @@ public class BasicGenerator extends RandomGenerator{
@Override
public void generate(Tile[][] tiles){
//todo use set seed
int seed = Mathf.random(99999999);
sim.setSeed(seed);
sim2.setSeed(seed + 1);

View File

@ -36,6 +36,7 @@ public class MapGenerator extends Generator{
public boolean distortFloor = false;
/**Items randomly added to containers and vaults.*/
public ItemStack[] storageDrops = ItemStack.with(Items.copper, 300, Items.lead, 300, Items.silicon, 200, Items.graphite, 200, Items.blastCompound, 200);
public Block coreBlock;
public MapGenerator(String mapName){
this.mapName = mapName;
@ -46,6 +47,11 @@ public class MapGenerator extends Generator{
this.enemySpawns = enemySpawns;
}
public MapGenerator core(Block block){
this.coreBlock = block;
return this;
}
public MapGenerator drops(ItemStack[] drops){
this.storageDrops = drops;
return this;
@ -174,8 +180,7 @@ public class MapGenerator extends Generator{
throw new IllegalArgumentException("All zone maps must have a core.");
}
//TODO set specific core block?
tiles[core.x][core.y].setBlock(coreTypes.get(players.indexOf(core)), defaultTeam);
tiles[core.x][core.y].setBlock(coreBlock == null ? coreTypes.get(players.indexOf(core)) : coreBlock, defaultTeam);
world.prepareTiles(tiles);
world.setMap(map);

View File

@ -9,6 +9,7 @@ import io.anuke.mindustry.game.UnlockableContent;
import io.anuke.mindustry.maps.generators.Generator;
import io.anuke.mindustry.world.Block;
import static io.anuke.mindustry.Vars.data;
import static io.anuke.mindustry.Vars.state;
public class Zone extends UnlockableContent{
@ -22,6 +23,7 @@ public class Zone extends UnlockableContent{
public Supplier<Rules> rules = Rules::new;
public boolean alwaysUnlocked;
public int conditionWave = Integer.MAX_VALUE;
public int configureWave = 50;
public int launchPeriod = 10;
public Zone(String name, Generator generator){
@ -34,6 +36,10 @@ public class Zone extends UnlockableContent{
return state.wave >= conditionWave;
}
public boolean canConfigure(){
return data.getWaveScore(this) >= configureWave;
}
@Override
public void init(){
generator.init();

View File

@ -2,11 +2,11 @@ package io.anuke.mindustry.world.blocks.defense.turrets;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.consumers.ConsumePower;
import io.anuke.mindustry.world.meta.BlockStat;
import io.anuke.mindustry.world.meta.StatUnit;
public abstract class PowerTurret extends CooledTurret{
//TODO recode this class, satisfaction must be 100%!
/** The percentage of power which will be used per shot. */
protected float powerUsed = 0.5f;
protected BulletType shootType;
@ -20,7 +20,7 @@ public abstract class PowerTurret extends CooledTurret{
public void setStats(){
super.setStats();
stats.add(BlockStat.powerShot, powerUsed, StatUnit.powerUnits);
stats.add(BlockStat.powerShot, powerUsed * consumes.get(ConsumePower.class).powerCapacity, StatUnit.powerUnits);
}
@Override

View File

@ -42,8 +42,6 @@ public class Smelter extends Block{
public void setStats(){
super.setStats();
//TODO
//stats.add(BlockStat.inputFuel, fuel);
stats.add(BlockStat.fuelBurnTime, burnDuration / 60f, StatUnit.seconds);
stats.add(BlockStat.outputItem, result);
stats.add(BlockStat.craftSpeed, 60f / craftTime, StatUnit.itemsSecond);

View File

@ -210,6 +210,12 @@ public class UnitFactory extends Block{
return new UnitFactoryEntity();
}
@Override
public boolean canProduce(Tile tile){
UnitFactoryEntity entity = tile.entity();
return entity.spawned < maxSpawn;
}
protected boolean hasRequirements(ItemModule inv, float fraction){
for(ItemStack stack : consumes.items()){
if(!inv.has(stack.item, (int) (fraction * stack.amount))){

View File

@ -105,8 +105,6 @@ public class ApplicationTests{
@Test
void playMap(){
assertTrue(world.maps.all().size > 0);
world.loadMap(testMap);
}
@ -125,8 +123,6 @@ public class ApplicationTests{
@Test
void createMap(){
assertTrue(world.maps.all().size > 0);
Tile[][] tiles = world.createTiles(8, 8);
world.beginMapLoad();
@ -181,16 +177,12 @@ public class ApplicationTests{
@Test
void save(){
assertTrue(world.maps.all().size > 0);
world.loadMap(testMap);
SaveIO.saveToSlot(0);
}
@Test
void load(){
assertTrue(world.maps.all().size > 0);
world.loadMap(testMap);
Map map = world.getMap();
@ -198,7 +190,6 @@ public class ApplicationTests{
resetWorld();
SaveIO.loadFromSlot(0);
assertEquals(world.getMap().name, map.name);
assertEquals(world.width(), map.meta.width);
assertEquals(world.height(), map.meta.height);
}

View File

@ -41,7 +41,7 @@ public class DirectConsumerTests extends PowerTestFixture{
consumerTile.entity.items.add(Items.lead, leadAmount);
Tile producerTile = createFakeTile(2, 0, createFakeProducerBlock(producedPower));
producerTile.<PowerGenerator.GeneratorEntity>entity().productionEfficiency = 0.5f; // 100%
producerTile.<PowerGenerator.GeneratorEntity>entity().productionEfficiency = 1f;
PowerGraph graph = new PowerGraph();
graph.add(producerTile);

View File

@ -38,9 +38,8 @@ public class PowerTestFixture{
}
protected static PowerGenerator createFakeProducerBlock(float producedPower){
// Multiply produced power by 2 since production efficiency is defined to be 0.5 = 100%
return new PowerGenerator("fakegen"){{
powerProduction = producedPower * 2.0f;
powerProduction = producedPower;
}};
}

View File

@ -51,7 +51,6 @@ public class PowerTests extends PowerTestFixture{
}
void simulateDirectConsumption(float producedPower, float requiredPower, float expectedSatisfaction, String parameterDescription){
Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(producedPower));
producerTile.<PowerGenerator.GeneratorEntity>entity().productionEfficiency = 0.5f; // Currently, 0.5f = 100%
Tile directConsumerTile = createFakeTile(0, 1, createFakeDirectConsumer(requiredPower));
PowerGraph powerGraph = new PowerGraph();
@ -91,7 +90,6 @@ public class PowerTests extends PowerTestFixture{
}
void simulateBufferedConsumption(float producedPower, float maxBuffer, float powerConsumedPerTick, float initialSatisfaction, float expectedSatisfaction, String parameterDescription){
Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(producedPower));
producerTile.<PowerGenerator.GeneratorEntity>entity().productionEfficiency = 0.5f; // Currently, 0.5 = 100%
Tile bufferedConsumerTile = createFakeTile(0, 1, createFakeBufferedConsumer(maxBuffer, maxBuffer > 0.0f ? maxBuffer/powerConsumedPerTick : 1.0f));
bufferedConsumerTile.entity.power.satisfaction = initialSatisfaction;
@ -136,7 +134,6 @@ public class PowerTests extends PowerTestFixture{
if(producedPower > 0.0f){
Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(producedPower));
producerTile.<PowerGenerator.GeneratorEntity>entity().productionEfficiency = 0.5f;
powerGraph.add(producerTile);
}
Tile directConsumerTile = null;