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
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()
{
_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);
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();