mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-12 19:09:34 +07:00
Fixed #7728
This commit is contained in:
parent
1ef1aeaaf3
commit
215633587d
@ -348,6 +348,7 @@ public class Logic implements ApplicationListener{
|
||||
|
||||
//map is over, no more world processor objective stuff
|
||||
state.rules.disableWorldProcessors = true;
|
||||
state.rules.objectives.clear();
|
||||
|
||||
//save, just in case
|
||||
if(!headless && !net.client()){
|
||||
@ -367,9 +368,7 @@ public class Logic implements ApplicationListener{
|
||||
public static void gameOver(Team winner){
|
||||
state.stats.wavesLasted = state.wave;
|
||||
state.won = player.team() == winner;
|
||||
Time.run(60f * 3f, () -> {
|
||||
ui.restart.show(winner);
|
||||
});
|
||||
Time.run(60f * 3f, () -> ui.restart.show(winner));
|
||||
netClient.setQuiet();
|
||||
}
|
||||
|
||||
@ -389,39 +388,6 @@ public class Logic implements ApplicationListener{
|
||||
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
|
||||
public void dispose(){
|
||||
//save the settings before quitting
|
||||
|
@ -139,6 +139,11 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
|
||||
return all.count(MapObjective::qualified) > 0;
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
if(all.size > 0) changed = true;
|
||||
all.clear();
|
||||
}
|
||||
|
||||
/** Iterates over all qualified in-map objectives. */
|
||||
public void eachRunning(Cons<MapObjective> 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.");
|
||||
|
||||
SectorPreset out = new SectorPreset(name, locate(ContentType.planet, value.getString("planet", "serpulo")), value.getInt("sector"));
|
||||
SectorPreset out = new SectorPreset(name);
|
||||
|
||||
currentContent = out;
|
||||
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");
|
||||
currentContent = out;
|
||||
read(() -> readFields(out, value));
|
||||
|
||||
readFields(out, value);
|
||||
});
|
||||
return out;
|
||||
},
|
||||
ContentType.planet, (TypeParser<Planet>)(mod, name, value) -> {
|
||||
|
@ -29,8 +29,17 @@ public class SectorPreset extends UnlockableContent{
|
||||
public boolean attackAfterWaves = false;
|
||||
|
||||
public SectorPreset(String name, Planet planet, int sector){
|
||||
this(name);
|
||||
initialize(planet, sector);
|
||||
}
|
||||
|
||||
/** Internal use only! */
|
||||
public SectorPreset(String name){
|
||||
super(name);
|
||||
this.generator = new FileMapGenerator(name, this);
|
||||
}
|
||||
|
||||
public void initialize(Planet planet, int sector){
|
||||
this.planet = planet;
|
||||
sector %= planet.sectors.size;
|
||||
this.sector = planet.sectors.get(sector);
|
||||
|
Loading…
Reference in New Issue
Block a user