Fix borg becoming emag immune if emag attempted with panel closed. (#23729)
* Fix borg becoming emag immune if emag attempted with panel closed. * new event * removed code added in accessreader * fix emag 1984
This commit is contained in:
@@ -6,6 +6,7 @@ using Content.Shared.Emag.Components;
|
|||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
|
using Content.Shared.Silicons.Laws.Components;
|
||||||
using Content.Shared.Tag;
|
using Content.Shared.Tag;
|
||||||
|
|
||||||
namespace Content.Shared.Emag.Systems;
|
namespace Content.Shared.Emag.Systems;
|
||||||
@@ -79,6 +80,13 @@ public sealed class EmagSystem : EntitySystem
|
|||||||
if (HasComp<EmaggedComponent>(target))
|
if (HasComp<EmaggedComponent>(target))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
var onAttemptEmagEvent = new OnAttemptEmagEvent(user);
|
||||||
|
RaiseLocalEvent(target, ref onAttemptEmagEvent);
|
||||||
|
|
||||||
|
// prevent emagging if attempt fails
|
||||||
|
if (onAttemptEmagEvent.Handled)
|
||||||
|
return false;
|
||||||
|
|
||||||
var emaggedEvent = new GotEmaggedEvent(user);
|
var emaggedEvent = new GotEmaggedEvent(user);
|
||||||
RaiseLocalEvent(target, ref emaggedEvent);
|
RaiseLocalEvent(target, ref emaggedEvent);
|
||||||
|
|
||||||
@@ -90,3 +98,6 @@ public sealed class EmagSystem : EntitySystem
|
|||||||
|
|
||||||
[ByRefEvent]
|
[ByRefEvent]
|
||||||
public record struct GotEmaggedEvent(EntityUid UserUid, bool Handled = false, bool Repeatable = false);
|
public record struct GotEmaggedEvent(EntityUid UserUid, bool Handled = false, bool Repeatable = false);
|
||||||
|
|
||||||
|
[ByRefEvent]
|
||||||
|
public record struct OnAttemptEmagEvent(EntityUid UserUid, bool Handled = false);
|
||||||
|
|||||||
@@ -16,18 +16,23 @@ public abstract class SharedSiliconLawSystem : EntitySystem
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<EmagSiliconLawComponent, GotEmaggedEvent>(OnGotEmagged);
|
SubscribeLocalEvent<EmagSiliconLawComponent, GotEmaggedEvent>(OnGotEmagged);
|
||||||
|
SubscribeLocalEvent<EmagSiliconLawComponent, OnAttemptEmagEvent>(OnAttemptEmag);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnGotEmagged(EntityUid uid, EmagSiliconLawComponent component, ref GotEmaggedEvent args)
|
protected virtual void OnAttemptEmag(EntityUid uid, EmagSiliconLawComponent component, ref OnAttemptEmagEvent args)
|
||||||
{
|
{
|
||||||
if (component.RequireOpenPanel &&
|
if (component.RequireOpenPanel &&
|
||||||
TryComp<WiresPanelComponent>(uid, out var panel) &&
|
TryComp<WiresPanelComponent>(uid, out var panel) &&
|
||||||
!panel.Open)
|
!panel.Open)
|
||||||
{
|
{
|
||||||
_popup.PopupClient(Loc.GetString("law-emag-require-panel"), uid, args.UserUid);
|
_popup.PopupClient(Loc.GetString("law-emag-require-panel"), uid, args.UserUid);
|
||||||
return;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnGotEmagged(EntityUid uid, EmagSiliconLawComponent component, ref GotEmaggedEvent args)
|
||||||
|
{
|
||||||
component.OwnerName = Name(args.UserUid);
|
component.OwnerName = Name(args.UserUid);
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user