Skip to content

Commit

Permalink
Fix issues with pathing
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheikah45 committed Sep 15, 2024
1 parent 6673747 commit eb8c5a2
Show file tree
Hide file tree
Showing 28 changed files with 397 additions and 261 deletions.
24 changes: 19 additions & 5 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
import com.faforever.neroxis.brushes.Brushes;
import com.faforever.neroxis.generator.GeneratorParameters;
import com.faforever.neroxis.map.SCMap;
import com.faforever.neroxis.map.Spawn;
import com.faforever.neroxis.map.SymmetrySettings;
import com.faforever.neroxis.mask.BooleanMask;
import com.faforever.neroxis.mask.FloatMask;
import com.faforever.neroxis.mask.MapMaskMethods;
import com.faforever.neroxis.util.vector.Vector2;
import com.faforever.neroxis.util.vector.Vector3;

import java.util.List;

public class BasicTerrainGenerator extends TerrainGenerator {
protected BooleanMask spawnLandMask;
protected BooleanMask spawnPlateauMask;
Expand Down Expand Up @@ -143,9 +147,18 @@ protected void teamConnectionsSetup() {
int numTeammateConnections = 1;
connections.setSize(map.getSize() + 1);

MapMaskMethods.connectTeamsAroundCenter(map, random.nextLong(), connections, minMiddlePoints, maxMiddlePoints,
List<Vector2> team0SpawnLocations = map.getSpawns()
.stream()
.filter(spawn -> spawn.getTeamID() == 0)
.map(Spawn::getPosition)
.map(Vector2::new)
.toList();

MapMaskMethods.connectTeamsAroundCenter(team0SpawnLocations, random.nextLong(), connections, minMiddlePoints,
maxMiddlePoints,
numTeamConnections, maxStepSize, 32);
MapMaskMethods.connectTeammates(map, random.nextLong(), connections, maxMiddlePoints, numTeammateConnections,
MapMaskMethods.connectTeammates(team0SpawnLocations, random.nextLong(), connections, maxMiddlePoints,
numTeammateConnections,
maxStepSize);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.faforever.neroxis.generator.terrain;

import com.faforever.neroxis.generator.ParameterConstraints;
import com.faforever.neroxis.map.Spawn;
import com.faforever.neroxis.mask.BooleanMask;
import com.faforever.neroxis.mask.MapMaskMethods;
import com.faforever.neroxis.util.vector.Vector2;

import java.util.List;

public class BigIslandsTerrainGenerator extends PathedTerrainGenerator {

Expand All @@ -24,7 +28,16 @@ protected void landSetup() {
BooleanMask islands = new BooleanMask(mapSize / 4, random.nextLong(), symmetrySettings, "islands", true);

land.setSize(mapSize + 1);
MapMaskMethods.pathAroundSpawns(map, random.nextLong(), land, maxStepSize, numPaths, maxMiddlePoints, bound,

List<Vector2> team0SpawnLocations = map.getSpawns()
.stream()
.filter(spawn -> spawn.getTeamID() == 0)
.map(Spawn::getPosition)
.map(Vector2::new)
.toList();

MapMaskMethods.pathAroundSpawns(team0SpawnLocations, random.nextLong(), land, maxStepSize, numPaths,
maxMiddlePoints, bound,
(float) StrictMath.PI / 2);
land.inflate(maxStepSize).setSize(mapSize / 4);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

import com.faforever.neroxis.generator.GeneratorParameters;
import com.faforever.neroxis.map.SCMap;
import com.faforever.neroxis.map.Spawn;
import com.faforever.neroxis.map.SymmetrySettings;
import com.faforever.neroxis.mask.MapMaskMethods;
import com.faforever.neroxis.util.vector.Vector2;

import java.util.List;

public class DropPlateauTerrainGenerator extends PathedTerrainGenerator {

Expand Down Expand Up @@ -31,9 +35,18 @@ protected void teamConnectionsSetup() {

connections.setSize(mapSize + 1);

MapMaskMethods.connectTeamsAroundCenter(map, random.nextLong(), connections, minMiddlePoints, maxMiddlePoints,
List<Vector2> team0SpawnLocations = map.getSpawns()
.stream()
.filter(spawn -> spawn.getTeamID() == 0)
.map(Spawn::getPosition)
.map(Vector2::new)
.toList();

MapMaskMethods.connectTeamsAroundCenter(team0SpawnLocations, random.nextLong(), connections, minMiddlePoints,
maxMiddlePoints,
numTeamConnections, maxStepSize, 32);
MapMaskMethods.connectTeammates(map, random.nextLong(), connections, maxMiddlePoints, numTeammateConnections,
MapMaskMethods.connectTeammates(team0SpawnLocations, random.nextLong(), connections, maxMiddlePoints,
numTeammateConnections,
maxStepSize);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.faforever.neroxis.generator.terrain;

import com.faforever.neroxis.generator.ParameterConstraints;
import com.faforever.neroxis.map.Spawn;
import com.faforever.neroxis.mask.MapMaskMethods;
import com.faforever.neroxis.util.vector.Vector2;

import java.util.List;

public class LandBridgeTerrainGenerator extends PathedTerrainGenerator {

Expand All @@ -20,9 +24,18 @@ protected void landSetup() {
int numPaths = 32 / generatorParameters.spawnCount();

land.setSize(mapSize + 1);
MapMaskMethods.connectTeammates(map, random.nextLong(), land, 8, 2, maxStepSize);
MapMaskMethods.connectTeams(map, random.nextLong(), land, 0, 2, 1, maxStepSize);
MapMaskMethods.pathAroundSpawns(map, random.nextLong(), land, maxStepSize, numPaths, 4, mapSize / 6,

List<Vector2> team0SpawnLocations = map.getSpawns()
.stream()
.filter(spawn -> spawn.getTeamID() == 0)
.map(Spawn::getPosition)
.map(Vector2::new)
.toList();

MapMaskMethods.connectTeammates(team0SpawnLocations, random.nextLong(), land, 8, 2, maxStepSize);
MapMaskMethods.connectTeams(team0SpawnLocations, random.nextLong(), land, 0, 2, 1, maxStepSize);
MapMaskMethods.pathAroundSpawns(team0SpawnLocations, random.nextLong(), land, maxStepSize, numPaths, 4,
mapSize / 6,
(float) (StrictMath.PI / 2f));
land.inflate(maxStepSize);
land.setSize(mapSize / 8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
import com.faforever.neroxis.generator.GeneratorParameters;
import com.faforever.neroxis.generator.ParameterConstraints;
import com.faforever.neroxis.map.SCMap;
import com.faforever.neroxis.map.Spawn;
import com.faforever.neroxis.map.SymmetrySettings;
import com.faforever.neroxis.mask.MapMaskMethods;
import com.faforever.neroxis.util.vector.Vector2;

import java.util.List;

public class OneIslandTerrainGenerator extends PathedTerrainGenerator {

Expand All @@ -31,9 +35,18 @@ protected void teamConnectionsSetup() {
int numTeammateConnections = 1;
connections.setSize(map.getSize() + 1);

MapMaskMethods.connectTeams(map, random.nextLong(), connections, minMiddlePoints, maxMiddlePoints,
List<Vector2> team0SpawnLocations = map.getSpawns()
.stream()
.filter(spawn -> spawn.getTeamID() == 0)
.map(Spawn::getPosition)
.map(Vector2::new)
.toList();

MapMaskMethods.connectTeams(team0SpawnLocations, random.nextLong(), connections, minMiddlePoints,
maxMiddlePoints,
numTeamConnections, maxStepSize);
MapMaskMethods.connectTeammates(map, random.nextLong(), connections, maxMiddlePoints, numTeammateConnections,
MapMaskMethods.connectTeammates(team0SpawnLocations, random.nextLong(), connections, maxMiddlePoints,
numTeammateConnections,
maxStepSize);
}

Expand All @@ -58,9 +71,19 @@ protected void landSetup() {
.fillEdge((int) (mapSize / 8 * (1 - landDensity) + mapSize / 8), false)
.inflate(mapSize / 64f)
.blur(12, .125f));
MapMaskMethods.connectTeamsAroundCenter(map, random.nextLong(), land, minMiddlePoints, maxMiddlePoints,

List<Vector2> team0SpawnLocations = map.getSpawns()
.stream()
.filter(spawn -> spawn.getTeamID() == 0)
.map(Spawn::getPosition)
.map(Vector2::new)
.toList();

MapMaskMethods.connectTeamsAroundCenter(team0SpawnLocations, random.nextLong(), land, minMiddlePoints,
maxMiddlePoints,
numTeamConnections, maxStepSize, 32);
MapMaskMethods.connectTeammates(map, random.nextLong(), land, maxMiddlePoints, numTeammateConnections,
MapMaskMethods.connectTeammates(team0SpawnLocations, random.nextLong(), land, maxMiddlePoints,
numTeammateConnections,
maxStepSize);
land.inflate(mapSize / 128f).setSize(mapSize / 8);
land.dilute(.5f, 8).erode(.5f, 6);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
import com.faforever.neroxis.generator.GeneratorParameters;
import com.faforever.neroxis.generator.ParameterConstraints;
import com.faforever.neroxis.map.SCMap;
import com.faforever.neroxis.map.Spawn;
import com.faforever.neroxis.map.SymmetrySettings;
import com.faforever.neroxis.mask.BooleanMask;
import com.faforever.neroxis.mask.MapMaskMethods;
import com.faforever.neroxis.util.vector.Vector2;

import java.util.List;

public class SmallIslandsTerrainGenerator extends PathedTerrainGenerator {
@Override
Expand All @@ -28,13 +32,22 @@ protected void landSetup() {

int maxMiddlePoints = 4;
int numPaths = (int) (4 * landDensity + 4) / symmetrySettings.spawnSymmetry().getNumSymPoints();
int bound = ((int) (mapSize / 16 * (random.nextFloat() * .25f + landDensity * .75f)) + mapSize / 16);
int bound = ((int) (mapSize / 16f * (random.nextFloat() * .25f + landDensity * .75f)) + mapSize / 16);
float maxStepSize = mapSize / 128f;

BooleanMask islands = new BooleanMask(mapSize / 4, random.nextLong(), symmetrySettings, "islands", true);

land.setSize(mapSize + 1);
MapMaskMethods.pathAroundSpawns(map, random.nextLong(), land, maxStepSize, numPaths, maxMiddlePoints, bound,

List<Vector2> team0SpawnLocations = map.getSpawns()
.stream()
.filter(spawn -> spawn.getTeamID() == 0)
.map(Spawn::getPosition)
.map(Vector2::new)
.toList();

MapMaskMethods.pathAroundSpawns(team0SpawnLocations, random.nextLong(), land, maxStepSize, numPaths,
maxMiddlePoints, bound,
(float) StrictMath.PI / 2);
land.inflate(maxStepSize).setSize(mapSize / 4);

Expand Down
2 changes: 0 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@ rootProject.name = 'NeroxisGen'
include 'shared'
include 'generator'
include 'toolsuite'
include 'mapgeneditor'
include 'utilities'
include 'ngraph'

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ public record SymmetrySettings(
Symmetry teamSymmetry,
Symmetry spawnSymmetry
) {

public SymmetrySettings {
if (terrainSymmetry.getNumSymPoints() % teamSymmetry.getNumSymPoints() != 0) {
throw new IllegalArgumentException("Team symmetry not a multiple of terrain symmetry");
}

if (terrainSymmetry.getNumSymPoints() % spawnSymmetry.getNumSymPoints() != 0) {
throw new IllegalArgumentException("Spawn symmetry not a multiple of terrain symmetry");
}

if (spawnSymmetry.getNumSymPoints() % teamSymmetry.getNumSymPoints() != 0) {
throw new IllegalArgumentException("Spawn symmetry not a multiple of team symmetry");
}
}

public SymmetrySettings(Symmetry symmetry) {
this(symmetry, symmetry, symmetry);
}
Expand Down
Loading

0 comments on commit eb8c5a2

Please sign in to comment.