mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 02:41:18 +03:00
* init * fixes, ghosting * i dont know man * popups, slight rework, actually works now * review * failn't * partial review * new sprites * cleanup * fix * fix multiple gasps, allow stasis when dead * typo * yeah * yeah * wuh * merge master part 2 * sub attribute * first try? * renames * network * identity * fix ts * fix imports * applying state check * temp * may god have mercy upon my soul * stuff * Revert "stuff" This reverts commit de7ec9cb9f761f5cd954921a0efa495388634d30. * Revert "may god have mercy upon my soul" This reverts commit 3e1aa567d47e0576daa6ed420dad29b80c112a31. * Revert "temp" This reverts commit 501dd6d4f6fd22c466e4abb2a284212636123c4a. * Revert "applying state check" This reverts commit 3c211f0a54812797987c7ab93a9b140f66a9088d. * fix --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using Content.Shared.Actions.Components;
|
|
using Content.Shared.Ghost;
|
|
using Content.Shared.Ghost.Systems;
|
|
using Content.Shared.Mobs;
|
|
|
|
namespace Content.Shared.Actions;
|
|
|
|
public abstract partial class SharedActionsSystem
|
|
{
|
|
private void InitializeRelay()
|
|
{
|
|
SubscribeLocalEvent<ActionsComponent, MobStateChangedEvent>(RefRelayActionEvent);
|
|
SubscribeLocalEvent<ActionsComponent, GhostAttemptEvent>(RefRelayActionEvent);
|
|
}
|
|
|
|
private void RefRelayActionEvent<T>(EntityUid uid, ActionsComponent component, ref T args) where T : struct
|
|
{
|
|
RelayEvent((uid, component), ref args);
|
|
}
|
|
|
|
private void RelayActionEvent<T>(EntityUid uid, ActionsComponent component, T args) where T : class
|
|
{
|
|
RelayEvent((uid, component), args);
|
|
}
|
|
|
|
public void RelayEvent<T>(Entity<ActionsComponent> ent, ref T args) where T : struct
|
|
{
|
|
// this copies the by-ref event if it is a struct
|
|
var ev = new ActionRelayedEvent<T>(args);
|
|
foreach (var action in ent.Comp.Actions)
|
|
{
|
|
RaiseLocalEvent(action, ref ev);
|
|
}
|
|
// and now we copy it back
|
|
args = ev.Args;
|
|
}
|
|
|
|
public void RelayEvent<T>(Entity<ActionsComponent> ent, T args) where T : class
|
|
{
|
|
// this copies the by-ref event if it is a struct
|
|
var ev = new ActionRelayedEvent<T>(args);
|
|
foreach (var action in ent.Comp.Actions)
|
|
{
|
|
RaiseLocalEvent(action, ref ev);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event wrapper for relayed events.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public record struct ActionRelayedEvent<TEvent>(TEvent Args)
|
|
{
|
|
public TEvent Args = Args;
|
|
}
|