-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
161 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Components/ElectricalOverloadComponent.cs → ...Components/ElectricalOverloadComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
Content.Server/_NF/StationEvents/Components/ElectricStormRuleComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Threading; | ||
using Content.Server.StationEvents.Events; | ||
|
||
namespace Content.Server.StationEvents.Components; | ||
|
||
/// <summary> | ||
/// Solar Flare event specific configuration | ||
/// </summary> | ||
[RegisterComponent, Access(typeof(ElectricStormRule))] | ||
public sealed partial class ElectricStormRuleComponent : Component | ||
{ | ||
/// <summary> | ||
/// Chance light bulb breaks per second during event | ||
/// </summary> | ||
[DataField] | ||
public float ComputerChance; | ||
|
||
/// <summary> | ||
/// Chance door toggles per second during event | ||
/// </summary> | ||
[DataField] | ||
public float MachineChance; | ||
|
||
/// <summary> | ||
/// Minimum faxes to send | ||
/// </summary> | ||
[DataField] | ||
public int PlayersPerTargets { get; private set; } = 5; | ||
|
||
/// <summary> | ||
/// Minimum faxes to send | ||
/// </summary> | ||
[DataField] | ||
public int MinTargets { get; private set; } = 1; | ||
|
||
/// <summary> | ||
/// Maximum faxes to send | ||
/// </summary> | ||
[DataField] | ||
public int MaxTargets { get; private set; } = 10; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
Content.Server/_NF/StationEvents/Events/ElectricStormRule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using Content.Server.GameTicking.Rules.Components; | ||
using Robust.Shared.Random; | ||
using Content.Server.StationEvents.Components; | ||
using Content.Shared.GameTicking.Components; | ||
using Content.Server.Construction.Components; | ||
using Content.Server.Power.EntitySystems; | ||
using Content.Server.Power.Components; | ||
using Content.Shared.Station.Components; | ||
using Robust.Server.Player; | ||
using Content.Server.Station.Components; | ||
using Content.Server.Station.Systems; | ||
using Content.Server._NF.Power.EntitySystems; | ||
using Content.Server._NF.Power.Components; | ||
|
||
namespace Content.Server.StationEvents.Events; | ||
|
||
public sealed class ElectricStormRule : StationEventSystem<ElectricStormRuleComponent> | ||
{ | ||
[Dependency] private readonly ElectricalOverloadSystem _electricalOverload = default!; | ||
[Dependency] private readonly IPlayerManager _playerManager = default!; | ||
|
||
private const int MaxRetries = 10; | ||
private float _effectTimer = 0; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
} | ||
|
||
protected override void Started(EntityUid uid, ElectricStormRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) | ||
{ | ||
base.Started(uid, component, gameRule, args); | ||
|
||
RaiseLocalEvent(uid, new ElectricalOverloadEvent(true)); | ||
} | ||
|
||
protected override void Ended(EntityUid uid, ElectricStormRuleComponent component, GameRuleComponent gameRule, GameRuleEndedEvent args) | ||
{ | ||
base.Ended(uid, component, gameRule, args); | ||
//RemComp<ElectricalOverloadComponent>(entity); // Umbra - ElectricalOverload | ||
} | ||
|
||
protected override void ActiveTick(EntityUid uid, ElectricStormRuleComponent component, GameRuleComponent gameRule, float frameTime) | ||
{ | ||
base.ActiveTick(uid, component, gameRule, frameTime); | ||
|
||
_effectTimer -= frameTime; | ||
if (_effectTimer < 0) | ||
{ | ||
_effectTimer += 1; | ||
var computerQuery = EntityQueryEnumerator<ComputerComponent>(); | ||
while (computerQuery.MoveNext(out var computerEnt, out var computer)) | ||
{ | ||
if (RobustRandom.Prob(component.ComputerChance)) | ||
{ | ||
EnsureComp<ElectricalOverloadComponent>(computerEnt); | ||
} | ||
} | ||
var lightQuery = EntityQueryEnumerator<MachineComponent>(); | ||
while (lightQuery.MoveNext(out var machineEnt, out var machine)) | ||
{ | ||
if (RobustRandom.Prob(component.MachineChance)) | ||
{ | ||
EnsureComp<ElectricalOverloadComponent>(machineEnt); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public record struct ElectricalOverloadEvent(bool Enabled); | ||
} |