From: ScarKy0 <106310278+ScarKy0@users.noreply.github.com>
Date: Wed, 14 Jan 2026 00:59:19 +0000 (+0100)
Subject: EmpResistance cleanup (#42402)
X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=2399b61ca7721fd77615672cdd30a237e238ebbd;p=space-station-14.git
EmpResistance cleanup (#42402)
* init
* yeah
* Update SharedEmpSystem.cs
---
diff --git a/Content.Shared/Emp/EmpResistanceComponent.cs b/Content.Shared/Emp/EmpResistanceComponent.cs
index 0768ad744f..9f83a1ad7b 100644
--- a/Content.Shared/Emp/EmpResistanceComponent.cs
+++ b/Content.Shared/Emp/EmpResistanceComponent.cs
@@ -11,8 +11,14 @@ namespace Content.Shared.Emp;
public sealed partial class EmpResistanceComponent : Component
{
///
- /// The proportion of the EMP effect that is resisted. 1.00 indicates full immunity while 0.00 indicates no resistance.
+ /// The strength of the EMP gets multiplied by this value.
///
[DataField, AutoNetworkedField]
- public FixedPoint2 Resistance = FixedPoint2.Zero;
+ public float StrengthMultiplier = 1f;
+
+ ///
+ /// The duration of the EMP gets multiplied by this value.
+ ///
+ [DataField, AutoNetworkedField]
+ public float DurationMultiplier = 1f;
}
diff --git a/Content.Shared/Emp/SharedEmpSystem.cs b/Content.Shared/Emp/SharedEmpSystem.cs
index d1c773dd90..cc1895b20f 100644
--- a/Content.Shared/Emp/SharedEmpSystem.cs
+++ b/Content.Shared/Emp/SharedEmpSystem.cs
@@ -19,6 +19,7 @@ public abstract class SharedEmpSystem : EntitySystem
[Dependency] private readonly SharedTransformSystem _transform = default!;
private HashSet _entSet = new();
+ private EntityQuery _resistanceQuery;
public override void Initialize()
{
@@ -29,7 +30,8 @@ public abstract class SharedEmpSystem : EntitySystem
SubscribeLocalEvent(OnRejuvenate);
SubscribeLocalEvent(OnResistEmpAttempt);
- SubscribeLocalEvent(OnResistEmpPulse);
+
+ _resistanceQuery = GetEntityQuery();
}
public static readonly EntProtoId EmpPulseEffectPrototype = "EffectEmpPulse";
@@ -109,7 +111,14 @@ public abstract class SharedEmpSystem : EntitySystem
/// If the entity was affected by the EMP.
public bool DoEmpEffects(EntityUid uid, float energyConsumption, TimeSpan duration, EntityUid? user = null)
{
- var ev = new EmpPulseEvent(energyConsumption, false, false, duration, user);
+ var strMultiplier = 1f;
+ var durMultiplier = 1f;
+ if (_resistanceQuery.TryComp(uid, out var resistance))
+ {
+ strMultiplier = resistance.StrengthMultiplier;
+ durMultiplier = resistance.DurationMultiplier;
+ }
+ var ev = new EmpPulseEvent(energyConsumption * strMultiplier, false, false, duration * durMultiplier, user);
RaiseLocalEvent(uid, ref ev);
// TODO: replace with PredictedSpawn once it works with animated sprites
@@ -120,7 +129,7 @@ public abstract class SharedEmpSystem : EntitySystem
return ev.Affected;
var disabled = EnsureComp(uid);
- disabled.DisabledUntil = Timing.CurTime + duration;
+ disabled.DisabledUntil = Timing.CurTime + duration * durMultiplier;
Dirty(uid, disabled);
return ev.Affected;
@@ -159,20 +168,11 @@ public abstract class SharedEmpSystem : EntitySystem
private void OnResistEmpAttempt(Entity ent, ref EmpAttemptEvent args)
{
- if (ent.Comp.Resistance >= 1)
+ // We only cancel if the strength multiplier is 0, because then the effect basically doesn't exist.
+ // Allows us to make things resistant to the duration, but still lose charge to the EMP.
+ if (ent.Comp.StrengthMultiplier <= 0)
args.Cancelled = true;
}
-
- private void OnResistEmpPulse(Entity ent, ref EmpPulseEvent args)
- {
- var empStrengthMultiplier = 1 - ent.Comp.Resistance;
-
- if (empStrengthMultiplier <= 0)
- return;
-
- args.Duration *= (float) empStrengthMultiplier;
- args.EnergyConsumption *= (float) empStrengthMultiplier;
- }
}
///
diff --git a/Resources/Prototypes/Entities/Clothing/Ears/headsets.yml b/Resources/Prototypes/Entities/Clothing/Ears/headsets.yml
index 30c5c9f295..c5c4f269f1 100644
--- a/Resources/Prototypes/Entities/Clothing/Ears/headsets.yml
+++ b/Resources/Prototypes/Entities/Clothing/Ears/headsets.yml
@@ -315,4 +315,4 @@
- type: Clothing
sprite: Clothing/Ears/Headsets/ninja.rsi
- type: EmpResistance
- resistance: 1
+ strengthMultiplier: 0
diff --git a/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml b/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml
index 8d3a0ebae4..4625aa1106 100644
--- a/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml
+++ b/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml
@@ -190,7 +190,7 @@
# core ninja suit stuff
- type: NinjaSuit
- type: EmpResistance
- resistance: 1
+ strengthMultiplier: 0
- type: UseDelay
delay: 5 # disable time
- type: PowerCellSlot