Various base generation tweaks

This commit is contained in:
Anuken 2020-09-08 16:25:01 -04:00
parent ef617b7fd2
commit ac88d84322
8 changed files with 28 additions and 16 deletions

View File

@ -92,7 +92,7 @@ public class BaseRegistry{
}
}
cores.sort(Structs.comps(Structs.comparingFloat(b -> b.core.health), Structs.comparingFloat(b -> b.tier)));
cores.sort(b -> b.tier);
parts.sort();
reqParts.each((key, arr) -> arr.sort());
}

View File

@ -15,6 +15,7 @@ import mindustry.world.blocks.defense.*;
import mindustry.world.blocks.environment.*;
import mindustry.world.blocks.power.*;
import mindustry.world.blocks.production.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
@ -29,7 +30,7 @@ public class BaseGenerator{
private ObjectMap<Item, Floor> oreFloors = new ObjectMap<>();
private Seq<Tile> cores;
public void generate(Tiles tiles, Seq<Tile> cores, Tile spawn, Team team, Sector sector){
public void generate(Tiles tiles, Seq<Tile> cores, Tile spawn, Team team, Sector sector, float difficulty){
this.tiles = tiles;
this.team = team;
this.cores = cores;
@ -50,10 +51,16 @@ public class BaseGenerator{
//TODO limit base size
float costBudget = 1000;
Seq<Block> wallsSmall = content.blocks().select(b -> b instanceof Wall && b.size == 1);
Seq<Block> wallsLarge = content.blocks().select(b -> b instanceof Wall && b.size == 2);
Seq<Block> wallsSmall = content.blocks().select(b -> b instanceof Wall && b.size == 1 && b.buildVisibility == BuildVisibility.shown && !(b instanceof Door));
Seq<Block> wallsLarge = content.blocks().select(b -> b instanceof Wall && b.size == 2 && b.buildVisibility == BuildVisibility.shown && !(b instanceof Door));
float bracket = 0.1f;
//sort by cost for correct fraction
wallsSmall.sort(b -> b.buildCost);
wallsLarge.sort(b -> b.buildCost);
//TODO proper difficulty selection
float bracket = difficulty;
float bracketRange = 0.2f;
int wallAngle = 70; //180 for full coverage
double resourceChance = 0.5;
double nonResourceChance = 0.0005;
@ -80,14 +87,15 @@ public class BaseGenerator{
|| (tile.floor().liquidDrop != null && Mathf.chance(nonResourceChance * 2))) && Mathf.chance(resourceChance)){
Seq<BasePart> parts = bases.forResource(tile.drop() != null ? tile.drop() : tile.floor().liquidDrop);
if(!parts.isEmpty()){
tryPlace(parts.random(), tile.x, tile.y);
tryPlace(parts.getFrac(bracket + Mathf.range(bracketRange)), tile.x, tile.y);
}
}else if(Mathf.chance(nonResourceChance)){
tryPlace(bases.parts.random(), tile.x, tile.y);
tryPlace(bases.parts.getFrac(bracket + Mathf.range(bracketRange)), tile.x, tile.y);
}
});
//replace walls with the correct type
//replace walls with the correct type (disabled)
if(false)
pass(tile -> {
if(tile.block() instanceof Wall && tile.team() == team && tile.block() != wall && tile.block() != wallLarge){
tile.setBlock(tile.block().size == 2 ? wallLarge : wall, team);

View File

@ -284,11 +284,11 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
float difficulty = sector.baseCoverage;
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);
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;
}else{
state.rules.winWave = 15 * (int)Math.max(difficulty, 1);
state.rules.winWave = 15 * (int)Math.max(difficulty * 5, 1);
}
state.rules.waves = true;
@ -296,11 +296,13 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
//TODO better waves
state.rules.spawns = defaultWaves.get();
float waveScaling = 1f + difficulty*2;
//scale up the spawning base on difficulty (this is just for testing)
for(SpawnGroup group : state.rules.spawns){
group.unitAmount *= difficulty;
group.unitAmount *= waveScaling;
if(group.unitScaling != SpawnGroup.never){
group.unitScaling /= difficulty;
group.unitScaling /= waveScaling;
}
}
}

View File

@ -205,7 +205,7 @@ public class Planet extends UnlockableContent{
sum += 2f;
}
sector.baseCoverage = sum;
sector.baseCoverage = Mathf.clamp(sum / 5f);
}
}

View File

@ -32,6 +32,7 @@ public class Sector{
public @Nullable SaveSlot save;
public @Nullable SectorPreset preset;
/** Number 0-1 indicating the difficulty based on nearby bases. */
public float baseCoverage;
//TODO implement a dynamic launch period

View File

@ -127,10 +127,11 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
//draw all sector stuff
for(Sector sec : planet.sectors){
if(selectAlpha > 0.01f){
if(canLaunch(sec) || sec.unlocked()){
if(sec.baseCoverage > 0){
planets.fill(sec, Tmp.c1.set(Team.crux.color).a(0.1f * sec.baseCoverage * selectAlpha), -0.002f);
planets.fill(sec, Tmp.c1.set(Team.crux.color).a(0.5f * sec.baseCoverage * selectAlpha), -0.002f);
}
Color color =

View File

@ -219,7 +219,7 @@ public class HudFragment extends Fragment{
//core items
parent.fill(t -> {
t.top().add(coreItems);
t.visible(() -> Core.settings.getBool("coreitems") && !mobile && !state.isPaused());
t.visible(() -> Core.settings.getBool("coreitems") && !mobile && !state.isPaused() && shown);
});
//spawner warning

View File

@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=5c7c5e8d8728880e20f9c39a888ee03612dc1071
archash=fc3cc66e77ebf7d10ac13e615403d29783028b8e