2021-06-19 13:25:05 +02:00
|
|
|
|
using Content.Server.Atmos.Components;
|
2022-07-14 04:45:31 -07:00
|
|
|
|
using Content.Server.Popups;
|
|
|
|
|
|
using Content.Shared.Interaction;
|
2020-12-08 11:56:10 +01:00
|
|
|
|
using JetBrains.Annotations;
|
2022-07-14 04:45:31 -07:00
|
|
|
|
using Robust.Server.GameObjects;
|
|
|
|
|
|
using Robust.Shared.Player;
|
2020-08-08 18:24:41 +02:00
|
|
|
|
|
2021-06-19 13:25:05 +02:00
|
|
|
|
namespace Content.Server.Atmos.EntitySystems
|
2020-08-08 18:24:41 +02:00
|
|
|
|
{
|
2020-12-08 11:56:10 +01:00
|
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class GasAnalyzerSystem : EntitySystem
|
2020-08-08 18:24:41 +02:00
|
|
|
|
{
|
2022-07-14 04:45:31 -07:00
|
|
|
|
[Dependency] private readonly PopupSystem _popup = default!;
|
|
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<GasAnalyzerComponent, AfterInteractEvent>(OnAfterInteract);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-08-08 18:24:41 +02:00
|
|
|
|
public override void Update(float frameTime)
|
|
|
|
|
|
{
|
2021-09-28 13:35:29 +02:00
|
|
|
|
foreach (var analyzer in EntityManager.EntityQuery<GasAnalyzerComponent>(true))
|
2020-08-08 18:24:41 +02:00
|
|
|
|
{
|
|
|
|
|
|
analyzer.Update(frameTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-07-14 04:45:31 -07:00
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
2020-08-08 18:24:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|