Skip to content

Commit

Permalink
Add boulder field prop generator (#398)
Browse files Browse the repository at this point in the history
* Add boulder field prop generator

* Fix tests

* Add boulder field to high reclaim style
  • Loading branch information
BlackYps authored Jun 3, 2024
1 parent 9a301fa commit f316fd5
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.faforever.neroxis.generator;

import com.faforever.neroxis.generator.prop.BasicPropGenerator;
import com.faforever.neroxis.generator.prop.BoulderFieldPropGenerator;
import com.faforever.neroxis.generator.prop.EnemyCivPropGenerator;
import com.faforever.neroxis.generator.prop.HighReclaimPropGenerator;
import com.faforever.neroxis.generator.prop.LargeBattlePropGenerator;
Expand All @@ -17,6 +18,7 @@
@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),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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;

public class BoulderFieldPropGenerator extends BasicPropGenerator {
protected BooleanMask fieldBoulderMask;
protected BooleanMask boulderReclaimAreaMask;
protected BooleanMask stoneReclaimAreaMask;

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

@Override
public void placePropsWithExclusion() {
Pipeline.await(treeMask, cliffRockMask, fieldStoneMask, fieldBoulderMask, stoneReclaimAreaMask, boulderReclaimAreaMask);
DebugUtil.timedRun("com.faforever.neroxis.map.generator", "placeProps", () -> {
Biome biome = map.getBiome();
propPlacer.placeProps(treeMask.getFinalMask().subtract(noProps), biome.propMaterials().treeGroups(),
3f, 7f);
propPlacer.placeProps(cliffRockMask.getFinalMask(), biome.propMaterials().rocks(), .6f, 2.5f);
propPlacer.placeProps(fieldStoneMask.getFinalMask().subtract(noProps),
biome.propMaterials().rocks(), .5f, 2.5f);
propPlacer.placeProps(fieldBoulderMask.getFinalMask().subtract(noProps),
biome.propMaterials().boulders(), 5f, 10f);
propPlacer.placeProps(stoneReclaimAreaMask.getFinalMask().subtract(noProps),
biome.propMaterials().rocks(), 1f, 3f);
propPlacer.placeProps(boulderReclaimAreaMask.getFinalMask().subtract(noProps),
biome.propMaterials().boulders(), 3f, 5f);
});
}

@Override
protected void setupPropPipeline() {
int mapSize = map.getSize();
float reclaimDensity = random.nextFloat() * 0.6f + 0.4f;
int spawnCount = generatorParameters.spawnCount();
treeMask.setSize(mapSize / 16);
cliffRockMask.setSize(mapSize / 32);
fieldBoulderMask.setSize(mapSize / 4);
boulderReclaimAreaMask.setSize(mapSize / 4);

BooleanMask reclaimArea = new BooleanMask(1, random.nextLong(), symmetrySettings, "reclaimArea", true);
reclaimArea.setSize(mapSize / 4);
reclaimArea.randomize(reclaimDensity * spawnCount * .0005f).dilute(.8f, 4).setSize(mapSize + 1);
boulderReclaimAreaMask.randomize(0.5f).setSize(mapSize + 1).multiply(reclaimArea);
stoneReclaimAreaMask.init(boulderReclaimAreaMask).dilute(.5f, 2).subtract(boulderReclaimAreaMask).dilute(.5f);
boulderReclaimAreaMask.multiply(passableLand).fillEdge(10, false);
stoneReclaimAreaMask.multiply(passableLand).fillEdge(9, false);

cliffRockMask.randomize(reclaimDensity * .5f).setSize(mapSize + 1);
cliffRockMask.multiply(impassable).dilute(.5f, 10).subtract(impassable).multiply(passableLand);
fieldBoulderMask.randomize(reclaimDensity * spawnCount * .0025f).setSize(mapSize + 1);
fieldBoulderMask.multiply(passableLand).fillEdge(10, false);
fieldStoneMask.init(fieldBoulderMask).dilute(.5f, 6).subtract(fieldBoulderMask).erode(.3f);
treeMask.randomize((reclaimDensity + random.nextFloat()) / 2f * .15f).setSize(mapSize / 4);
treeMask.inflate(2).erode(.5f);
treeMask.setSize(mapSize + 1);
treeMask.subtract(boulderReclaimAreaMask).subtract(stoneReclaimAreaMask.copy().dilute(.8f, 2)).subtract(fieldBoulderMask);
treeMask.multiply(passableLand.copy().deflate(8)).fillEdge(8, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import com.faforever.neroxis.generator.WeightedOption;
import com.faforever.neroxis.generator.WeightedOptionsWithFallback;
import com.faforever.neroxis.generator.prop.BasicPropGenerator;
import com.faforever.neroxis.generator.prop.BoulderFieldPropGenerator;
import com.faforever.neroxis.generator.prop.EnemyCivPropGenerator;
import com.faforever.neroxis.generator.prop.HighReclaimPropGenerator;
import com.faforever.neroxis.generator.prop.LargeBattlePropGenerator;
import com.faforever.neroxis.generator.prop.NavyWrecksPropGenerator;
import com.faforever.neroxis.generator.prop.NeutralCivPropGenerator;
Expand All @@ -19,7 +21,9 @@ public class BasicStyleGenerator extends StyleGenerator {
protected WeightedOptionsWithFallback<PropGenerator> getPropGeneratorOptions() {
return WeightedOptionsWithFallback.of(new BasicPropGenerator(),
new WeightedOption<>(new BasicPropGenerator(), 1f),
new WeightedOption<>(new BoulderFieldPropGenerator(), 1f),
new WeightedOption<>(new EnemyCivPropGenerator(), .5f),
new WeightedOption<>(new HighReclaimPropGenerator(), .5f),
new WeightedOption<>(new LargeBattlePropGenerator(), 2f),
new WeightedOption<>(new NavyWrecksPropGenerator(), 2f),
new WeightedOption<>(new NeutralCivPropGenerator(), 1f),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.faforever.neroxis.generator.WeightedOption;
import com.faforever.neroxis.generator.WeightedOptionsWithFallback;
import com.faforever.neroxis.generator.prop.BasicPropGenerator;
import com.faforever.neroxis.generator.prop.BoulderFieldPropGenerator;
import com.faforever.neroxis.generator.prop.EnemyCivPropGenerator;
import com.faforever.neroxis.generator.prop.NavyWrecksPropGenerator;
import com.faforever.neroxis.generator.prop.NeutralCivPropGenerator;
Expand All @@ -29,11 +30,12 @@ protected WeightedOptionsWithFallback<TerrainGenerator> getTerrainGeneratorOptio
protected WeightedOptionsWithFallback<PropGenerator> getPropGeneratorOptions() {
return WeightedOptionsWithFallback.of(new BasicPropGenerator(),
new WeightedOption<>(new BasicPropGenerator(), 1f),
new WeightedOption<>(new BoulderFieldPropGenerator(), 1f),
new WeightedOption<>(new EnemyCivPropGenerator(), .5f),
new WeightedOption<>(new NavyWrecksPropGenerator(), 2),
new WeightedOption<>(new NeutralCivPropGenerator(), 1f),
new WeightedOption<>(new RockFieldPropGenerator(), 1f),
new WeightedOption<>(new SmallBattlePropGenerator(), 1f),
new WeightedOption<>(new EnemyCivPropGenerator(), .5f),
new WeightedOption<>(new NavyWrecksPropGenerator(), 2));
new WeightedOption<>(new SmallBattlePropGenerator(), 1f));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.faforever.neroxis.generator.WeightedOption;
import com.faforever.neroxis.generator.WeightedOptionsWithFallback;
import com.faforever.neroxis.generator.prop.BasicPropGenerator;
import com.faforever.neroxis.generator.prop.BoulderFieldPropGenerator;
import com.faforever.neroxis.generator.prop.EnemyCivPropGenerator;
import com.faforever.neroxis.generator.prop.NavyWrecksPropGenerator;
import com.faforever.neroxis.generator.prop.NeutralCivPropGenerator;
Expand Down Expand Up @@ -31,11 +32,12 @@ protected WeightedOptionsWithFallback<TerrainGenerator> getTerrainGeneratorOptio
protected WeightedOptionsWithFallback<PropGenerator> getPropGeneratorOptions() {
return WeightedOptionsWithFallback.of(new BasicPropGenerator(),
new WeightedOption<>(new BasicPropGenerator(), 1f),
new WeightedOption<>(new BoulderFieldPropGenerator(), 1f),
new WeightedOption<>(new EnemyCivPropGenerator(), .5f),
new WeightedOption<>(new NavyWrecksPropGenerator(), 2),
new WeightedOption<>(new NeutralCivPropGenerator(), 1f),
new WeightedOption<>(new RockFieldPropGenerator(), 1f),
new WeightedOption<>(new SmallBattlePropGenerator(), 1f),
new WeightedOption<>(new EnemyCivPropGenerator(), .5f),
new WeightedOption<>(new NavyWrecksPropGenerator(), 2));
new WeightedOption<>(new SmallBattlePropGenerator(), 1f));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.faforever.neroxis.generator.WeightedOption;
import com.faforever.neroxis.generator.WeightedOptionsWithFallback;
import com.faforever.neroxis.generator.prop.BasicPropGenerator;
import com.faforever.neroxis.generator.prop.BoulderFieldPropGenerator;
import com.faforever.neroxis.generator.prop.EnemyCivPropGenerator;
import com.faforever.neroxis.generator.prop.HighReclaimPropGenerator;
import com.faforever.neroxis.generator.prop.LargeBattlePropGenerator;
Expand All @@ -24,12 +25,13 @@ protected WeightedOptionsWithFallback<TerrainGenerator> getTerrainGeneratorOptio
protected WeightedOptionsWithFallback<PropGenerator> getPropGeneratorOptions() {
return WeightedOptionsWithFallback.of(new BasicPropGenerator(),
new WeightedOption<>(new BasicPropGenerator(), 1f),
new WeightedOption<>(new BoulderFieldPropGenerator(), 1f),
new WeightedOption<>(new EnemyCivPropGenerator(), .5f),
new WeightedOption<>(new HighReclaimPropGenerator(), .5f),
new WeightedOption<>(new LargeBattlePropGenerator(), 2f),
new WeightedOption<>(new NeutralCivPropGenerator(), 1f),
new WeightedOption<>(new RockFieldPropGenerator(), 1f),
new WeightedOption<>(new SmallBattlePropGenerator(), 1f),
new WeightedOption<>(new HighReclaimPropGenerator(), .5f));
new WeightedOption<>(new SmallBattlePropGenerator(), 1f));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.faforever.neroxis.generator.WeightedOption;
import com.faforever.neroxis.generator.WeightedOptionsWithFallback;
import com.faforever.neroxis.generator.prop.BoulderFieldPropGenerator;
import com.faforever.neroxis.generator.prop.HighReclaimPropGenerator;
import com.faforever.neroxis.generator.prop.PropGenerator;
import com.faforever.neroxis.generator.terrain.BasicTerrainGenerator;
Expand Down Expand Up @@ -30,7 +31,9 @@ protected WeightedOptionsWithFallback<TerrainGenerator> getTerrainGeneratorOptio

@Override
protected WeightedOptionsWithFallback<PropGenerator> getPropGeneratorOptions() {
return WeightedOptionsWithFallback.of(new HighReclaimPropGenerator());
return WeightedOptionsWithFallback.of(new HighReclaimPropGenerator(),
new WeightedOption<>(new HighReclaimPropGenerator(), 1f),
new WeightedOption<>(new BoulderFieldPropGenerator(), 1f));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.faforever.neroxis.generator.ParameterConstraints;
import com.faforever.neroxis.generator.WeightedOption;
import com.faforever.neroxis.generator.WeightedOptionsWithFallback;
import com.faforever.neroxis.generator.prop.BoulderFieldPropGenerator;
import com.faforever.neroxis.generator.prop.LargeBattlePropGenerator;
import com.faforever.neroxis.generator.prop.NavyWrecksPropGenerator;
import com.faforever.neroxis.generator.prop.NeutralCivPropGenerator;
Expand Down Expand Up @@ -30,11 +31,12 @@ protected WeightedOptionsWithFallback<TerrainGenerator> getTerrainGeneratorOptio
@Override
protected WeightedOptionsWithFallback<PropGenerator> getPropGeneratorOptions() {
return WeightedOptionsWithFallback.of(new LargeBattlePropGenerator(),
new WeightedOption<>(new BoulderFieldPropGenerator(), 1f),
new WeightedOption<>(new LargeBattlePropGenerator(), 2f),
new WeightedOption<>(new NavyWrecksPropGenerator(), 2f),
new WeightedOption<>(new NeutralCivPropGenerator(), 1f),
new WeightedOption<>(new RockFieldPropGenerator(), 1f),
new WeightedOption<>(new SmallBattlePropGenerator(), 1f),
new WeightedOption<>(new NavyWrecksPropGenerator(), 2f));
new WeightedOption<>(new SmallBattlePropGenerator(), 1f));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.faforever.neroxis.generator.WeightedOption;
import com.faforever.neroxis.generator.WeightedOptionsWithFallback;
import com.faforever.neroxis.generator.prop.BasicPropGenerator;
import com.faforever.neroxis.generator.prop.BoulderFieldPropGenerator;
import com.faforever.neroxis.generator.prop.EnemyCivPropGenerator;
import com.faforever.neroxis.generator.prop.HighReclaimPropGenerator;
import com.faforever.neroxis.generator.prop.LargeBattlePropGenerator;
Expand All @@ -24,11 +25,12 @@ protected WeightedOptionsWithFallback<TerrainGenerator> getTerrainGeneratorOptio
protected WeightedOptionsWithFallback<PropGenerator> getPropGeneratorOptions() {
return WeightedOptionsWithFallback.of(new BasicPropGenerator(),
new WeightedOption<>(new BasicPropGenerator(), 1f),
new WeightedOption<>(new BoulderFieldPropGenerator(), 1f),
new WeightedOption<>(new EnemyCivPropGenerator(), .5f),
new WeightedOption<>(new HighReclaimPropGenerator(), .5f),
new WeightedOption<>(new LargeBattlePropGenerator(), 2f),
new WeightedOption<>(new NeutralCivPropGenerator(), 1f),
new WeightedOption<>(new RockFieldPropGenerator(), 1f),
new WeightedOption<>(new SmallBattlePropGenerator(), 1f),
new WeightedOption<>(new HighReclaimPropGenerator(), .5f));
new WeightedOption<>(new SmallBattlePropGenerator(), 1f));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.faforever.neroxis.generator.WeightedOption;
import com.faforever.neroxis.generator.WeightedOptionsWithFallback;
import com.faforever.neroxis.generator.prop.BasicPropGenerator;
import com.faforever.neroxis.generator.prop.BoulderFieldPropGenerator;
import com.faforever.neroxis.generator.prop.EnemyCivPropGenerator;
import com.faforever.neroxis.generator.prop.HighReclaimPropGenerator;
import com.faforever.neroxis.generator.prop.LargeBattlePropGenerator;
Expand Down Expand Up @@ -49,13 +50,14 @@ protected WeightedOptionsWithFallback<TerrainGenerator> getTerrainGeneratorOptio
protected WeightedOptionsWithFallback<PropGenerator> getPropGeneratorOptions() {
return WeightedOptionsWithFallback.of(new BasicPropGenerator(),
new WeightedOption<>(new BasicPropGenerator(), 1f),
new WeightedOption<>(new NavyWrecksPropGenerator(), 2f),
new WeightedOption<>(new BoulderFieldPropGenerator(), 1f),
new WeightedOption<>(new EnemyCivPropGenerator(), .5f),
new WeightedOption<>(new HighReclaimPropGenerator(), .5f),
new WeightedOption<>(new LargeBattlePropGenerator(), 2f),
new WeightedOption<>(new NavyWrecksPropGenerator(), 2f),
new WeightedOption<>(new NeutralCivPropGenerator(), 1f),
new WeightedOption<>(new RockFieldPropGenerator(), 1f),
new WeightedOption<>(new SmallBattlePropGenerator(), 1f),
new WeightedOption<>(new HighReclaimPropGenerator(), .5f));
new WeightedOption<>(new SmallBattlePropGenerator(), 1f));
}
}

Expand Down
Loading

0 comments on commit f316fd5

Please sign in to comment.