* Update MassHallucinationsRule. * Update Content.Server/StationEvents/Events/MassHallucinationsRule.cs Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com> * Update Content.Server/StationEvents/Events/MassHallucinationsRule.cs Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com> * Update Content.Server/StationEvents/Events/MassHallucinationsRule.cs Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com> * MGS Change * Update Content.Server/StationEvents/Events/MassHallucinationsRule.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/StationEvents/Events/MassHallucinationsRule.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Move affectedentities to component, remove masshallucinationscomponent as its no longer needed to track entities. * Apply suggested changes. * No double checks --------- Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
46 lines
1.7 KiB
C#
46 lines
1.7 KiB
C#
using Content.Server.GameTicking.Rules.Components;
|
|
using Content.Server.StationEvents.Components;
|
|
using Content.Server.Traits.Assorted;
|
|
using Content.Shared.GameTicking.Components;
|
|
using Content.Shared.Humanoid;
|
|
using Content.Shared.Mind.Components;
|
|
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<MindContainerComponent, HumanoidAppearanceComponent>();
|
|
while (query.MoveNext(out var ent, out _, out _))
|
|
{
|
|
if (!EnsureComp<ParacusiaComponent>(ent, out var paracusia))
|
|
{
|
|
_paracusia.SetSounds(ent, component.Sounds, paracusia);
|
|
_paracusia.SetTime(ent, component.MinTimeBetweenIncidents, component.MaxTimeBetweenIncidents, paracusia);
|
|
_paracusia.SetDistance(ent, component.MaxSoundDistance);
|
|
|
|
component.AffectedEntities.Add(ent);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void Ended(EntityUid uid, MassHallucinationsRuleComponent component, GameRuleComponent gameRule, GameRuleEndedEvent args)
|
|
{
|
|
base.Ended(uid, component, gameRule, args);
|
|
|
|
foreach (var ent in component.AffectedEntities)
|
|
{
|
|
RemComp<ParacusiaComponent>(ent);
|
|
}
|
|
|
|
component.AffectedEntities.Clear();
|
|
}
|
|
}
|