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.Server.StationEvents.Events;
|
||||||
using Content.Shared.Radio;
|
using Content.Shared.Radio;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||||
|
|
||||||
namespace Content.Server.StationEvents.Components;
|
namespace Content.Server.StationEvents.Components;
|
||||||
@@ -22,6 +23,24 @@ public sealed class SolarFlareRuleComponent : Component
|
|||||||
[DataField("affectedChannels", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<RadioChannelPrototype>))]
|
[DataField("affectedChannels", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<RadioChannelPrototype>))]
|
||||||
public readonly HashSet<string> AffectedChannels = new();
|
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>
|
/// <summary>
|
||||||
/// Chance light bulb breaks per second during event
|
/// Chance light bulb breaks per second during event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -20,7 +20,18 @@ public sealed class SolarFlareRule : StationEventSystem<SolarFlareRuleComponent>
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.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)
|
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>();
|
var query = EntityQueryEnumerator<SolarFlareRuleComponent, GameRuleComponent>();
|
||||||
while (query.MoveNext(out var uid, out var flare, out var gameRule))
|
while (query.MoveNext(out var uid, out var flare, out var gameRule))
|
||||||
|
|||||||
@@ -194,8 +194,8 @@
|
|||||||
- type: RandomSentienceRule
|
- type: RandomSentienceRule
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: SolarFlare
|
|
||||||
parent: BaseGameRule
|
parent: BaseGameRule
|
||||||
|
id: SolarFlare
|
||||||
noSpawn: true
|
noSpawn: true
|
||||||
components:
|
components:
|
||||||
- type: StationEvent
|
- type: StationEvent
|
||||||
@@ -210,7 +210,15 @@
|
|||||||
onlyJamHeadsets: true
|
onlyJamHeadsets: true
|
||||||
affectedChannels:
|
affectedChannels:
|
||||||
- Common
|
- Common
|
||||||
|
extraChannels:
|
||||||
|
- Command
|
||||||
|
- Engineering
|
||||||
|
- Medical
|
||||||
|
- Science
|
||||||
|
- Security
|
||||||
- Service
|
- Service
|
||||||
|
- Supply
|
||||||
|
extraCount: 2
|
||||||
lightBreakChancePerSecond: 0.0003
|
lightBreakChancePerSecond: 0.0003
|
||||||
doorToggleChancePerSecond: 0.001
|
doorToggleChancePerSecond: 0.001
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user