Skip to content

Commit

Permalink
Debuggable dungen output, wallmount typo (new-frontiers-14#2252)
Browse files Browse the repository at this point in the history
  • Loading branch information
whatston3 authored Oct 15, 2024
1 parent cdfff35 commit 5984401
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Content.Server/Gateway/Systems/GatewayGeneratorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private void OnGeneratorOpen(Entity<GatewayGeneratorDestinationComponent> ent, r
var dungeonRotation = _dungeon.GetDungeonRotation(seed);
var dungeonPosition = (origin + dungeonRotation.RotateVec(new Vector2i(0, dungeonDistance))).Floored();

_dungeon.GenerateDungeon(_protoManager.Index<DungeonConfigPrototype>("Experiment"), args.MapUid, grid, dungeonPosition, seed);
_dungeon.GenerateDungeon(_protoManager.Index<DungeonConfigPrototype>("Experiment"), "Experiment", args.MapUid, grid, dungeonPosition, seed); // Frontier: added "Experiment"

// TODO: Dungeon mobs + loot.

Expand Down
5 changes: 4 additions & 1 deletion Content.Server/Procedural/DungeonJob/DungeonJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public sealed partial class DungeonJob : Job<List<Dungeon>>
private readonly EntityCoordinates? _targetCoordinates;

private readonly ISawmill _sawmill;
private readonly string _genId; // Frontier: add ID

public DungeonJob(
ISawmill sawmill,
Expand All @@ -73,6 +74,7 @@ public DungeonJob(
EntityUid gridUid,
int seed,
Vector2i position,
string genID, // Frontier
EntityCoordinates? targetCoordinates = null,
CancellationToken cancellation = default) : base(maxTime, cancellation)
{
Expand All @@ -99,6 +101,7 @@ public DungeonJob(
_seed = seed;
_position = position;
_targetCoordinates = targetCoordinates;
_genId = genID; // Frontier
}

/// <summary>
Expand Down Expand Up @@ -144,7 +147,7 @@ private async Task<List<Dungeon>> GetDungeons(

protected override async Task<List<Dungeon>?> Process()
{
_sawmill.Info($"Generating dungeon {_gen} with seed {_seed} on {_entManager.ToPrettyString(_gridUid)}");
_sawmill.Info($"Generating dungeon {_genId} with seed {_seed} on {_entManager.ToPrettyString(_gridUid)}"); // Frontier: _gen<_genId
_grid.CanSplit = false;
var random = new Random(_seed);
var position = (_position + random.NextPolarVector2(_gen.MinOffset, _gen.MaxOffset)).Floored();
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Procedural/DungeonSystem.Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private async void GenerateDungeon(IConsoleShell shell, string argstr, string[]
}

shell.WriteLine(Loc.GetString("cmd-dungen-start", ("seed", seed)));
GenerateDungeon(dungeon, dungeonUid, dungeonGrid, position, seed);
GenerateDungeon(dungeon, dungeon.ID, dungeonUid, dungeonGrid, position, seed); // Frontier: add dungeon.ID
}

private CompletionResult CompletionCallback(IConsoleShell shell, string[] args)
Expand Down
4 changes: 4 additions & 0 deletions Content.Server/Procedural/DungeonSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public MapId GetOrCreateTemplate(DungeonRoomPrototype proto)
/// </summary>
/// <param name="coordinates">Coordinates to move the dungeon to afterwards. Will delete the original map</param>
public void GenerateDungeon(DungeonConfig gen,
string genID, // Frontier
EntityUid gridUid,
MapGridComponent grid,
Vector2i position,
Expand All @@ -212,6 +213,7 @@ public void GenerateDungeon(DungeonConfig gen,
gridUid,
seed,
position,
genID, // Frontier
coordinates,
cancelToken.Token);

Expand All @@ -221,6 +223,7 @@ public void GenerateDungeon(DungeonConfig gen,

public async Task<List<Dungeon>> GenerateDungeonAsync(
DungeonConfig gen,
string genID, // Frontier
EntityUid gridUid,
MapGridComponent grid,
Vector2i position,
Expand All @@ -244,6 +247,7 @@ public async Task<List<Dungeon>> GenerateDungeonAsync(
gridUid,
seed,
position,
genID, // Frontier
null,
cancelToken.Token);

Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Salvage/SalvageSystem.Magnet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,12 @@ private async Task TakeMagnetOffer(Entity<SalvageMagnetDataComponent> data, int
{
case AsteroidOffering asteroid:
var grid = _mapManager.CreateGridEntity(salvMap);
await _dungeon.GenerateDungeonAsync(asteroid.DungeonConfig, grid.Owner, grid.Comp, Vector2i.Zero, seed);
await _dungeon.GenerateDungeonAsync(asteroid.DungeonConfig, asteroid.Id, grid.Owner, grid.Comp, Vector2i.Zero, seed); // Frontier: added asteroid.Id - FIXME: value makes no sense.
break;
case DebrisOffering debris:
var debrisProto = _prototypeManager.Index<DungeonConfigPrototype>(debris.Id);
var debrisGrid = _mapManager.CreateGridEntity(salvMap);
await _dungeon.GenerateDungeonAsync(debrisProto, debrisGrid.Owner, debrisGrid.Comp, Vector2i.Zero, seed);
await _dungeon.GenerateDungeonAsync(debrisProto, debrisProto.ID, debrisGrid.Owner, debrisGrid.Comp, Vector2i.Zero, seed); // Frontier: debrisProto.ID
break;
case SalvageOffering wreck:
var salvageProto = wreck.SalvageMap;
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Salvage/SpawnSalvageMissionJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private async Task<bool> InternalProcess() // Frontier: make process an internal
dungeonOffset = dungeonRotation.RotateVec(dungeonOffset);
var dungeonMod = _prototypeManager.Index<SalvageDungeonModPrototype>(mission.Dungeon);
var dungeonConfig = _prototypeManager.Index(dungeonMod.Proto);
var dungeons = await WaitAsyncTask(_dungeon.GenerateDungeonAsync(dungeonConfig, mapUid, grid, (Vector2i) dungeonOffset,
var dungeons = await WaitAsyncTask(_dungeon.GenerateDungeonAsync(dungeonConfig, dungeonConfig.ID, mapUid, grid, (Vector2i) dungeonOffset, // Frontier: add dungeonConfig.ID
_missionParams.Seed));

dungeon = dungeons.First();
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private bool TryDungeonSpawn(Entity<MapGridComponent?> targetGrid, DungeonSpawnG
var spawnedGrid = _mapManager.CreateGridEntity(mapId);

_transform.SetMapCoordinates(spawnedGrid, new MapCoordinates(Vector2.Zero, mapId));
_dungeon.GenerateDungeon(dungeonProto, spawnedGrid.Owner, spawnedGrid.Comp, Vector2i.Zero, _random.Next(), spawnCoords);
_dungeon.GenerateDungeon(dungeonProto, dungeonProto.ID, spawnedGrid.Owner, spawnedGrid.Comp, Vector2i.Zero, _random.Next(), spawnCoords); // Frontier: add dungeonProto.ID

spawned = spawnedGrid.Owner;
return true;
Expand Down
5 changes: 4 additions & 1 deletion Content.Server/_NF/GameRule/NfAdventureRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ protected override void Started(EntityUid uid, AdventureRuleComponent component,

foreach (var dunGen in dungenTypes)
{
if (dunGen.SkipDungeonGen)
continue;

var seed = _random.Next();
var offset = GetRandomPOICoord(3000f, 8500f, true);
if (!_map.TryLoad(_mapId, "/Maps/_NF/Dungeon/spaceplatform.yml", out var grids,
Expand All @@ -184,7 +187,7 @@ protected override void Started(EntityUid uid, AdventureRuleComponent component,
//pls fit the grid I beg, this is so hacky
//its better now but i think i need to do a normalization pass on the dungeon configs
//because they are all offset. confirmed good size grid, just need to fix all the offsets.
_dunGen.GenerateDungeon(dunGen, grids[0], mapGrid, new Vector2i(0, 0), seed);
_dunGen.GenerateDungeon(dunGen, dunGen.ID, grids[0], mapGrid, new Vector2i(0, 0), seed);
AddStationCoordsToSet(offset);
}
}
Expand Down
5 changes: 5 additions & 0 deletions Content.Shared/Procedural/DungeonConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@ public sealed class DungeonConfigPrototype : DungeonConfig, IPrototype
{
[IdDataField]
public string ID { get; private set; } = default!;

// Frontier: skip dungeon generation
[DataField]
public bool SkipDungeonGen = false;
// End Frontier
}
5 changes: 3 additions & 2 deletions Resources/Prototypes/Procedural/dungeon_configs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Base configs
- type: dungeonConfig
id: PlanetBase
skipDungeonGen: true # Frontier
layers:
- !type:PrefabDunGen
presets:
Expand Down Expand Up @@ -125,7 +126,7 @@
Entrance: LavaBrigEntrance
EntranceFlank: BaseWindow
Junction: BaseAirlock
WallMounts: NanoTrasenFasilityWallmounts # Frontier: ScienceLabsWalls<NanoTrasenFasilityWallmounts
WallMounts: NanoTrasenFacilityWallmounts # Frontier: ScienceLabsWalls<NanoTrasenFacilityWallmounts
Window: BaseWindow
whitelists:
Rooms:
Expand All @@ -147,7 +148,7 @@
Entrance: BaseWoodWall
EntranceFlank: BaseWoodWall
Junction: BaseWoodSupport
WallMounts: NanoTrasenFasilityWallmounts # Frontier:added WallMounts: NanoTrasenFasilityWallmounts
WallMounts: NanoTrasenFacilityWallmounts # Frontier:added WallMounts: NanoTrasenFacilityWallmounts
Window: BaseWoodWall
tiles:
FallbackTile: FloorCaveDrought
Expand Down
3 changes: 2 additions & 1 deletion Resources/Prototypes/_NF/Procedural/dungeon_configs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Base dungeon prototypes
- type: dungeonConfig
id: Everything
skipDungeonGen: true # Frontier
layers:
- !type:PrefabDunGen
presets:
Expand Down Expand Up @@ -334,7 +335,7 @@

## Wallmounts
- type: entitySpawnEntry
id: NanoTrasenFasilityWallmounts
id: NanoTrasenFacilityWallmounts
entries:
- id: RandomPosterLegit
orGroup: content
Expand Down

0 comments on commit 5984401

Please sign in to comment.