Mass hallucinations event (#17321)
* paracusia component auto comp state * it works * rule component config
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
using Content.Server.StationEvents.Events;
|
||||
|
||||
namespace Content.Server.StationEvents.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This is used to keep track of hallucinated entities to remove effects when event ends
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(MassHallucinationsRule))]
|
||||
public sealed class MassHallucinationsComponent : Component
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Content.Server.StationEvents.Events;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.StationEvents.Components;
|
||||
|
||||
[RegisterComponent, Access(typeof(MassHallucinationsRule))]
|
||||
public sealed class MassHallucinationsRuleComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The maximum time between incidents in seconds
|
||||
/// </summary>
|
||||
[DataField("maxTimeBetweenIncidents", required: true), ViewVariables(VVAccess.ReadWrite)]
|
||||
public float MaxTimeBetweenIncidents;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum time between incidents in seconds
|
||||
/// </summary>
|
||||
[DataField("minTimeBetweenIncidents", required: true), ViewVariables(VVAccess.ReadWrite)]
|
||||
public float MinTimeBetweenIncidents;
|
||||
|
||||
[DataField("maxSoundDistance", required: true), ViewVariables(VVAccess.ReadWrite)]
|
||||
public float MaxSoundDistance;
|
||||
|
||||
[DataField("sounds", required: true)]
|
||||
public SoundSpecifier Sounds = default!;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.StationEvents.Components;
|
||||
using Content.Server.Traits.Assorted;
|
||||
using Content.Shared.Traits.Assorted;
|
||||
|
||||
namespace Content.Server.StationEvents.Events;
|
||||
|
||||
public sealed class MassHallucinationsRule : StationEventSystem<MassHallucinationsRuleComponent>
|
||||
{
|
||||
[Dependency] private readonly ParacusiaSystem _paracusia = default!;
|
||||
|
||||
protected override void Started(EntityUid uid, MassHallucinationsRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
|
||||
{
|
||||
base.Started(uid, component, gameRule, args);
|
||||
var query = EntityQueryEnumerator<MindComponent>();
|
||||
while (query.MoveNext(out var ent, out _))
|
||||
{
|
||||
if (!HasComp<ParacusiaComponent>(ent))
|
||||
{
|
||||
EnsureComp<MassHallucinationsComponent>(ent);
|
||||
var paracusia = EnsureComp<ParacusiaComponent>(ent);
|
||||
_paracusia.SetSounds(ent, component.Sounds, paracusia);
|
||||
_paracusia.SetTime(ent, component.MinTimeBetweenIncidents, component.MaxTimeBetweenIncidents, paracusia);
|
||||
_paracusia.SetDistance(ent, component.MaxSoundDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Ended(EntityUid uid, MassHallucinationsRuleComponent component, GameRuleComponent gameRule, GameRuleEndedEvent args)
|
||||
{
|
||||
base.Ended(uid, component, gameRule, args);
|
||||
var query = EntityQueryEnumerator<MassHallucinationsComponent>();
|
||||
while (query.MoveNext(out var ent, out _))
|
||||
{
|
||||
RemComp<ParacusiaComponent>(ent);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user