mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-02-14 23:14:45 +01:00
Adds EMP Resistance component, gives it to ninja suit and headset (#42334)
* add comp and apply to ninja gear * cleanup * requested changes --------- Co-authored-by: seanpimble <149889301+seanpimble@users.noreply.github.com>
This commit is contained in:
18
Content.Shared/Emp/EmpResistanceComponent.cs
Normal file
18
Content.Shared/Emp/EmpResistanceComponent.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Emp;
|
||||
|
||||
/// <summary>
|
||||
/// An entity with this component resists or is fully immune to EMPs.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
[Access(typeof(SharedEmpSystem))]
|
||||
public sealed partial class EmpResistanceComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The proportion of the EMP effect that is resisted. 1.00 indicates full immunity while 0.00 indicates no resistance.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public FixedPoint2 Resistance = FixedPoint2.Zero;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Emp;
|
||||
|
||||
@@ -26,6 +27,9 @@ public abstract class SharedEmpSystem : EntitySystem
|
||||
SubscribeLocalEvent<EmpDisabledComponent, ExaminedEvent>(OnExamine);
|
||||
SubscribeLocalEvent<EmpDisabledComponent, ComponentRemove>(OnRemove);
|
||||
SubscribeLocalEvent<EmpDisabledComponent, RejuvenateEvent>(OnRejuvenate);
|
||||
|
||||
SubscribeLocalEvent<EmpResistanceComponent, EmpAttemptEvent>(OnResistEmpAttempt);
|
||||
SubscribeLocalEvent<EmpResistanceComponent, EmpPulseEvent>(OnResistEmpPulse);
|
||||
}
|
||||
|
||||
public static readonly EntProtoId EmpPulseEffectPrototype = "EffectEmpPulse";
|
||||
@@ -152,6 +156,23 @@ public abstract class SharedEmpSystem : EntitySystem
|
||||
{
|
||||
RemCompDeferred<EmpDisabledComponent>(ent);
|
||||
}
|
||||
|
||||
private void OnResistEmpAttempt(Entity<EmpResistanceComponent> ent, ref EmpAttemptEvent args)
|
||||
{
|
||||
if (ent.Comp.Resistance >= 1)
|
||||
args.Cancelled = true;
|
||||
}
|
||||
|
||||
private void OnResistEmpPulse(Entity<EmpResistanceComponent> ent, ref EmpPulseEvent args)
|
||||
{
|
||||
var empStrengthMultiplier = 1 - ent.Comp.Resistance;
|
||||
|
||||
if (empStrengthMultiplier <= 0)
|
||||
return;
|
||||
|
||||
args.Duration *= (float) empStrengthMultiplier;
|
||||
args.EnergyConsumption *= (float) empStrengthMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -36,7 +36,6 @@ public abstract class SharedNinjaSuitSystem : EntitySystem
|
||||
SubscribeLocalEvent<NinjaSuitComponent, CreateItemAttemptEvent>(OnCreateStarAttempt);
|
||||
SubscribeLocalEvent<NinjaSuitComponent, ItemToggleActivateAttemptEvent>(OnActivateAttempt);
|
||||
SubscribeLocalEvent<NinjaSuitComponent, GotUnequippedEvent>(OnUnequipped);
|
||||
SubscribeLocalEvent<NinjaSuitComponent, EmpAttemptEvent>(OnEmpAttempt);
|
||||
}
|
||||
|
||||
private void OnEquipped(Entity<NinjaSuitComponent> ent, ref ClothingGotEquippedEvent args)
|
||||
@@ -172,11 +171,4 @@ public abstract class SharedNinjaSuitSystem : EntitySystem
|
||||
if (user.Comp.Gloves is { } uid)
|
||||
_toggle.TryDeactivate(uid, user: user);
|
||||
}
|
||||
|
||||
private void OnEmpAttempt(Entity<NinjaSuitComponent> ent, ref EmpAttemptEvent args)
|
||||
{
|
||||
// ninja suit (battery) is immune to emp
|
||||
// powercell relays the event to suit
|
||||
args.Cancelled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,3 +314,5 @@
|
||||
sprite: Clothing/Ears/Headsets/ninja.rsi
|
||||
- type: Clothing
|
||||
sprite: Clothing/Ears/Headsets/ninja.rsi
|
||||
- type: EmpResistance
|
||||
resistance: 1
|
||||
|
||||
@@ -189,6 +189,8 @@
|
||||
noPowerPopup: ninja-no-power
|
||||
# core ninja suit stuff
|
||||
- type: NinjaSuit
|
||||
- type: EmpResistance
|
||||
resistance: 1
|
||||
- type: UseDelay
|
||||
delay: 5 # disable time
|
||||
- type: PowerCellSlot
|
||||
|
||||
Reference in New Issue
Block a user