Checks to prevent uncaptureable sectors

This commit is contained in:
Anuken
2020-10-17 10:10:29 -04:00
parent c3d0819cc1
commit be394c4b33
6 changed files with 25 additions and 6 deletions
+1 -1
View File
@@ -40,7 +40,7 @@ public class BaseAI{
} }
public void update(){ public void update(){
if(timer.get(timerSpawn, 60) && data.hasCore()){ if(data.team.rules().aiCoreSpawn && timer.get(timerSpawn, 60 * 2.5f) && data.hasCore()){
CoreBlock block = (CoreBlock)data.core().block; CoreBlock block = (CoreBlock)data.core().block;
//create AI core unit //create AI core unit
+2
View File
@@ -106,6 +106,8 @@ public class Rules{
public boolean ai; public boolean ai;
/** TODO Tier of blocks/designs that the AI uses for building. [0, 1]*/ /** TODO Tier of blocks/designs that the AI uses for building. [0, 1]*/
public float aiTier = 0f; public float aiTier = 0f;
/** Whether, when AI is enabled, ships should be spawned from the core. */
public boolean aiCoreSpawn = true;
/** If true, blocks don't require power or resources. */ /** If true, blocks don't require power or resources. */
public boolean cheat; public boolean cheat;
/** If true, resources are not consumed when building. */ /** If true, resources are not consumed when building. */
+11 -2
View File
@@ -101,6 +101,17 @@ public class SectorInfo{
/** Write contents of meta into main storage. */ /** Write contents of meta into main storage. */
public void write(){ public void write(){
//enable attack mode when there's a core.
if(state.rules.waveTeam.core() != null){
attack = true;
winWave = 0;
}
//if there are infinite waves and no win wave, add a win wave.
if(waves && winWave <= 0 && !attack){
winWave = 30;
}
state.wave = wave; state.wave = wave;
state.rules.waves = waves; state.rules.waves = waves;
state.rules.waveSpacing = waveSpacing; state.rules.waveSpacing = waveSpacing;
@@ -114,8 +125,6 @@ public class SectorInfo{
//ensure capacity. //ensure capacity.
entity.items.each((i, a) -> entity.items.set(i, Math.min(a, entity.storageCapacity))); entity.items.each((i, a) -> entity.items.set(i, Math.min(a, entity.storageCapacity)));
} }
//TODO write items.
} }
/** Prepare data for writing to a save. */ /** Prepare data for writing to a save. */
@@ -412,12 +412,12 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
if(sector.hasEnemyBase()){ if(sector.hasEnemyBase()){
basegen.generate(tiles, enemies.map(r -> tiles.getn(r.x, r.y)), tiles.get(spawn.x, spawn.y), state.rules.waveTeam, sector, difficulty); basegen.generate(tiles, enemies.map(r -> tiles.getn(r.x, r.y)), tiles.get(spawn.x, spawn.y), state.rules.waveTeam, sector, difficulty);
state.rules.attackMode = true; state.rules.attackMode = sector.info.attack = true;
}else{ }else{
state.rules.winWave = 15 * (int)Math.max(difficulty * 10, 1); state.rules.winWave = sector.info.winWave = 15 * (int)Math.max(difficulty * 10, 1);
} }
state.rules.waves = true; state.rules.waves = sector.info.waves = true;
//TODO better waves //TODO better waves
state.rules.spawns = DefaultWaves.generate(difficulty); state.rules.spawns = DefaultWaves.generate(difficulty);
@@ -23,6 +23,7 @@ public class SectorPreset extends UnlockableContent{
super(name); super(name);
this.generator = new FileMapGenerator(name); this.generator = new FileMapGenerator(name);
this.planet = planet; this.planet = planet;
sector %= planet.sectors.size;
this.sector = planet.sectors.get(sector); this.sector = planet.sectors.get(sector);
planet.preset(sector, this); planet.preset(sector, this);
@@ -14,6 +14,7 @@ import mindustry.entities.*;
import mindustry.entities.units.*; import mindustry.entities.units.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
import mindustry.logic.*;
import mindustry.type.*; import mindustry.type.*;
import mindustry.ui.*; import mindustry.ui.*;
import mindustry.world.blocks.*; import mindustry.world.blocks.*;
@@ -122,6 +123,12 @@ public class UnitFactory extends UnitBlock{
return currentPlan == -1 ? 0 : progress / plans.get(currentPlan).time; return currentPlan == -1 ? 0 : progress / plans.get(currentPlan).time;
} }
@Override
public Object senseObject(LAccess sensor){
if(sensor == LAccess.config) return currentPlan == -1 ? null : plans.get(currentPlan).unit;
return super.senseObject(sensor);
}
@Override @Override
public void buildConfiguration(Table table){ public void buildConfiguration(Table table){
Seq<UnitType> units = Seq.with(plans).map(u -> u.unit).filter(u -> u.unlockedNow()); Seq<UnitType> units = Seq.with(plans).map(u -> u.unit).filter(u -> u.unlockedNow());