mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* first pass * second pass * reorganize * make the icon better (subjective) * self review * review --------- Co-authored-by: iaada <iaada@users.noreply.github.com>
121 lines
6.1 KiB
C#
121 lines
6.1 KiB
C#
using Content.Shared.Body.Events;
|
|
using Content.Shared.Atmos;
|
|
using Content.Shared.Chat;
|
|
using Content.Shared.Chemistry.Events;
|
|
using Content.Shared.Climbing.Events;
|
|
using Content.Shared.Damage.Events;
|
|
using Content.Shared.Damage.Systems;
|
|
using Content.Shared.Examine;
|
|
using Content.Shared.Eye.Blinding.Systems;
|
|
using Content.Shared.Flash;
|
|
using Content.Shared.Medical;
|
|
using Content.Shared.Mobs;
|
|
using Content.Shared.Mobs.Events;
|
|
using Content.Shared.Movement.Events;
|
|
using Content.Shared.Movement.Systems;
|
|
using Content.Shared.Rejuvenate;
|
|
using Content.Shared.Speech;
|
|
using Content.Shared.Speech.EntitySystems;
|
|
using Content.Shared.StatusEffectNew.Components;
|
|
using Content.Shared.Stunnable;
|
|
using Content.Shared.Throwing;
|
|
using Content.Shared.Weapons.Ranged.Events;
|
|
using Robust.Shared.Collections;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Shared.StatusEffectNew;
|
|
|
|
public sealed partial class StatusEffectsSystem
|
|
{
|
|
private void InitializeRelay()
|
|
{
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, LocalPlayerAttachedEvent>(RelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, LocalPlayerDetachedEvent>(RelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, RejuvenateEvent>(RelayStatusEffectEvent);
|
|
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, RefreshMovementSpeedModifiersEvent>(RelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, ModifySlowOnDamageSpeedEvent>(RefRelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, UpdateCanMoveEvent>(RelayStatusEffectEvent);
|
|
|
|
// By Ref Events
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, MobStateChangedEvent>(RefRelayStatusEffectEvent);
|
|
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, RefreshFrictionModifiersEvent>(RefRelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, TileFrictionEvent>(RefRelayStatusEffectEvent);
|
|
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, StandUpAttemptEvent>(RefRelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, StunEndAttemptEvent>(RefRelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, RefreshStaminaCritThresholdEvent>(RefRelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, CanSeeAttemptEvent>(RelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, FlashAttemptEvent>(RefRelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, SelfBeforeClimbEvent>(RelayStatusEffectEvent);
|
|
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, BeforeForceSayEvent>(RelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, BeforeAlertSeverityCheckEvent>(RelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, SpeakAttemptEvent>(RelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, ExaminedEvent>(RelayStatusEffectEvent);
|
|
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, EmoteActionEvent>(RelayStatusEffectEvent, before: new[] { typeof(VocalSystem) });
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, AccentGetEvent>(RefRelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, EmoteEvent>(RefRelayStatusEffectEvent, before: new[] { typeof(VocalSystem), typeof(MumbleAccentSystem) });
|
|
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, BleedModifierEvent>(RefRelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, DamageModifyEvent>(RelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, RefreshPressureImmunityEvent>(RefRelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, SelfBeforeDefibrillatorZapsEvent>(RelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, SelfBeforeInjectEvent>(RelayStatusEffectEvent);
|
|
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, CatchAttemptEvent>(RefRelayStatusEffectEvent);
|
|
SubscribeLocalEvent<StatusEffectContainerComponent, SelfBeforeGunShotEvent>(RelayStatusEffectEvent);
|
|
}
|
|
|
|
private void RefRelayStatusEffectEvent<T>(EntityUid uid, StatusEffectContainerComponent component, ref T args) where T : struct
|
|
{
|
|
RelayEvent((uid, component), ref args);
|
|
}
|
|
|
|
private void RelayStatusEffectEvent<T>(EntityUid uid, StatusEffectContainerComponent component, T args) where T : class
|
|
{
|
|
RelayEvent((uid, component), args);
|
|
}
|
|
|
|
public void RelayEvent<T>(Entity<StatusEffectContainerComponent> statusEffect, ref T args) where T : struct
|
|
{
|
|
if(statusEffect.Comp.ActiveStatusEffects?.ContainedEntities is not {} originalCollection || originalCollection.Count == 0)
|
|
return;
|
|
|
|
// this copies the by-ref event if it is a struct
|
|
var ev = new StatusEffectRelayedEvent<T>(args, statusEffect);
|
|
|
|
// Prevent a collection modified enumeration error by copying the list in case a status adds another status
|
|
var list = new ValueList<EntityUid>(originalCollection);
|
|
foreach (var activeEffect in list)
|
|
{
|
|
RaiseLocalEvent(activeEffect, ref ev);
|
|
}
|
|
// and now we copy it back
|
|
args = ev.Args;
|
|
}
|
|
|
|
public void RelayEvent<T>(Entity<StatusEffectContainerComponent> statusEffect, T args) where T : class
|
|
{
|
|
if (statusEffect.Comp.ActiveStatusEffects?.ContainedEntities is not { } originalCollection || originalCollection.Count == 0)
|
|
return;
|
|
|
|
// this copies the by-ref event if it is a struct
|
|
var ev = new StatusEffectRelayedEvent<T>(args, statusEffect);
|
|
|
|
// Prevent a collection modified enumeration error by copying the list in case a status adds another status
|
|
var list = new ValueList<EntityUid>(originalCollection);
|
|
foreach (var activeEffect in list)
|
|
{
|
|
RaiseLocalEvent(activeEffect, ref ev);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event wrapper for relayed events.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public record struct StatusEffectRelayedEvent<TEvent>(TEvent Args, EntityUid AppliedTo);
|