Files
wwdpublic/Content.Server/Procedural/RoomFillSystem.cs
Spatison 1297182e3c [Port] Room spawner mask (#483)
* RoomSpawner mask (#33110)

* RoolFill can now spaw rooms with any size

* tile ignoring

* upgrade interior

* simplify

* Update DungeonSystem.Rooms.cs

* center rooms

* Update RoomFillComponent.cs

* Update RoomFillComponent.cs

* Update DungeonSystem.Rooms.cs

* Remove roomfillcoponent from integration test

* Update EntityTest.cs

* remove nullable size, replaced with minsize and maxsize

* clear existing logic refactor

* delete this one

* vgroidinterior.yml delete

* some fix

---------

Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com>
2025-05-03 12:51:57 +03:00

51 lines
1.6 KiB
C#

using Robust.Shared.Map.Components;
namespace Content.Server.Procedural;
public sealed class RoomFillSystem : EntitySystem
{
[Dependency] private readonly DungeonSystem _dungeon = default!;
[Dependency] private readonly SharedMapSystem _maps = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RoomFillComponent, MapInitEvent>(OnRoomFillMapInit);
}
private void OnRoomFillMapInit(EntityUid uid, RoomFillComponent component, MapInitEvent args)
{
var xform = Transform(uid);
if (xform.GridUid != null)
{
var random = new Random();
var room = _dungeon.GetRoomPrototype(random, component.RoomWhitelist, component.MinSize, component.MaxSize);
if (room != null)
{
var mapGrid = Comp<MapGridComponent>(xform.GridUid.Value);
_dungeon.SpawnRoom(
xform.GridUid.Value,
mapGrid,
_maps.LocalToTile(xform.GridUid.Value, mapGrid, xform.Coordinates) - new Vector2i(room.Size.X/2,room.Size.Y/2),
room,
random,
// WD EDIT START
null,
xform.LocalRotation,
component.ClearExisting,
component.Rotation);
// WD EDIT END
}
else
{
Log.Error($"Unable to find matching room prototype for {ToPrettyString(uid)}");
}
}
// Final cleanup
QueueDel(uid);
}
}