2023-08-12 17:39:58 -04:00
|
|
|
|
using Content.Shared.Emag.Systems;
|
2025-01-30 05:05:47 +01:00
|
|
|
|
using Content.Shared.Mind;
|
2023-08-14 19:34:23 -04:00
|
|
|
|
using Content.Shared.Popups;
|
2023-08-12 17:39:58 -04:00
|
|
|
|
using Content.Shared.Silicons.Laws.Components;
|
2025-01-30 05:05:47 +01:00
|
|
|
|
using Content.Shared.Stunnable;
|
2023-08-14 19:34:23 -04:00
|
|
|
|
using Content.Shared.Wires;
|
2025-01-30 05:05:47 +01:00
|
|
|
|
using Robust.Shared.Audio;
|
2023-08-12 17:39:58 -04:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Shared.Silicons.Laws;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// This handles getting and displaying the laws for silicons.
|
|
|
|
|
|
/// </summary>
|
2024-08-28 10:57:12 +10:00
|
|
|
|
public abstract partial class SharedSiliconLawSystem : EntitySystem
|
2023-08-12 17:39:58 -04:00
|
|
|
|
{
|
2023-08-14 19:34:23 -04:00
|
|
|
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
2025-01-30 05:05:47 +01:00
|
|
|
|
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
|
|
|
|
|
[Dependency] private readonly EmagSystem _emag = default!;
|
|
|
|
|
|
[Dependency] private readonly SharedMindSystem _mind = default!;
|
2023-08-14 19:34:23 -04:00
|
|
|
|
|
2023-08-12 17:39:58 -04:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
2024-08-28 10:57:12 +10:00
|
|
|
|
InitializeUpdater();
|
2023-08-12 17:39:58 -04:00
|
|
|
|
SubscribeLocalEvent<EmagSiliconLawComponent, GotEmaggedEvent>(OnGotEmagged);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-30 05:05:47 +01:00
|
|
|
|
private void OnGotEmagged(EntityUid uid, EmagSiliconLawComponent component, ref GotEmaggedEvent args)
|
2023-08-12 17:39:58 -04:00
|
|
|
|
{
|
2025-01-30 05:05:47 +01:00
|
|
|
|
if (!_emag.CompareFlag(args.Type, EmagType.Interaction))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (_emag.CheckFlag(uid, EmagType.Interaction))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// prevent self-emagging
|
2024-02-11 01:23:32 -05:00
|
|
|
|
if (uid == args.UserUid)
|
|
|
|
|
|
{
|
|
|
|
|
|
_popup.PopupClient(Loc.GetString("law-emag-cannot-emag-self"), uid, args.UserUid);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-14 19:34:23 -04:00
|
|
|
|
if (component.RequireOpenPanel &&
|
|
|
|
|
|
TryComp<WiresPanelComponent>(uid, out var panel) &&
|
|
|
|
|
|
!panel.Open)
|
|
|
|
|
|
{
|
|
|
|
|
|
_popup.PopupClient(Loc.GetString("law-emag-require-panel"), uid, args.UserUid);
|
2025-01-30 05:05:47 +01:00
|
|
|
|
return;
|
2023-08-14 19:34:23 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-30 05:05:47 +01:00
|
|
|
|
var ev = new SiliconEmaggedEvent(args.UserUid);
|
|
|
|
|
|
RaiseLocalEvent(uid, ref ev);
|
2024-01-10 23:01:38 +01:00
|
|
|
|
|
2023-08-12 17:39:58 -04:00
|
|
|
|
component.OwnerName = Name(args.UserUid);
|
2025-01-30 05:05:47 +01:00
|
|
|
|
|
|
|
|
|
|
NotifyLawsChanged(uid, component.EmaggedSound);
|
|
|
|
|
|
if(_mind.TryGetMind(uid, out var mindId, out _))
|
|
|
|
|
|
EnsureSubvertedSiliconRole(mindId);
|
|
|
|
|
|
|
|
|
|
|
|
_stunSystem.TryParalyze(uid, component.StunTime, true);
|
|
|
|
|
|
|
2023-08-12 17:39:58 -04:00
|
|
|
|
args.Handled = true;
|
|
|
|
|
|
}
|
2025-01-30 05:05:47 +01:00
|
|
|
|
|
2025-02-23 01:49:58 +01:00
|
|
|
|
public virtual void NotifyLawsChanged(EntityUid uid, SoundSpecifier? cue = null)
|
2025-01-30 05:05:47 +01:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void EnsureSubvertedSiliconRole(EntityUid mindId)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-02-23 01:49:58 +01:00
|
|
|
|
|
|
|
|
|
|
protected virtual void RemoveSubvertedSiliconRole(EntityUid mindId)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-08-12 17:39:58 -04:00
|
|
|
|
}
|
2025-01-30 05:05:47 +01:00
|
|
|
|
|
|
|
|
|
|
[ByRefEvent]
|
|
|
|
|
|
public record struct SiliconEmaggedEvent(EntityUid user);
|