56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using Content.Shared.Emag.Systems;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Singularity.Components;
|
|
|
|
namespace Content.Shared.Singularity.EntitySystems;
|
|
|
|
/// <summary>
|
|
/// Shared part of SingularitySingularityGeneratorSystem
|
|
/// </summary>
|
|
public abstract class SharedSingularityGeneratorSystem : EntitySystem
|
|
{
|
|
#region Dependencies
|
|
[Dependency] protected readonly SharedPopupSystem PopupSystem = default!;
|
|
[Dependency] private readonly EmagSystem _emag = default!;
|
|
#endregion Dependencies
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<SingularityGeneratorComponent, GotEmaggedEvent>(OnEmagged);
|
|
SubscribeLocalEvent<SingularityGeneratorComponent, GotUnEmaggedEvent>(OnUnemagged); // Frontier
|
|
}
|
|
|
|
private void OnEmagged(EntityUid uid, SingularityGeneratorComponent component, ref GotEmaggedEvent args)
|
|
{
|
|
if (!_emag.CompareFlag(args.Type, EmagType.Interaction))
|
|
return;
|
|
|
|
if (_emag.CheckFlag(uid, EmagType.Interaction))
|
|
return;
|
|
|
|
if (component.FailsafeDisabled)
|
|
return;
|
|
|
|
component.FailsafeDisabled = true;
|
|
args.Handled = true;
|
|
}
|
|
|
|
// Frontier: demag
|
|
private void OnUnemagged(EntityUid uid, SingularityGeneratorComponent component, ref GotUnEmaggedEvent args)
|
|
{
|
|
if (!_emag.CompareFlag(args.Type, EmagType.Interaction))
|
|
return;
|
|
|
|
if (!_emag.CheckFlag(uid, EmagType.Interaction))
|
|
return;
|
|
|
|
if (component.FailsafeDisabled)
|
|
component.FailsafeDisabled = false;
|
|
|
|
args.Handled = true;
|
|
}
|
|
// End Frontier: demag
|
|
}
|