Files
Pieter-Jan BriersandGitHub 5168b5f3d4 IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

49 lines
1.5 KiB
C#

using Robust.Shared.Map.Components;
using Robust.Shared.Random;
namespace Content.Server.Procedural;
public sealed partial class RoomFillSystem : EntitySystem
{
[Dependency] private DungeonSystem _dungeon = default!;
[Dependency] private SharedMapSystem _maps = default!;
[Dependency] private IRobustRandom _random = 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 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,
null,
clearExisting: component.ClearExisting,
rotation: component.Rotation);
}
else
{
Log.Error($"Unable to find matching room prototype for {ToPrettyString(uid)}");
}
}
// Final cleanup
QueueDel(uid);
}
}