]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Revert "Electric anomaly rework" (#23546)
authorEmisse <99158783+Emisse@users.noreply.github.com>
Fri, 5 Jan 2024 00:35:24 +0000 (17:35 -0700)
committerGitHub <noreply@github.com>
Fri, 5 Jan 2024 00:35:24 +0000 (17:35 -0700)
Revert "Electric anomaly rework (#23173)"

This reverts commit 05ee6eb30812271d903c5dc6ff8b46f08281ba73.

Content.Server/Anomaly/Effects/ElectricityAnomalySystem.cs
Content.Server/Lightning/LightningSystem.cs
Content.Shared/Anomaly/Effects/Components/ElectricityAnomalyComponent.cs

index 8b5a72449f348d2027ab86bb8ed7fb91ac748ac7..bc6aa3bb1fb5b50f395e4a3d2e9a7dca3a50c049 100644 (file)
@@ -1,8 +1,10 @@
-using Content.Server.Electrocution;
+using Content.Server.Electrocution;
 using Content.Server.Emp;
 using Content.Server.Lightning;
+using Content.Server.Power.Components;
 using Content.Shared.Anomaly.Components;
 using Content.Shared.Anomaly.Effects.Components;
+using Content.Shared.Mobs.Components;
 using Content.Shared.StatusEffect;
 using Robust.Shared.Random;
 using Robust.Shared.Timing;
@@ -12,7 +14,6 @@ namespace Content.Server.Anomaly.Effects;
 public sealed class ElectricityAnomalySystem : EntitySystem
 {
     [Dependency] private readonly IGameTiming _timing = default!;
-    [Dependency] private readonly SharedTransformSystem _transform = default!;
     [Dependency] private readonly IRobustRandom _random = default!;
     [Dependency] private readonly LightningSystem _lightning = default!;
     [Dependency] private readonly ElectrocutionSystem _electrocution = default!;
@@ -26,21 +27,38 @@ public sealed class ElectricityAnomalySystem : EntitySystem
         SubscribeLocalEvent<ElectricityAnomalyComponent, AnomalySupercriticalEvent>(OnSupercritical);
     }
 
-    private void OnPulse(Entity<ElectricityAnomalyComponent> anomaly, ref AnomalyPulseEvent args)
+    private void OnPulse(EntityUid uid, ElectricityAnomalyComponent component, ref AnomalyPulseEvent args)
     {
-        var range = anomaly.Comp.MaxElectrocuteRange * args.Stability;
-
-        int boltCount = (int)MathF.Floor(MathHelper.Lerp((float)anomaly.Comp.MinBoltCount, (float)anomaly.Comp.MaxBoltCount, args.Severity));
-
-        _lightning.ShootRandomLightnings(anomaly, range, boltCount);
+        var range = component.MaxElectrocuteRange * args.Stability;
+        var xform = Transform(uid);
+        foreach (var (ent, comp) in _lookup.GetEntitiesInRange<MobStateComponent>(xform.MapPosition, range))
+        {
+            _lightning.ShootLightning(uid, ent);
+        }
     }
 
-    private void OnSupercritical(Entity<ElectricityAnomalyComponent> anomaly, ref AnomalySupercriticalEvent args)
+    private void OnSupercritical(EntityUid uid, ElectricityAnomalyComponent component, ref AnomalySupercriticalEvent args)
     {
-        var range = anomaly.Comp.MaxElectrocuteRange * 3;
+        var poweredQuery = GetEntityQuery<ApcPowerReceiverComponent>();
+        var mobQuery = GetEntityQuery<MobThresholdsComponent>();
+        var validEnts = new HashSet<EntityUid>();
+        foreach (var ent in _lookup.GetEntitiesInRange(uid, component.MaxElectrocuteRange * 2))
+        {
+            if (mobQuery.HasComponent(ent))
+                validEnts.Add(ent);
+
+            if (_random.Prob(0.01f) && poweredQuery.HasComponent(ent))
+                validEnts.Add(ent);
+        }
+
+        // goodbye, sweet perf
+        foreach (var ent in validEnts)
+        {
+            _lightning.ShootLightning(uid, ent);
+        }
 
-        _emp.EmpPulse(_transform.GetMapCoordinates(anomaly), range, anomaly.Comp.EmpEnergyConsumption, anomaly.Comp.EmpDisabledDuration);
-        _lightning.ShootRandomLightnings(anomaly, range, anomaly.Comp.MaxBoltCount * 3, arcDepth: 3);
+        var empRange = component.MaxElectrocuteRange * 3;
+        _emp.EmpPulse(Transform(uid).MapPosition, empRange, component.EmpEnergyConsumption, component.EmpDisabledDuration);
     }
 
     public override void Update(float frameTime)
index 5e975f317935a82b2d04d455a2187c6edc283a73..ae95a2a491d819ce6636e294b0abd31be30e933a 100644 (file)
@@ -75,6 +75,7 @@ public sealed class LightningSystem : SharedLightningSystem
         var targets = _lookup.GetComponentsInRange<LightningTargetComponent>(Transform(user).MapPosition, range).ToList();
         _random.Shuffle(targets);
         targets.Sort((x, y) => y.Priority.CompareTo(x.Priority));
+        //var realCount = Math.Min(targets.Count, boltCount);
 
         int shootedCount = 0;
         int count = -1;
index e48e0ae6a73c32d59bad56a4d41f3f31219aff1b..5e4fc333e38bd01a53cb4e9d33d1d342627bf10a 100644 (file)
@@ -1,65 +1,53 @@
-using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
+using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
 
 namespace Content.Shared.Anomaly.Effects.Components;
 
 [RegisterComponent]
 public sealed partial class ElectricityAnomalyComponent : Component
 {
-    /// <summary>
-    /// the minimum number of lightning strikes
-    /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
-    public int MinBoltCount = 2;
-
-    /// <summary>
-    /// the number of lightning strikes, at the maximum severity of the anomaly
-    /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
-    public int MaxBoltCount = 5;
-
     /// <summary>
     /// The maximum radius of the passive electrocution effect
     /// scales with stability
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField("maxElectrocutionRange"), ViewVariables(VVAccess.ReadWrite)]
     public float MaxElectrocuteRange = 7f;
 
     /// <summary>
     /// The maximum amount of damage the electrocution can do
     /// scales with severity
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField("maxElectrocuteDamage"), ViewVariables(VVAccess.ReadWrite)]
     public float MaxElectrocuteDamage = 20f;
 
     /// <summary>
     /// The maximum amount of time the electrocution lasts
     /// scales with severity
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField("maxElectrocuteDuration"), ViewVariables(VVAccess.ReadWrite)]
     public TimeSpan MaxElectrocuteDuration = TimeSpan.FromSeconds(8);
 
     /// <summary>
     /// The maximum chance that each second, when in range of the anomaly, you will be electrocuted.
     /// scales with stability
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField("passiveElectrocutionChance"), ViewVariables(VVAccess.ReadWrite)]
     public float PassiveElectrocutionChance = 0.05f;
 
     /// <summary>
     /// Used for tracking seconds, so that we can shock people in a non-tick-dependent way.
     /// </summary>
-    [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
+    [DataField("nextSecond", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
     public TimeSpan NextSecond = TimeSpan.Zero;
 
     /// <summary>
     /// Energy consumed from devices by the emp pulse upon going supercritical.
     /// <summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField("empEnergyConsumption"), ViewVariables(VVAccess.ReadWrite)]
     public float EmpEnergyConsumption = 100000f;
 
     /// <summary>
     /// Duration of devices being disabled by the emp pulse upon going supercritical.
     /// <summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField("empDisabledDuration"), ViewVariables(VVAccess.ReadWrite)]
     public float EmpDisabledDuration = 60f;
 }