CatStation/Content.Server/Tiles/RequiresTileSystem.cs
Eveloop 22a547c7c8
Use dependency injection for EntityQuery<T>s in Content.Server (#43566)
* Replace usages of EntityQuery with dependency injected ones in Content.Server

* Remove unused EntityQuery dependencies

* Restore CheckPressureAndFire override method

* Revert EntityQuery refactor changes to DisposalTubeSystem.cs & DisposableSystem.cs

* Infer Transform/Metadata directly instead of passing (#43479)

* Resolve RA0049, RA0051 errors (#43479)

* Resolve RA0049, RA0051 errors (#43479)

* Apply suggestions from code review

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
2026-05-17 15:59:37 +00:00

39 lines
1 KiB
C#

using Content.Shared.Tiles;
using Robust.Shared.Map.Components;
namespace Content.Server.Tiles;
public sealed partial class RequiresTileSystem : EntitySystem
{
/*
* Needs to be on server as client can't predict QueueDel.
*/
[Dependency] private SharedMapSystem _maps = default!;
[Dependency] private EntityQuery<RequiresTileComponent> _tilesQuery = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<TileChangedEvent>(OnTileChange);
}
private void OnTileChange(ref TileChangedEvent ev)
{
if (!TryComp<MapGridComponent>(ev.Entity, out var grid))
return;
foreach (var change in ev.Changes)
{
var anchored = _maps.GetAnchoredEntitiesEnumerator(ev.Entity, grid, change.GridIndices);
while (anchored.MoveNext(out var ent))
{
if (!_tilesQuery.HasComponent(ent.Value))
continue;
QueueDel(ent.Value);
}
}
}
}