better solar flare (#19189)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Content.Server.StationEvents.Events;
|
||||
using Content.Shared.Radio;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||
|
||||
namespace Content.Server.StationEvents.Components;
|
||||
@@ -22,6 +23,24 @@ public sealed class SolarFlareRuleComponent : Component
|
||||
[DataField("affectedChannels", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<RadioChannelPrototype>))]
|
||||
public readonly HashSet<string> AffectedChannels = new();
|
||||
|
||||
/// <summary>
|
||||
/// List of extra channels that can be random disabled on top of the starting channels.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Channels are not removed from this, so its possible to roll the same channel multiple times.
|
||||
/// </remarks>
|
||||
[DataField("extraChannels", customTypeSerializer: typeof(PrototypeIdListSerializer<RadioChannelPrototype>))]
|
||||
public readonly List<String> ExtraChannels = new();
|
||||
|
||||
/// <summary>
|
||||
/// Number of times to roll a channel from ExtraChannels.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Channels are not removed from it, so its possible to roll the same channel multiple times.
|
||||
/// </remarks>
|
||||
[DataField("extraCount")]
|
||||
public uint ExtraCount;
|
||||
|
||||
/// <summary>
|
||||
/// Chance light bulb breaks per second during event
|
||||
/// </summary>
|
||||
|
||||
@@ -20,7 +20,18 @@ public sealed class SolarFlareRule : StationEventSystem<SolarFlareRuleComponent>
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<RadioReceiveAttemptEvent>(OnRadioSendAttempt);
|
||||
SubscribeLocalEvent<RadioReceiveAttemptEvent>(OnRadioReceiveAttempt);
|
||||
}
|
||||
|
||||
protected override void Started(EntityUid uid, SolarFlareRuleComponent comp, GameRuleComponent gameRule, GameRuleStartedEvent args)
|
||||
{
|
||||
base.Started(uid, comp, gameRule, args);
|
||||
|
||||
for (var i = 0; i < comp.ExtraCount; i++)
|
||||
{
|
||||
var channel = RobustRandom.Pick(comp.ExtraChannels);
|
||||
comp.AffectedChannels.Add(channel);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ActiveTick(EntityUid uid, SolarFlareRuleComponent component, GameRuleComponent gameRule, float frameTime)
|
||||
@@ -46,7 +57,7 @@ public sealed class SolarFlareRule : StationEventSystem<SolarFlareRuleComponent>
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRadioSendAttempt(ref RadioReceiveAttemptEvent args)
|
||||
private void OnRadioReceiveAttempt(ref RadioReceiveAttemptEvent args)
|
||||
{
|
||||
var query = EntityQueryEnumerator<SolarFlareRuleComponent, GameRuleComponent>();
|
||||
while (query.MoveNext(out var uid, out var flare, out var gameRule))
|
||||
|
||||
@@ -194,8 +194,8 @@
|
||||
- type: RandomSentienceRule
|
||||
|
||||
- type: entity
|
||||
id: SolarFlare
|
||||
parent: BaseGameRule
|
||||
id: SolarFlare
|
||||
noSpawn: true
|
||||
components:
|
||||
- type: StationEvent
|
||||
@@ -210,7 +210,15 @@
|
||||
onlyJamHeadsets: true
|
||||
affectedChannels:
|
||||
- Common
|
||||
extraChannels:
|
||||
- Command
|
||||
- Engineering
|
||||
- Medical
|
||||
- Science
|
||||
- Security
|
||||
- Service
|
||||
- Supply
|
||||
extraCount: 2
|
||||
lightBreakChancePerSecond: 0.0003
|
||||
doorToggleChancePerSecond: 0.001
|
||||
|
||||
|
||||
Reference in New Issue
Block a user