Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement spawn placement after terrain generation #402

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.faforever.neroxis.generator.prop.LargeBattlePropGenerator;
import com.faforever.neroxis.generator.prop.NavyWrecksPropGenerator;
import com.faforever.neroxis.generator.prop.NeutralCivPropGenerator;
import com.faforever.neroxis.generator.prop.PropGenerator;
import com.faforever.neroxis.generator.prop.RockFieldPropGenerator;
import com.faforever.neroxis.generator.prop.SmallBattlePropGenerator;
import lombok.AllArgsConstructor;
Expand All @@ -17,16 +18,15 @@
@Getter
@AllArgsConstructor
public enum PropStyle {
BASIC(BasicPropGenerator.class, BasicPropGenerator::new),
BOULDER_FIELD(BoulderFieldPropGenerator.class, BoulderFieldPropGenerator::new),
ENEMY_CIV(EnemyCivPropGenerator.class, EnemyCivPropGenerator::new),
HIGH_RECLAIM(HighReclaimPropGenerator.class, HighReclaimPropGenerator::new),
LARGE_BATTLE(LargeBattlePropGenerator.class, LargeBattlePropGenerator::new),
NAVY_WRECKS(NavyWrecksPropGenerator.class, NavyWrecksPropGenerator::new),
NEUTRAL_CIV(NeutralCivPropGenerator.class, NeutralCivPropGenerator::new),
ROCK_FIELD(RockFieldPropGenerator.class, RockFieldPropGenerator::new),
SMALL_BATTLE(SmallBattlePropGenerator.class, SmallBattlePropGenerator::new);
BASIC(BasicPropGenerator::new),
BOULDER_FIELD(BoulderFieldPropGenerator::new),
ENEMY_CIV(EnemyCivPropGenerator::new),
HIGH_RECLAIM(HighReclaimPropGenerator::new),
LARGE_BATTLE(LargeBattlePropGenerator::new),
NAVY_WRECKS(NavyWrecksPropGenerator::new),
NEUTRAL_CIV(NeutralCivPropGenerator::new),
ROCK_FIELD(RockFieldPropGenerator::new),
SMALL_BATTLE(SmallBattlePropGenerator::new);

private final Class<? extends com.faforever.neroxis.generator.prop.PropGenerator> generatorClass;
private final Supplier<com.faforever.neroxis.generator.prop.PropGenerator> generatorSupplier;
private final Supplier<PropGenerator> generatorSupplier;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.faforever.neroxis.generator.resource.BasicResourceGenerator;
import com.faforever.neroxis.generator.resource.LowMexResourceGenerator;
import com.faforever.neroxis.generator.resource.ResourceGenerator;
import com.faforever.neroxis.generator.resource.WaterMexResourceGenerator;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand All @@ -11,10 +12,9 @@
@Getter
@AllArgsConstructor
public enum ResourceStyle {
BASIC(BasicResourceGenerator.class, BasicResourceGenerator::new),
LOW_MEX(LowMexResourceGenerator.class, LowMexResourceGenerator::new),
WATER_MEX(WaterMexResourceGenerator.class, WaterMexResourceGenerator::new);
BASIC(BasicResourceGenerator::new),
LOW_MEX(LowMexResourceGenerator::new),
WATER_MEX(WaterMexResourceGenerator::new);

private final Class<? extends com.faforever.neroxis.generator.resource.ResourceGenerator> generatorClass;
private final Supplier<com.faforever.neroxis.generator.resource.ResourceGenerator> generatorSupplier;
private final Supplier<ResourceGenerator> generatorSupplier;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.faforever.neroxis.generator.terrain.MountainRangeTerrainGenerator;
import com.faforever.neroxis.generator.terrain.OneIslandTerrainGenerator;
import com.faforever.neroxis.generator.terrain.SmallIslandsTerrainGenerator;
import com.faforever.neroxis.generator.terrain.SpawnLastTerrainGenerator;
import com.faforever.neroxis.generator.terrain.TerrainGenerator;
import com.faforever.neroxis.generator.terrain.ValleyTerrainGenerator;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand All @@ -19,18 +21,18 @@
@Getter
@AllArgsConstructor
public enum TerrainStyle {
BASIC(BasicTerrainGenerator.class, BasicTerrainGenerator::new),
BIG_ISLANDS(BigIslandsTerrainGenerator.class, BigIslandsTerrainGenerator::new),
CENTER_LAKE(CenterLakeTerrainGenerator.class, CenterLakeTerrainGenerator::new),
DROP_PLATEAU(DropPlateauTerrainGenerator.class, DropPlateauTerrainGenerator::new),
FLOODED(FloodedTerrainGenerator.class, FloodedTerrainGenerator::new),
LAND_BRIDGE(LandBridgeTerrainGenerator.class, LandBridgeTerrainGenerator::new),
LITTLE_MOUNTAIN(LittleMountainTerrainGenerator.class, LittleMountainTerrainGenerator::new),
MOUNTAIN_RANGE(MountainRangeTerrainGenerator.class, MountainRangeTerrainGenerator::new),
ONE_ISLAND(OneIslandTerrainGenerator.class, OneIslandTerrainGenerator::new),
SMALL_ISLANDS(SmallIslandsTerrainGenerator.class, SmallIslandsTerrainGenerator::new),
VALLEY(ValleyTerrainGenerator.class, ValleyTerrainGenerator::new);
BASIC(BasicTerrainGenerator::new),
SPAWN_LAST(SpawnLastTerrainGenerator::new),
BIG_ISLANDS(BigIslandsTerrainGenerator::new),
CENTER_LAKE(CenterLakeTerrainGenerator::new),
DROP_PLATEAU(DropPlateauTerrainGenerator::new),
FLOODED(FloodedTerrainGenerator::new),
LAND_BRIDGE(LandBridgeTerrainGenerator::new),
LITTLE_MOUNTAIN(LittleMountainTerrainGenerator::new),
MOUNTAIN_RANGE(MountainRangeTerrainGenerator::new),
ONE_ISLAND(OneIslandTerrainGenerator::new),
SMALL_ISLANDS(SmallIslandsTerrainGenerator::new),
VALLEY(ValleyTerrainGenerator::new);

private final Class<? extends com.faforever.neroxis.generator.terrain.TerrainGenerator> generatorClass;
private final Supplier<com.faforever.neroxis.generator.terrain.TerrainGenerator> generatorSupplier;
private final Supplier<TerrainGenerator> generatorSupplier;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.faforever.neroxis.generator.texture.StonesTextureGenerator;
import com.faforever.neroxis.generator.texture.SunsetTextureGenerator;
import com.faforever.neroxis.generator.texture.SyrtisTextureGenerator;
import com.faforever.neroxis.generator.texture.TextureGenerator;
import com.faforever.neroxis.generator.texture.WindingRiverTextureGenerator;
import com.faforever.neroxis.generator.texture.WonderTextureGenerator;
import lombok.AllArgsConstructor;
Expand All @@ -33,6 +34,6 @@ public enum TextureStyle {
WINDINGRIVER(WindingRiverTextureGenerator::new, "WindingRiver"),
WONDER(WonderTextureGenerator::new, "Wonder");

private final Supplier<com.faforever.neroxis.generator.texture.TextureGenerator> generatorSupplier;
private final Supplier<TextureGenerator> generatorSupplier;
private final String folderName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.faforever.neroxis.mask.FloatMask;

import java.util.Random;
import java.util.concurrent.CompletableFuture;

public abstract class DecalGenerator implements HasParameterConstraints {
protected SCMap map;
Expand All @@ -23,6 +24,12 @@ public abstract class DecalGenerator implements HasParameterConstraints {
protected BooleanMask fieldDecal;
protected BooleanMask slopeDecal;

private CompletableFuture<Void> decalsPlacedFuture;

public CompletableFuture<Void> getDecalsPlacedFuture() {
return decalsPlacedFuture.copy();
}

public void initialize(SCMap map, long seed, GeneratorParameters generatorParameters,
SymmetrySettings symmetrySettings, TerrainGenerator terrainGenerator) {
this.map = map;
Expand All @@ -34,9 +41,17 @@ public void initialize(SCMap map, long seed, GeneratorParameters generatorParame
fieldDecal = new BooleanMask(1, random.nextLong(), symmetrySettings, "fieldDecal", true);
slopeDecal = new BooleanMask(1, random.nextLong(), symmetrySettings, "slopeDecal", true);
decalPlacer = new DecalPlacer(map, random.nextLong());

afterInitialize();

decalsPlacedFuture = CompletableFuture.runAsync(this::placeDecals);

setupPipeline();
}

public abstract void setupPipeline();
protected void afterInitialize() {}

protected abstract void setupPipeline();

public abstract void placeDecals();
protected abstract void placeDecals();
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package com.faforever.neroxis.generator.prop;

import com.faforever.neroxis.biomes.Biome;
import com.faforever.neroxis.generator.GeneratorParameters;
import com.faforever.neroxis.generator.terrain.TerrainGenerator;
import com.faforever.neroxis.map.SCMap;
import com.faforever.neroxis.map.SymmetrySettings;
import com.faforever.neroxis.mask.BooleanMask;
import com.faforever.neroxis.util.DebugUtil;
import com.faforever.neroxis.util.Pipeline;
Expand All @@ -16,9 +12,7 @@ public class BasicPropGenerator extends PropGenerator {
protected BooleanMask noProps;

@Override
public void initialize(SCMap map, long seed, GeneratorParameters generatorParameters,
SymmetrySettings symmetrySettings, TerrainGenerator terrainGenerator) {
super.initialize(map, seed, generatorParameters, symmetrySettings, terrainGenerator);
protected void afterInitialize() {
treeMask = new BooleanMask(1, random.nextLong(), symmetrySettings, "treeMask", true);
cliffRockMask = new BooleanMask(1, random.nextLong(), symmetrySettings, "cliffRockMask", true);
fieldStoneMask = new BooleanMask(1, random.nextLong(), symmetrySettings, "fieldStoneMask", true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package com.faforever.neroxis.generator.prop;

import com.faforever.neroxis.biomes.Biome;
import com.faforever.neroxis.generator.GeneratorParameters;
import com.faforever.neroxis.generator.terrain.TerrainGenerator;
import com.faforever.neroxis.map.SCMap;
import com.faforever.neroxis.map.SymmetrySettings;
import com.faforever.neroxis.mask.BooleanMask;
import com.faforever.neroxis.util.DebugUtil;
import com.faforever.neroxis.util.Pipeline;
Expand All @@ -15,9 +11,8 @@ public class BoulderFieldPropGenerator extends BasicPropGenerator {
protected BooleanMask stoneReclaimAreaMask;

@Override
public void initialize(SCMap map, long seed, GeneratorParameters generatorParameters,
SymmetrySettings symmetrySettings, TerrainGenerator terrainGenerator) {
super.initialize(map, seed, generatorParameters, symmetrySettings, terrainGenerator);
protected void afterInitialize() {
super.afterInitialize();
fieldBoulderMask = new BooleanMask(1, random.nextLong(), symmetrySettings, "fieldBoulderMask", true);
boulderReclaimAreaMask = new BooleanMask(1, random.nextLong(), symmetrySettings, "boulderReclaimAreaMask",
true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.faforever.neroxis.generator.prop;

import com.faforever.neroxis.generator.GeneratorParameters;
import com.faforever.neroxis.generator.Visibility;
import com.faforever.neroxis.generator.terrain.TerrainGenerator;
import com.faforever.neroxis.map.Army;
import com.faforever.neroxis.map.Group;
import com.faforever.neroxis.map.SCMap;
import com.faforever.neroxis.map.SymmetrySettings;
import com.faforever.neroxis.map.SymmetryType;
import com.faforever.neroxis.map.placement.UnitPlacer;
import com.faforever.neroxis.mask.BooleanMask;
import com.faforever.neroxis.util.DebugUtil;
Expand All @@ -19,9 +16,8 @@ public class EnemyCivPropGenerator extends BasicPropGenerator {
protected BooleanMask noBases;

@Override
public void initialize(SCMap map, long seed, GeneratorParameters generatorParameters,
SymmetrySettings symmetrySettings, TerrainGenerator terrainGenerator) {
super.initialize(map, seed, generatorParameters, symmetrySettings, terrainGenerator);
protected void afterInitialize() {
super.afterInitialize();
baseMask = new BooleanMask(1, random.nextLong(), symmetrySettings, "baseMask", true);
noBases = new BooleanMask(1, random.nextLong(), symmetrySettings);
}
Expand Down Expand Up @@ -66,7 +62,7 @@ protected void setupCivilianPipeline() {
if (!map.isUnexplored()) {
baseMask.randomize(.005f).setSize(mapSize + 1);
baseMask.multiply(passableLand.copy().subtract(unbuildable).deflate(24))
.fillCenter(32, false)
.fillCenter(32, false, SymmetryType.TEAM)
.fillEdge(32, false);
} else {
baseMask.setSize(mapSize + 1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.faforever.neroxis.generator.prop;

import com.faforever.neroxis.generator.GeneratorParameters;
import com.faforever.neroxis.generator.Visibility;
import com.faforever.neroxis.generator.terrain.TerrainGenerator;
import com.faforever.neroxis.map.Army;
import com.faforever.neroxis.map.Group;
import com.faforever.neroxis.map.SCMap;
import com.faforever.neroxis.map.SymmetrySettings;
import com.faforever.neroxis.map.SymmetryType;
import com.faforever.neroxis.map.placement.UnitPlacer;
import com.faforever.neroxis.mask.BooleanMask;
import com.faforever.neroxis.util.DebugUtil;
Expand All @@ -17,9 +14,8 @@ public class LargeBattlePropGenerator extends ReducedNaturalPropGenerator {
protected BooleanMask noWrecks;

@Override
public void initialize(SCMap map, long seed, GeneratorParameters generatorParameters,
SymmetrySettings symmetrySettings, TerrainGenerator terrainGenerator) {
super.initialize(map, seed, generatorParameters, symmetrySettings, terrainGenerator);
protected void afterInitialize() {
super.afterInitialize();
landWreckMask = new BooleanMask(1, random.nextLong(), symmetrySettings, "landWreckMask", true);
noWrecks = new BooleanMask(1, random.nextLong(), symmetrySettings);
}
Expand Down Expand Up @@ -52,7 +48,7 @@ protected void setupWreckPipeline() {
int mapSize = map.getSize();

landWreckMask.setSize(mapSize + 1);
landWreckMask.fillCenter(196, true);
landWreckMask.fillCenter(196, true, SymmetryType.TEAM);
map.getSpawns().forEach(spawn -> landWreckMask.fillCircle(spawn.getPosition(), 128, false));
landWreckMask.multiply(passableLand).space(96, 128);
landWreckMask.inflate(20f).setSize(mapSize / 4);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.faforever.neroxis.generator.prop;

import com.faforever.neroxis.generator.GeneratorParameters;
import com.faforever.neroxis.generator.Visibility;
import com.faforever.neroxis.generator.terrain.TerrainGenerator;
import com.faforever.neroxis.map.Army;
import com.faforever.neroxis.map.Group;
import com.faforever.neroxis.map.SCMap;
import com.faforever.neroxis.map.SymmetrySettings;
import com.faforever.neroxis.map.SymmetryType;
import com.faforever.neroxis.map.placement.UnitPlacer;
import com.faforever.neroxis.mask.BooleanMask;
import com.faforever.neroxis.util.DebugUtil;
Expand All @@ -18,9 +15,8 @@ public class NavyWrecksPropGenerator extends ReducedNaturalPropGenerator {
protected BooleanMask noWrecks;

@Override
public void initialize(SCMap map, long seed, GeneratorParameters generatorParameters,
SymmetrySettings symmetrySettings, TerrainGenerator terrainGenerator) {
super.initialize(map, seed, generatorParameters, symmetrySettings, terrainGenerator);
protected void afterInitialize() {
super.afterInitialize();
t2NavyWreckMask = new BooleanMask(1, random.nextLong(), symmetrySettings, "t2NavyWreckMask", true);
navyFactoryWreckMask = new BooleanMask(1, random.nextLong(), symmetrySettings, "navyFactoryWreckMask", true);
noWrecks = new BooleanMask(1, random.nextLong(), symmetrySettings);
Expand Down Expand Up @@ -59,7 +55,7 @@ protected void setupWreckPipeline() {
navyFactoryWreckMask.add(passableLand.copy().inflate(48))
.subtract(passableLand.copy().inflate(16))
.fillEdge(20, false)
.fillCenter(32, false);
.fillCenter(32, false, SymmetryType.TEAM);
navyFactoryWreckMask.flipValues((navyWreckDensity * .8f + random.nextFloat() * .2f) * .001f).inflate(8);
t2NavyWreckMask.add(passableLand.copy().inflate(8).outline()).fillEdge(20, false);
t2NavyWreckMask.flipValues((navyWreckDensity * .8f + random.nextFloat() * .2f) * .001f).inflate(8);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.faforever.neroxis.generator.prop;

import com.faforever.neroxis.generator.GeneratorParameters;
import com.faforever.neroxis.generator.Visibility;
import com.faforever.neroxis.generator.terrain.TerrainGenerator;
import com.faforever.neroxis.map.Army;
import com.faforever.neroxis.map.Group;
import com.faforever.neroxis.map.SCMap;
import com.faforever.neroxis.map.SymmetrySettings;
import com.faforever.neroxis.map.SymmetryType;
import com.faforever.neroxis.map.placement.UnitPlacer;
import com.faforever.neroxis.mask.BooleanMask;
import com.faforever.neroxis.util.DebugUtil;
Expand All @@ -19,9 +16,8 @@ public class NeutralCivPropGenerator extends BasicPropGenerator {
protected BooleanMask noCivs;

@Override
public void initialize(SCMap map, long seed, GeneratorParameters generatorParameters,
SymmetrySettings symmetrySettings, TerrainGenerator terrainGenerator) {
super.initialize(map, seed, generatorParameters, symmetrySettings, terrainGenerator);
protected void afterInitialize() {
super.afterInitialize();
civReclaimMask = new BooleanMask(1, random.nextLong(), symmetrySettings, "civReclaimMask", true);

noCivs = new BooleanMask(1, random.nextLong(), symmetrySettings);
Expand Down Expand Up @@ -67,7 +63,7 @@ protected void setupCivilianPipeline() {
if (!map.isUnexplored()) {
civReclaimMask.randomize(.005f).setSize(mapSize + 1);
civReclaimMask.multiply(passableLand.copy().subtract(unbuildable).deflate(24))
.fillCenter(32, false)
.fillCenter(32, false, SymmetryType.TEAM)
.fillEdge(64, false);
} else {
civReclaimMask.setSize(mapSize + 1);
Expand Down
Loading
Loading