mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* 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
33 lines
997 B
C#
33 lines
997 B
C#
using Content.Server.Light.Components;
|
|
using Content.Shared.Light.EntitySystems;
|
|
using Robust.Shared.Map.Components;
|
|
|
|
namespace Content.Server.Light.EntitySystems;
|
|
|
|
/// <inheritdoc/>
|
|
public sealed partial class RoofSystem : SharedRoofSystem
|
|
{
|
|
[Dependency] private SharedMapSystem _maps = default!;
|
|
|
|
private EntityQuery<MapGridComponent> _gridQuery;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
_gridQuery = GetEntityQuery<MapGridComponent>();
|
|
SubscribeLocalEvent<SetRoofComponent, ComponentStartup>(OnFlagStartup);
|
|
}
|
|
|
|
private void OnFlagStartup(Entity<SetRoofComponent> ent, ref ComponentStartup args)
|
|
{
|
|
var xform = Transform(ent.Owner);
|
|
|
|
if (_gridQuery.TryComp(xform.GridUid, out var grid))
|
|
{
|
|
var index = _maps.LocalToTile(xform.GridUid.Value, grid, xform.Coordinates);
|
|
SetRoof((xform.GridUid.Value, grid, null), index, ent.Comp.Value);
|
|
}
|
|
|
|
QueueDel(ent.Owner);
|
|
}
|
|
}
|