diff --git a/Content.Server/GameTicking/Rules/Configurations/SolarFlareEventRuleConfiguration.cs b/Content.Server/GameTicking/Rules/Configurations/SolarFlareEventRuleConfiguration.cs index 7c1d1e35e8..f014c56280 100644 --- a/Content.Server/GameTicking/Rules/Configurations/SolarFlareEventRuleConfiguration.cs +++ b/Content.Server/GameTicking/Rules/Configurations/SolarFlareEventRuleConfiguration.cs @@ -33,8 +33,14 @@ public sealed class SolarFlareEventRuleConfiguration : StationEventRuleConfigura public readonly HashSet AffectedChannels = new(); /// - /// Chance any given light bulb breaks due to event + /// Chance light bulb breaks per second during event /// - [DataField("lightBreakChance")] - public float LightBreakChance; + [DataField("lightBreakChancePerSecond")] + public float LightBreakChancePerSecond; + + /// + /// Chance door toggles per second during event + /// + [DataField("doorToggleChancePerSecond")] + public float DoorToggleChancePerSecond; } \ No newline at end of file diff --git a/Content.Server/StationEvents/Events/SolarFlare.cs b/Content.Server/StationEvents/Events/SolarFlare.cs index 2ae4be595e..1baf45862b 100644 --- a/Content.Server/StationEvents/Events/SolarFlare.cs +++ b/Content.Server/StationEvents/Events/SolarFlare.cs @@ -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()) - { - 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()) + { + if (RobustRandom.Prob(_event.LightBreakChancePerSecond)) + _poweredLight.TryDestroyBulb(comp.Owner, comp); + } + + foreach (var comp in EntityQuery()) + { + if (RobustRandom.Prob(_event.DoorToggleChancePerSecond)) + _door.TryToggleDoor(comp.Owner, comp); + } + } + if (Elapsed > _event.EndAfter) { ForceEndSelf(); diff --git a/Resources/Prototypes/GameRules/events.yml b/Resources/Prototypes/GameRules/events.yml index 9986cedd9b..6572fba4f6 100644 --- a/Resources/Prototypes/GameRules/events.yml +++ b/Resources/Prototypes/GameRules/events.yml @@ -177,7 +177,8 @@ affectedChannels: - Common - Service - lightBreakChance: 0.05 + lightBreakChancePerSecond: 0.0003 + doorToggleChancePerSecond: 0.001 - type: gameRule id: VentClog