Fixed #7728
This commit is contained in:
@@ -348,6 +348,7 @@ public class Logic implements ApplicationListener{
|
|||||||
|
|
||||||
//map is over, no more world processor objective stuff
|
//map is over, no more world processor objective stuff
|
||||||
state.rules.disableWorldProcessors = true;
|
state.rules.disableWorldProcessors = true;
|
||||||
|
state.rules.objectives.clear();
|
||||||
|
|
||||||
//save, just in case
|
//save, just in case
|
||||||
if(!headless && !net.client()){
|
if(!headless && !net.client()){
|
||||||
@@ -367,9 +368,7 @@ public class Logic implements ApplicationListener{
|
|||||||
public static void gameOver(Team winner){
|
public static void gameOver(Team winner){
|
||||||
state.stats.wavesLasted = state.wave;
|
state.stats.wavesLasted = state.wave;
|
||||||
state.won = player.team() == winner;
|
state.won = player.team() == winner;
|
||||||
Time.run(60f * 3f, () -> {
|
Time.run(60f * 3f, () -> ui.restart.show(winner));
|
||||||
ui.restart.show(winner);
|
|
||||||
});
|
|
||||||
netClient.setQuiet();
|
netClient.setQuiet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,39 +388,6 @@ public class Logic implements ApplicationListener{
|
|||||||
state.rules.researched.add(u.name);
|
state.rules.researched.add(u.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//called when the remote server runs a turn and produces something
|
|
||||||
@Remote
|
|
||||||
public static void sectorProduced(int[] amounts){
|
|
||||||
//TODO currently disabled.
|
|
||||||
if(!state.isCampaign() || true) return;
|
|
||||||
|
|
||||||
Planet planet = state.rules.sector.planet;
|
|
||||||
boolean any = false;
|
|
||||||
|
|
||||||
for(Item item : content.items()){
|
|
||||||
int am = amounts[item.id];
|
|
||||||
if(am > 0){
|
|
||||||
int sumMissing = planet.sectors.sum(s -> s.hasBase() ? s.info.storageCapacity - s.info.items.get(item) : 0);
|
|
||||||
if(sumMissing == 0) continue;
|
|
||||||
//how much % to add
|
|
||||||
double percent = Math.min((double)am / sumMissing, 1);
|
|
||||||
for(Sector sec : planet.sectors){
|
|
||||||
if(sec.hasBase()){
|
|
||||||
int added = (int)Math.ceil(((sec.info.storageCapacity - sec.info.items.get(item)) * percent));
|
|
||||||
sec.info.items.add(item, added);
|
|
||||||
any = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(any){
|
|
||||||
for(Sector sec : planet.sectors){
|
|
||||||
sec.saveInfo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose(){
|
public void dispose(){
|
||||||
//save the settings before quitting
|
//save the settings before quitting
|
||||||
|
|||||||
@@ -139,6 +139,11 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
|
|||||||
return all.count(MapObjective::qualified) > 0;
|
return all.count(MapObjective::qualified) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clear(){
|
||||||
|
if(all.size > 0) changed = true;
|
||||||
|
all.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/** Iterates over all qualified in-map objectives. */
|
/** Iterates over all qualified in-map objectives. */
|
||||||
public void eachRunning(Cons<MapObjective> cons){
|
public void eachRunning(Cons<MapObjective> cons){
|
||||||
all.each(MapObjective::qualified, cons);
|
all.each(MapObjective::qualified, cons);
|
||||||
|
|||||||
@@ -556,11 +556,21 @@ public class ContentParser{
|
|||||||
|
|
||||||
if(!value.has("sector") || !value.get("sector").isNumber()) throw new RuntimeException("SectorPresets must have a sector number.");
|
if(!value.has("sector") || !value.get("sector").isNumber()) throw new RuntimeException("SectorPresets must have a sector number.");
|
||||||
|
|
||||||
SectorPreset out = new SectorPreset(name, locate(ContentType.planet, value.getString("planet", "serpulo")), value.getInt("sector"));
|
SectorPreset out = new SectorPreset(name);
|
||||||
value.remove("sector");
|
|
||||||
value.remove("planet");
|
|
||||||
currentContent = out;
|
currentContent = out;
|
||||||
read(() -> readFields(out, value));
|
read(() -> {
|
||||||
|
Planet planet = locate(ContentType.planet, value.getString("planet", "serpulo"));
|
||||||
|
|
||||||
|
if(planet == null) throw new RuntimeException("Planet '" + value.getString("planet") + "' not found.");
|
||||||
|
|
||||||
|
out.initialize(planet, value.getInt("sector", 0));
|
||||||
|
|
||||||
|
value.remove("sector");
|
||||||
|
value.remove("planet");
|
||||||
|
|
||||||
|
readFields(out, value);
|
||||||
|
});
|
||||||
return out;
|
return out;
|
||||||
},
|
},
|
||||||
ContentType.planet, (TypeParser<Planet>)(mod, name, value) -> {
|
ContentType.planet, (TypeParser<Planet>)(mod, name, value) -> {
|
||||||
|
|||||||
@@ -29,8 +29,17 @@ public class SectorPreset extends UnlockableContent{
|
|||||||
public boolean attackAfterWaves = false;
|
public boolean attackAfterWaves = false;
|
||||||
|
|
||||||
public SectorPreset(String name, Planet planet, int sector){
|
public SectorPreset(String name, Planet planet, int sector){
|
||||||
|
this(name);
|
||||||
|
initialize(planet, sector);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Internal use only! */
|
||||||
|
public SectorPreset(String name){
|
||||||
super(name);
|
super(name);
|
||||||
this.generator = new FileMapGenerator(name, this);
|
this.generator = new FileMapGenerator(name, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialize(Planet planet, int sector){
|
||||||
this.planet = planet;
|
this.planet = planet;
|
||||||
sector %= planet.sectors.size;
|
sector %= planet.sectors.size;
|
||||||
this.sector = planet.sectors.get(sector);
|
this.sector = planet.sectors.get(sector);
|
||||||
|
|||||||
Reference in New Issue
Block a user