More bugfixes

This commit is contained in:
Anuken
2019-02-22 23:16:50 -05:00
parent 7fb72bf0e2
commit d74887eaa1
17 changed files with 81 additions and 62 deletions

View File

@@ -45,6 +45,8 @@ public class Vars{
public static final Team defaultTeam = Team.blue; public static final Team defaultTeam = Team.blue;
/**team of the enemy in waves/sectors*/ /**team of the enemy in waves/sectors*/
public static final Team waveTeam = Team.red; public static final Team waveTeam = Team.red;
/**how many times longer a boss wave takes*/
public static final float bossWaveMultiplier = 3f;
/**max chat message length*/ /**max chat message length*/
public static final int maxTextLength = 150; public static final int maxTextLength = 150;
/**max player name length in bytes*/ /**max player name length in bytes*/

View File

@@ -833,7 +833,7 @@ public class Blocks implements ContentList{
thermalGenerator = new ThermalGenerator("thermal-generator"){{ thermalGenerator = new ThermalGenerator("thermal-generator"){{
requirements(Category.power, ItemStack.with(Items.copper, 80, Items.graphite, 70, Items.lead, 100, Items.silicon, 70, Items.metaglass, 80)); requirements(Category.power, ItemStack.with(Items.copper, 80, Items.graphite, 70, Items.lead, 100, Items.silicon, 70, Items.metaglass, 80));
powerProduction = 2f; powerProduction = 1.8f;
generateEffect = Fx.redgeneratespark; generateEffect = Fx.redgeneratespark;
size = 2; size = 2;
}}; }};
@@ -843,6 +843,7 @@ public class Blocks implements ContentList{
powerProduction = 6f; powerProduction = 6f;
itemDuration = 30f; itemDuration = 30f;
consumes.liquid(Liquids.water, 0.05f); consumes.liquid(Liquids.water, 0.05f);
hasLiquids = true;
size = 2; size = 2;
}}; }};

View File

@@ -0,0 +1,10 @@
package io.anuke.mindustry.content;
import io.anuke.mindustry.game.ContentList;
public class Loadouts implements ContentList{
@Override
public void load(){
}
}

View File

@@ -132,7 +132,7 @@ public class UnitTypes implements ContentList{
mass = 5f; mass = 5f;
hitsize = 20f; hitsize = 20f;
rotatespeed = 0.06f; rotatespeed = 0.06f;
health = 20000; health = 4000;
weapon = new Weapon("chaos"){{ weapon = new Weapon("chaos"){{
length = 8f; length = 8f;
reload = 50f; reload = 50f;
@@ -155,7 +155,7 @@ public class UnitTypes implements ContentList{
mass = 5f; mass = 5f;
hitsize = 20f; hitsize = 20f;
rotatespeed = 0.06f; rotatespeed = 0.06f;
health = 80000; health = 10000;
weapon = new Weapon("eradication"){{ weapon = new Weapon("eradication"){{
length = 13f; length = 13f;
reload = 30f; reload = 30f;
@@ -236,7 +236,7 @@ public class UnitTypes implements ContentList{
}}; }};
revenant = new UnitType("revenant", Revenant.class, Revenant::new){{ revenant = new UnitType("revenant", Revenant.class, Revenant::new){{
health = 4000; health = 3000;
mass = 5f; mass = 5f;
hitsize = 20f; hitsize = 20f;
speed = 0.1f; speed = 0.1f;
@@ -266,7 +266,7 @@ public class UnitTypes implements ContentList{
}}; }};
lich = new UnitType("lich", Revenant.class, Revenant::new){{ lich = new UnitType("lich", Revenant.class, Revenant::new){{
health = 15000; health = 9000;
mass = 20f; mass = 20f;
hitsize = 40f; hitsize = 40f;
speed = 0.01f; speed = 0.01f;
@@ -297,7 +297,7 @@ public class UnitTypes implements ContentList{
}}; }};
reaper = new UnitType("reaper", Revenant.class, Revenant::new){{ reaper = new UnitType("reaper", Revenant.class, Revenant::new){{
health = 30000; health = 20000;
mass = 30f; mass = 30f;
hitsize = 56f; hitsize = 56f;
speed = 0.01f; speed = 0.01f;

View File

@@ -49,6 +49,7 @@ public class ContentLoader{
new Mechs(), new Mechs(),
new UnitTypes(), new UnitTypes(),
new Blocks(), new Blocks(),
new Loadouts(),
new TechTree(), new TechTree(),
new Zones(), new Zones(),

View File

@@ -43,7 +43,7 @@ public class GameState{
} }
public boolean isPaused(){ public boolean isPaused(){
return (is(State.paused) && !Net.active()) || gameOver; return (is(State.paused) && !Net.active()) || (gameOver && !Net.active());
} }
public boolean is(State astate){ public boolean is(State astate){

View File

@@ -81,7 +81,7 @@ public class Logic implements ApplicationListener{
public void runWave(){ public void runWave(){
world.spawner.spawnEnemies(); world.spawner.spawnEnemies();
state.wave++; state.wave++;
state.wavetime = state.rules.waveSpacing; state.wavetime = world.isZone() && world.getZone().isBossWave(state.wave) ? state.rules.waveSpacing * bossWaveMultiplier : state.rules.waveSpacing;
Events.fire(new WaveEvent()); Events.fire(new WaveEvent());
} }

View File

@@ -364,8 +364,9 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
@Override @Override
public void drawUnder(){ public void drawUnder(){
float size = mech.engineSize * (mech.flying ? 1f : boostHeat); if(dead) return;
float size = mech.engineSize * (mech.flying ? 1f : boostHeat);
Draw.color(mech.engineColor); Draw.color(mech.engineColor);
Fill.circle(x + Angles.trnsx(rotation + 180, mech.engineOffset), y + Angles.trnsy(rotation + 180, mech.engineOffset), Fill.circle(x + Angles.trnsx(rotation + 180, mech.engineOffset), y + Angles.trnsy(rotation + 180, mech.engineOffset),
size + Mathf.absin(Time.time(), 2f, size/4f)); size + Mathf.absin(Time.time(), 2f, size/4f));

View File

@@ -1,17 +1,10 @@
package io.anuke.mindustry.game; package io.anuke.mindustry.game;
import io.anuke.mindustry.content.Blocks; import io.anuke.mindustry.type.ContentType;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
public enum Loadout{ public abstract class Loadout extends Content{
test(Blocks.coreShard){
@Override
public void setup(Tile tile){
}
};
public final Block core; public final Block core;
Loadout(Block core){ Loadout(Block core){
@@ -19,4 +12,9 @@ public enum Loadout{
} }
public abstract void setup(Tile tile); public abstract void setup(Tile tile);
@Override
public ContentType getContentType(){
return ContentType.loadout;
}
} }

View File

@@ -11,5 +11,6 @@ public enum ContentType {
unit, unit,
weather, weather,
effect, effect,
zone zone,
loadout
} }

View File

@@ -89,7 +89,7 @@ public class MapsDialog extends FloatingDialog{
TextButton button = maps.addButton("", "clear", () -> showMapInfo(map)).width(mapsize).pad(8).get(); TextButton button = maps.addButton("", "clear", () -> showMapInfo(map)).width(mapsize).pad(8).get();
button.clearChildren(); button.clearChildren();
button.margin(9); button.margin(9);
button.add(map.meta.tags.get("name", map.name)).growX().center().get().setEllipsis(true); button.add(map.meta.tags.get("name", map.name)).width(mapsize - 18f).center().get().setEllipsis(true);
button.row(); button.row();
button.addImage("white").growX().pad(4).color(Color.GRAY); button.addImage("white").growX().pad(4).color(Color.GRAY);
button.row(); button.row();

View File

@@ -39,10 +39,15 @@ public class ZoneInfoDialog extends FloatingDialog{
Table iteminfo = new Table(); Table iteminfo = new Table();
Runnable rebuildItems = () -> { Runnable rebuildItems = () -> {
int i = 0;
iteminfo.clear(); iteminfo.clear();
ItemStack[] stacks = zone.unlocked() ? zone.getLaunchCost() : zone.itemRequirements; ItemStack[] stacks = zone.unlocked() ? zone.getLaunchCost() : zone.itemRequirements;
for(ItemStack stack : stacks){ for(ItemStack stack : stacks){
if(stack.amount == 0) continue; if(stack.amount == 0) continue;
if(i++ % 2 == 0){
iteminfo.row();
}
iteminfo.addImage(stack.item.icon(Item.Icon.medium)).size(8*3).padRight(1); iteminfo.addImage(stack.item.icon(Item.Icon.medium)).size(8*3).padRight(1);
iteminfo.add(stack.amount + "").color(Color.LIGHT_GRAY).padRight(5); iteminfo.add(stack.amount + "").color(Color.LIGHT_GRAY).padRight(5);
} }
@@ -157,7 +162,7 @@ public class ZoneInfoDialog extends FloatingDialog{
dialog.cont.row(); dialog.cont.row();
} }
dialog.show(); dialog.show();
}).colspan(4).size(100f, bsize).left(); }).colspan(4).size(100f, bsize).left().disabled(b -> !content.items().contains(item -> data.getItem(item) > 0 && item.type == ItemType.material && !zone.getStartingItems().contains(stack -> stack.item == item)));
}; };
rebuildLoadout[0].run(); rebuildLoadout[0].run();
@@ -188,7 +193,7 @@ public class ZoneInfoDialog extends FloatingDialog{
hide(); hide();
world.playZone(zone); world.playZone(zone);
} }
}).size(300f, 70f).padTop(5).disabled(b -> zone.locked() ? !canUnlock(zone) : !data.hasItems(zone.getLaunchCost())).get(); }).margin(13f).padTop(5).disabled(b -> zone.locked() ? !canUnlock(zone) : !data.hasItems(zone.getLaunchCost())).get();
button.row(); button.row();
button.add(iteminfo); button.add(iteminfo);

View File

@@ -134,16 +134,21 @@ public class HudFragment extends Fragment{
cont.row(); cont.row();
//fps display //fps display
infolabel = cont.table(t -> { infolabel = new Table();
IntFormat fps = new IntFormat("fps"); IntFormat fps = new IntFormat("fps");
IntFormat ping = new IntFormat("ping"); IntFormat ping = new IntFormat("ping");
t.label(() -> fps.get(Core.graphics.getFramesPerSecond())).padRight(10); infolabel.label(() -> fps.get(Core.graphics.getFramesPerSecond())).padRight(10);
t.row(); infolabel.row();
if(Net.hasClient()){ if(Net.hasClient()){
t.label(() -> ping.get(Net.getPing())).visible(Net::client).colspan(2); infolabel.label(() -> ping.get(Net.getPing())).visible(Net::client).colspan(2);
} }
}).size(-1).visible(() -> Core.settings.getBool("fps")).update(t -> t.setTranslation(0, infolabel.visible(() -> Core.settings.getBool("fps")).update(() ->
(!waves.isVisible() ? wavetable.getHeight() + healthTable.getHeight() : Math.min(wavetable.getTranslation().y + healthTable.getHeight(), wavetable.getHeight() + healthTable.getHeight())))).get(); infolabel.setPosition(0,
healthTable.isVisible() ? healthTable.getY() + healthTable.getTranslation().y : wavetable.isVisible() ? wavetable.getY() : 0f,
Align.topLeft));
infolabel.pack();
cont.addChild(infolabel);
//make wave box appear below rest of menu //make wave box appear below rest of menu
if(mobile){ if(mobile){

View File

@@ -68,6 +68,7 @@ public abstract class BlockStorage extends UnlockableContent{
/**Remove a stack from this inventory, and return the amount removed.*/ /**Remove a stack from this inventory, and return the amount removed.*/
public int removeStack(Tile tile, Item item, int amount){ public int removeStack(Tile tile, Item item, int amount){
amount = Math.min(amount, tile.entity.items.get(item));
tile.entity.noSleep(); tile.entity.noSleep();
tile.entity.items.remove(item, amount); tile.entity.items.remove(item, amount);
return amount; return amount;

View File

@@ -15,6 +15,6 @@ public class TurbineGenerator extends BurnerGenerator{
@Override @Override
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){ public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
return super.acceptLiquid(tile, source, liquid, amount) || liquid == consumes.liquid() && tile.entity.liquids.get(consumes.liquid()) < liquidCapacity; return (liquid == consumes.liquid() && tile.entity.liquids.get(consumes.liquid()) < liquidCapacity);
} }
} }

View File

@@ -14,11 +14,8 @@ import io.anuke.arc.util.CommandHandler.ResponseType;
import io.anuke.arc.util.Timer.Task; import io.anuke.arc.util.Timer.Task;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.type.Player; import io.anuke.mindustry.entities.type.Player;
import io.anuke.mindustry.game.Difficulty; import io.anuke.mindustry.game.*;
import io.anuke.mindustry.game.EventType.GameOverEvent; import io.anuke.mindustry.game.EventType.GameOverEvent;
import io.anuke.mindustry.game.RulePreset;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.game.Version;
import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.io.SaveIO; import io.anuke.mindustry.io.SaveIO;
import io.anuke.mindustry.maps.Map; import io.anuke.mindustry.maps.Map;
@@ -48,7 +45,7 @@ public class ServerControl implements ApplicationListener{
private FileHandle currentLogFile; private FileHandle currentLogFile;
private boolean inExtraRound; private boolean inExtraRound;
private Task lastTask; private Task lastTask;
private RulePreset lastPreset;
public ServerControl(String[] args){ public ServerControl(String[] args){
Core.settings.defaults( Core.settings.defaults(
@@ -214,7 +211,7 @@ public class ServerControl implements ApplicationListener{
try{ try{
preset = RulePreset.valueOf(arg[1]); preset = RulePreset.valueOf(arg[1]);
}catch(IllegalArgumentException e){ }catch(IllegalArgumentException e){
err("No gamemode '{0}' found."); err("No gamemode '{0}' found.", arg[1]);
return; return;
} }
} }
@@ -643,7 +640,9 @@ public class ServerControl implements ApplicationListener{
players.add(p); players.add(p);
p.setDead(true); p.setDead(true);
} }
Rules rules = state.rules;
logic.reset(); logic.reset();
state.rules = rules;
Call.onWorldDataBegin(); Call.onWorldDataBegin();
run.run(); run.run();
logic.play(); logic.play();

View File

@@ -241,37 +241,32 @@ public class ApplicationTests{
@Test @Test
void zoneEmptyWaves(){ void zoneEmptyWaves(){
for(Zone zone : content.zones()){ for(Zone zone : content.zones()){
checkNoEmptyWaves(zone, zone.rules.get().spawns, 1, 100); Array<SpawnGroup> spawns = zone.rules.get().spawns;
for(int i = 1; i <= 100; i++){
int total = 0;
for(SpawnGroup spawn : spawns){
total += spawn.getUnitsSpawned(i);
}
assertNotEquals(0, total, "Zone " + zone + " has no spawned enemies at wave " + i);
}
} }
} }
@Test @Test
void zoneOverflowWaves(){ void zoneOverflowWaves(){
for(Zone zone : content.zones()){ for(Zone zone : content.zones()){
checkExtraWaves(zone, zone.rules.get().spawns, 1, 40, 140); Array<SpawnGroup> spawns = zone.rules.get().spawns;
}
}
void checkNoEmptyWaves(Zone zone, Array<SpawnGroup> spawns, int from, int to){ for(int i = 1; i <= 40; i++){
for(int i = from; i <= to; i++){ int total = 0;
int total = 0; for(SpawnGroup spawn : spawns){
for(SpawnGroup spawn : spawns){ total += spawn.getUnitsSpawned(i);
total += spawn.getUnitsSpawned(i); }
}
assertNotEquals(0, total, "Zone " + zone + " has no spawned enemies at wave " + i); if(total >= 140){
} fail("Zone '" + zone + "' has too many spawned enemies at wave " + i + " : " + total);
} }
void checkExtraWaves(Zone zone, Array<SpawnGroup> spawns, int from, int to, int max){
for(int i = from; i <= to; i++){
int total = 0;
for(SpawnGroup spawn : spawns){
total += spawn.getUnitsSpawned(i);
}
if(total >= max){
fail("Zone '" + zone + "' has too many spawned enemies at wave " + i + " : " + total);
} }
} }
} }