]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Solar flare better effects (#14400)
authorSlava0135 <40753025+Slava0135@users.noreply.github.com>
Mon, 6 Mar 2023 23:35:59 +0000 (02:35 +0300)
committerGitHub <noreply@github.com>
Mon, 6 Mar 2023 23:35:59 +0000 (19:35 -0400)
Content.Server/GameTicking/Rules/Configurations/SolarFlareEventRuleConfiguration.cs
Content.Server/StationEvents/Events/SolarFlare.cs
Resources/Prototypes/GameRules/events.yml

index 7c1d1e35e8de6682a384ea12f11e07121aa598bf..f014c562804be47cc71ba890eac934c7d36a6422 100644 (file)
@@ -33,8 +33,14 @@ public sealed class SolarFlareEventRuleConfiguration : StationEventRuleConfigura
     public readonly HashSet<string> AffectedChannels = new();
 
     /// <summary>
-    ///     Chance any given light bulb breaks due to event
+    ///     Chance light bulb breaks per second during event
     /// </summary>
-    [DataField("lightBreakChance")]
-    public float LightBreakChance;
+    [DataField("lightBreakChancePerSecond")]
+    public float LightBreakChancePerSecond;
+
+    /// <summary>
+    ///     Chance door toggles per second during event
+    /// </summary>
+    [DataField("doorToggleChancePerSecond")]
+    public float DoorToggleChancePerSecond;
 }
\ No newline at end of file
index 2ae4be595ecea768dfdd9fc98c0a653784940bc3..1baf45862b19f46ad454baffe7ab81273e53fab3 100644 (file)
@@ -5,16 +5,20 @@ using Robust.Shared.Random;
 using Content.Server.Light.EntitySystems;
 using Content.Server.Light.Components;
 using Content.Shared.Radio.Components;
+using Content.Shared.Doors.Components;
+using Content.Shared.Doors.Systems;
 
 namespace Content.Server.StationEvents.Events;
 
 public sealed class SolarFlare : StationEventSystem
 {
     [Dependency] private readonly PoweredLightSystem _poweredLight = default!;
+    [Dependency] private readonly SharedDoorSystem _door = default!;
 
     public override string Prototype => "SolarFlare";
 
     private SolarFlareEventRuleConfiguration _event = default!;
+    private float _effectTimer = 0;
 
     public override void Initialize()
     {
@@ -33,24 +37,6 @@ public sealed class SolarFlare : StationEventSystem
         _event.EndAfter = RobustRandom.Next(ev.MinEndAfter, ev.MaxEndAfter);
     }
 
-    public override void Started()
-    {
-        base.Started();
-        MessLights();
-    }
-
-    private void MessLights()
-    {
-        foreach (var comp in EntityQuery<PoweredLightComponent>())
-        {
-            if (RobustRandom.Prob(_event.LightBreakChance))
-            {
-                var uid = comp.Owner;
-                _poweredLight.TryDestroyBulb(uid, comp);
-            }
-        }
-    }
-
     public override void Update(float frameTime)
     {
         base.Update(frameTime);
@@ -58,6 +44,23 @@ public sealed class SolarFlare : StationEventSystem
         if (!RuleStarted)
             return;
 
+        _effectTimer -= frameTime;
+        if (_effectTimer < 0)
+        {
+            _effectTimer += 1;
+            foreach (var comp in EntityQuery<PoweredLightComponent>())
+            {
+                if (RobustRandom.Prob(_event.LightBreakChancePerSecond))
+                    _poweredLight.TryDestroyBulb(comp.Owner, comp);
+            }
+
+            foreach (var comp in EntityQuery<DoorComponent>())
+            {
+                if (RobustRandom.Prob(_event.DoorToggleChancePerSecond))
+                    _door.TryToggleDoor(comp.Owner, comp);
+            }
+        }
+
         if (Elapsed > _event.EndAfter)
         {
             ForceEndSelf();
index 9986cedd9bc3f1046960b965aa9e8d9b96df89aa..6572fba4f6ffe2729f03bddb7ff17eb15ef897b7 100644 (file)
     affectedChannels:
     - Common
     - Service
-    lightBreakChance: 0.05
+    lightBreakChancePerSecond: 0.0003
+    doorToggleChancePerSecond: 0.001
 
 - type: gameRule
   id: VentClog