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:
parent
abe17f5842
commit
297276dcc3
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,7 @@ using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Configuration; // Frontier
|
using Robust.Shared.Configuration; // Frontier
|
||||||
using Robust.Shared;
|
using Robust.Shared;
|
||||||
using Content.Shared.Damage; // Frontier
|
using Content.Shared.Damage; // Frontier
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Shared.Emp;
|
namespace Content.Shared.Emp;
|
||||||
|
|
||||||
|
|
@ -39,6 +40,9 @@ public abstract class SharedEmpSystem : EntitySystem
|
||||||
SubscribeLocalEvent<EmpDisabledComponent, ExaminedEvent>(OnExamine);
|
SubscribeLocalEvent<EmpDisabledComponent, ExaminedEvent>(OnExamine);
|
||||||
SubscribeLocalEvent<EmpDisabledComponent, ComponentRemove>(OnRemove);
|
SubscribeLocalEvent<EmpDisabledComponent, ComponentRemove>(OnRemove);
|
||||||
SubscribeLocalEvent<EmpDisabledComponent, RejuvenateEvent>(OnRejuvenate);
|
SubscribeLocalEvent<EmpDisabledComponent, RejuvenateEvent>(OnRejuvenate);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<EmpResistanceComponent, EmpAttemptEvent>(OnResistEmpAttempt);
|
||||||
|
SubscribeLocalEvent<EmpResistanceComponent, EmpPulseEvent>(OnResistEmpPulse);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly EntProtoId EmpPulseEffectPrototype = "EffectEmpBlast"; // Frontier - was EffectEmpPulse
|
public static readonly EntProtoId EmpPulseEffectPrototype = "EffectEmpBlast"; // Frontier - was EffectEmpPulse
|
||||||
|
|
@ -192,6 +196,23 @@ public abstract class SharedEmpSystem : EntitySystem
|
||||||
{
|
{
|
||||||
RemCompDeferred<EmpDisabledComponent>(ent);
|
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>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ public abstract class SharedNinjaSuitSystem : EntitySystem
|
||||||
SubscribeLocalEvent<NinjaSuitComponent, CreateItemAttemptEvent>(OnCreateStarAttempt);
|
SubscribeLocalEvent<NinjaSuitComponent, CreateItemAttemptEvent>(OnCreateStarAttempt);
|
||||||
SubscribeLocalEvent<NinjaSuitComponent, ItemToggleActivateAttemptEvent>(OnActivateAttempt);
|
SubscribeLocalEvent<NinjaSuitComponent, ItemToggleActivateAttemptEvent>(OnActivateAttempt);
|
||||||
SubscribeLocalEvent<NinjaSuitComponent, GotUnequippedEvent>(OnUnequipped);
|
SubscribeLocalEvent<NinjaSuitComponent, GotUnequippedEvent>(OnUnequipped);
|
||||||
SubscribeLocalEvent<NinjaSuitComponent, EmpAttemptEvent>(OnEmpAttempt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEquipped(Entity<NinjaSuitComponent> ent, ref ClothingGotEquippedEvent args)
|
private void OnEquipped(Entity<NinjaSuitComponent> ent, ref ClothingGotEquippedEvent args)
|
||||||
|
|
@ -178,11 +177,4 @@ public abstract class SharedNinjaSuitSystem : EntitySystem
|
||||||
if (user.Comp.Gloves is { } uid)
|
if (user.Comp.Gloves is { } uid)
|
||||||
_toggle.TryDeactivate(uid, user: user);
|
_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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -315,3 +315,5 @@
|
||||||
sprite: Clothing/Ears/Headsets/ninja.rsi
|
sprite: Clothing/Ears/Headsets/ninja.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
sprite: Clothing/Ears/Headsets/ninja.rsi
|
sprite: Clothing/Ears/Headsets/ninja.rsi
|
||||||
|
- type: EmpResistance
|
||||||
|
resistance: 1
|
||||||
|
|
|
||||||
|
|
@ -249,6 +249,8 @@
|
||||||
noPowerPopup: ninja-no-power
|
noPowerPopup: ninja-no-power
|
||||||
# core ninja suit stuff
|
# core ninja suit stuff
|
||||||
- type: NinjaSuit
|
- type: NinjaSuit
|
||||||
|
- type: EmpResistance
|
||||||
|
resistance: 1
|
||||||
- type: UseDelay
|
- type: UseDelay
|
||||||
delay: 5 # disable time
|
delay: 5 # disable time
|
||||||
- type: PowerCellSlot
|
- type: PowerCellSlot
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue