Demiplan polishing 2 (#528)

* wizden PR copy

* starter rooms

* grass geode location, new modifiers
This commit is contained in:
Ed
2024-11-02 00:59:55 +03:00
committed by GitHub
parent 3b520ac69c
commit 2b9d949eea
17 changed files with 2300 additions and 939 deletions

View File

@@ -19,7 +19,7 @@ public sealed partial class DungeonSystem
/// <summary>
/// Gets a random dungeon room matching the specified area and whitelist.
/// </summary>
public DungeonRoomPrototype? GetRoomPrototype(Vector2i size, Random random, EntityWhitelist? whitelist = null)
public DungeonRoomPrototype? GetRoomPrototype(Random random, EntityWhitelist? whitelist = null, Vector2i? size = null)
{
// Can never be true.
if (whitelist is { Tags: null })
@@ -31,7 +31,7 @@ public sealed partial class DungeonSystem
foreach (var proto in _prototype.EnumeratePrototypes<DungeonRoomPrototype>())
{
if (proto.Size != size)
if (size is not null && proto.Size != size)
continue;
if (whitelist == null)
@@ -156,6 +156,12 @@ public sealed partial class DungeonSystem
if (!clearExisting && reservedTiles?.Contains(rounded) == true)
continue;
if (room.IgnoreTile is not null)
{
if (_maps.TryGetTileDef(templateGrid, indices, out var tileDef) && room.IgnoreTile == tileDef.ID)
continue;
}
_tiles.Add((rounded, tileRef.Tile));
}
}

View File

@@ -45,8 +45,8 @@ public sealed partial class DungeonSystem : SharedDungeonSystem
private const double DungeonJobTime = 0.005;
public const int CollisionMask = (int) CollisionGroup.Impassable;
public const int CollisionLayer = (int) CollisionGroup.Impassable;
public const int CollisionMask = (int) CollisionGroup.AllMask; //CP14 replace to AllMask
public const int CollisionLayer = (int) CollisionGroup.AllMask; //CP14 replace to AllMask
private readonly JobQueue _dungeonJobQueue = new(DungeonJobTime);
private readonly Dictionary<DungeonJob.DungeonJob, CancellationTokenSource> _dungeonJobs = new();

View File

@@ -20,18 +20,18 @@ public sealed partial class RoomFillComponent : Component
/// <summary>
/// Size of the room to fill.
/// </summary>
[DataField(required: true)]
public Vector2i Size;
[DataField]
public Vector2i? Size;
/// <summary>
/// Rooms allowed for the marker.
/// </summary>
[DataField]
public EntityWhitelist? RoomWhitelist;
/// <summary>
/// Should any existing entities / decals be bulldozed first.
/// </summary>
[DataField]
public bool ClearExisting;
public bool ClearExisting = true;
}

View File

@@ -24,7 +24,7 @@ public sealed class RoomFillSystem : EntitySystem
if (xform.GridUid != null)
{
var random = new Random();
var room = _dungeon.GetRoomPrototype(component.Size, random, component.RoomWhitelist);
var room = _dungeon.GetRoomPrototype(random, component.RoomWhitelist, component.Size);
if (room != null)
{

View File

@@ -98,7 +98,9 @@ public sealed partial class CP14DemiplaneSystem
AddDemiplanRandomExitPoint(demiplane, (tempRift, connection));
AddDemiplanRandomExitPoint(demiplane, (tempRift2, connection2));
#if !DEBUG
QueueDel(generator); //wtf its crash debug build?
#endif
}
private void GeneratorMapInit(Entity<CP14DemiplaneGeneratorDataComponent> generator, ref MapInitEvent args)