Files
tbd-station-14/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs
Kara fab331742a Remove IAfterInteract (#9715)
* remove gas analyzer iafterinteract

* solution transfer + obsolete

* cuffable

* remove
2022-07-14 21:45:31 +10:00

47 lines
1.4 KiB
C#

using Content.Server.Atmos.Components;
using Content.Server.Popups;
using Content.Shared.Interaction;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Player;
namespace Content.Server.Atmos.EntitySystems
{
[UsedImplicitly]
public sealed class GasAnalyzerSystem : EntitySystem
{
[Dependency] private readonly PopupSystem _popup = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<GasAnalyzerComponent, AfterInteractEvent>(OnAfterInteract);
}
public override void Update(float frameTime)
{
foreach (var analyzer in EntityManager.EntityQuery<GasAnalyzerComponent>(true))
{
analyzer.Update(frameTime);
}
}
private void OnAfterInteract(EntityUid uid, GasAnalyzerComponent component, AfterInteractEvent args)
{
if (!args.CanReach)
{
_popup.PopupEntity(Loc.GetString("gas-analyzer-component-player-cannot-reach-message"), args.User, Filter.Entities(args.User));
return;
}
if (TryComp(args.User, out ActorComponent? actor))
{
component.OpenInterface(actor.PlayerSession, args.ClickLocation);
}
args.Handled = true;
}
}
}