fixed some sector things, broke more things

This commit is contained in:
Anuken
2020-10-15 15:41:09 -04:00
parent 988e1add82
commit 45b87ec615
12 changed files with 30 additions and 47 deletions

View File

@@ -160,9 +160,7 @@ public class Control implements ApplicationListener, Loadable{
//delete the save, it is gone. //delete the save, it is gone.
if(saves.getCurrent() != null && !state.rules.tutorial){ if(saves.getCurrent() != null && !state.rules.tutorial){
Sector sector = state.getSector(); saves.getCurrent().save();
sector.save = null;
saves.getCurrent().delete();
} }
} }
}); });
@@ -283,18 +281,16 @@ public class Control implements ApplicationListener, Loadable{
state.rules.sector = sector; state.rules.sector = sector;
//if there is no base, simulate a new game and place the right loadout at the spawn position //if there is no base, simulate a new game and place the right loadout at the spawn position
//TODO this is broken?
if(state.rules.defaultTeam.cores().isEmpty()){ if(state.rules.defaultTeam.cores().isEmpty()){
//reset wave so things are more fair
state.wave = 1;
//kill all friendly units, since they should be dead anwyay //kill all units, since they should be dead anwyay
for(Unit unit : Groups.unit){ for(Unit unit : Groups.unit){
if(unit.team() == state.rules.defaultTeam){ unit.remove();
unit.remove();
}
} }
Tile spawn = world.tile(sector.getSpawnPosition()); Tile spawn = world.tile(sector.getSpawnPosition());
//TODO PLACE CORRECT LOADOUT
Schematics.placeLoadout(universe.getLastLoadout(), spawn.x, spawn.y); Schematics.placeLoadout(universe.getLastLoadout(), spawn.x, spawn.y);
//set up camera/player locations //set up camera/player locations

View File

@@ -120,7 +120,7 @@ public class Logic implements ApplicationListener{
} }
//waves depend on attack status. //waves depend on attack status.
state.rules.waves = state.rules.sector.isUnderAttack(); state.rules.waves = state.rules.sector.isUnderAttack() || !state.rules.sector.hasBase();
//add resources based on turns passed //add resources based on turns passed
if(state.rules.sector.save != null && core != null){ if(state.rules.sector.save != null && core != null){

View File

@@ -28,7 +28,6 @@ public class Objectives{
} }
} }
//TODO fix
public static class SectorComplete extends SectorObjective{ public static class SectorComplete extends SectorObjective{
public SectorComplete(SectorPreset zone){ public SectorComplete(SectorPreset zone){
@@ -39,12 +38,12 @@ public class Objectives{
@Override @Override
public boolean complete(){ public boolean complete(){
return preset.sector.save != null && preset.sector.save.meta.wave >= preset.sector.save.meta.rules.winWave; return preset.sector.save != null && preset.sector.save.meta.wave >= preset.captureWave;
} }
@Override @Override
public String display(){ public String display(){
return Core.bundle.format("requirement.wave", preset.sector.save == null ? "<unknown>" : preset.sector.save.meta.rules.winWave, preset.localizedName); return Core.bundle.format("requirement.capture", preset.localizedName);
} }
} }

View File

@@ -161,17 +161,14 @@ public class Universe{
//if so, just delete the save for now. it's lost. //if so, just delete the save for now. it's lost.
//TODO don't delete it later maybe //TODO don't delete it later maybe
sector.save.delete();
//clear recieved
sector.setExtraItems(new ItemSeq()); sector.setExtraItems(new ItemSeq());
sector.save = null; sector.setDamage(1.01f);
sector.setDamage(0f);
}else if(attacked && wavesPassed > 0 && sector.save.meta.wave + wavesPassed >= sector.save.meta.rules.winWave && !sector.hasEnemyBase()){ }else if(attacked && wavesPassed > 0 && sector.save.meta.wave + wavesPassed >= sector.save.meta.rules.winWave && !sector.hasEnemyBase()){
//autocapture the sector //autocapture the sector
sector.setUnderAttack(false); sector.setUnderAttack(false);
//fire the event //fire the event
Events.fire(new SectorCaptureEvent(state.rules.sector)); Events.fire(new SectorCaptureEvent(sector));
} }
} }
@@ -179,9 +176,10 @@ public class Universe{
if(sector.save != null && sector.save.meta != null && sector.save.meta.secinfo != null && sector.save.meta.secinfo.destination != null){ if(sector.save != null && sector.save.meta != null && sector.save.meta.secinfo != null && sector.save.meta.secinfo.destination != null){
Sector to = sector.save.meta.secinfo.destination; Sector to = sector.save.meta.secinfo.destination;
if(to.save != null){ if(to.save != null){
float scl = Math.max(1f - sector.getDamage(), 0);
ItemSeq items = new ItemSeq(); ItemSeq items = new ItemSeq();
//calculated exported items to this sector //calculated exported items to this sector
sector.save.meta.secinfo.export.each((item, stat) -> items.add(item, (int)(stat.mean * newSecondsPassed))); sector.save.meta.secinfo.export.each((item, stat) -> items.add(item, (int)(stat.mean * newSecondsPassed * scl)));
to.addItems(items); to.addItems(items);
} }
} }

View File

@@ -360,6 +360,13 @@ public class SectorDamage{
} }
} }
//kill every core if damage is maximum
if(damage >= 1){
for(Building c : state.rules.defaultTeam.cores().copy()){
c.tile.remove();
}
}
float falloff = (damage) / (Math.max(tiles.width, tiles.height) * Mathf.sqrt2); float falloff = (damage) / (Math.max(tiles.width, tiles.height) * Mathf.sqrt2);
int peak = 0; int peak = 0;

View File

@@ -86,7 +86,7 @@ public class Sector{
/** @return whether the player has a base here. */ /** @return whether the player has a base here. */
public boolean hasBase(){ public boolean hasBase(){
return save != null && !save.meta.tags.getBool("nocores"); return save != null && !save.meta.tags.getBool("nocores") && getDamage() < 1f;
} }
/** @return whether the enemy has a generated base here. */ /** @return whether the enemy has a generated base here. */
@@ -229,9 +229,10 @@ public class Sector{
if(save != null){ if(save != null){
long seconds = getSecondsPassed(); long seconds = getSecondsPassed();
float scl = Math.max(1f - getDamage(), 0);
//add produced items //add produced items
save.meta.secinfo.production.each((item, stat) -> count.add(item, (int)(stat.mean * seconds))); save.meta.secinfo.production.each((item, stat) -> count.add(item, (int)(stat.mean * seconds * scl)));
//add received items //add received items
count.add(getExtraItems()); count.add(getExtraItems());
@@ -253,6 +254,8 @@ public class Sector{
/** @return sector damage from enemy, 0 to 1 */ /** @return sector damage from enemy, 0 to 1 */
public float getDamage(){ public float getDamage(){
//dead sector
if(save != null & save.meta.tags.getBool("nocores")) return 1.01f;
return Core.settings.getFloat(key("damage"), 0f); return Core.settings.getFloat(key("damage"), 0f);
} }

View File

@@ -394,8 +394,10 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
stable.table(t -> { stable.table(t -> {
t.left(); t.left();
float scl = Math.max(1f - sector.getDamage(), 0);
sector.save.meta.secinfo.production.each((item, stat) -> { sector.save.meta.secinfo.production.each((item, stat) -> {
int total = (int)(stat.mean * 60); int total = (int)(stat.mean * 60 * scl);
if(total > 1){ if(total > 1){
t.image(item.icon(Cicon.small)).padRight(3); t.image(item.icon(Cicon.small)).padRight(3);
t.add(UI.formatAmount(total) + " " + Core.bundle.get("unit.perminute")).color(Color.lightGray); t.add(UI.formatAmount(total) + " " + Core.bundle.get("unit.perminute")).color(Color.lightGray);

View File

@@ -291,7 +291,7 @@ public class SettingsMenuDialog extends SettingsDialog{
} }
return s + "%"; return s + "%";
}); });
graphics.sliderPref("bridgeopacity", 75, 0, 100, 5, s -> s + "%"); graphics.sliderPref("bridgeopacity", 100, 0, 100, 5, s -> s + "%");
if(!mobile){ if(!mobile){
graphics.checkPref("vsync", true, b -> Core.graphics.setVSync(b)); graphics.checkPref("vsync", true, b -> Core.graphics.setVSync(b));

View File

@@ -71,7 +71,7 @@ public class HudFragment extends Fragment{
//TODO details and stuff //TODO details and stuff
Events.on(SectorCaptureEvent.class, e ->{ Events.on(SectorCaptureEvent.class, e ->{
//TODO localize //TODO localize
showToast("Sector[accent] captured[]!"); showToast("Sector [accent]" + (e.sector.isBeingPlayed() ? "" : e.sector.id + " ") + "[]captured!");
}); });
//TODO localize //TODO localize

View File

@@ -310,23 +310,6 @@ public class CoreBlock extends StorageBlock{
} }
} }
@Override
public void onDestroyed(){
super.onDestroyed();
if(state.isCampaign() && team == state.rules.waveTeam){
//do not recache
world.setGenerating(true);
tile.setOverlay(Blocks.spawn);
world.setGenerating(false);
if(!spawner.getSpawns().contains(tile)){
spawner.getSpawns().add(tile);
}
spawner.doShockwave(x, y);
}
}
@Override @Override
public void placed(){ public void placed(){
super.placed(); super.placed();

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=true org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=171cba8dda6deed931b998a0eb368d61f68ea38c archash=7ce118ba1fcbe652dd3b225fd7d16a7a761c238e

View File

@@ -63,11 +63,6 @@ public class FakeGraphics extends Graphics{
return 0; return 0;
} }
@Override
public float getRawDeltaTime(){
return 0;
}
@Override @Override
public int getFramesPerSecond(){ public int getFramesPerSecond(){
return 0; return 0;