Files
space-station-14/Content.Shared/Body/BodySystem.Relay.cs
pathetic meowmeow d0c2734dad Nubody (#42419)
* Nubody

* fix test fails

* gibbing

* lung test returns

* doc comment

* hand organ test

* giblet test

* yaml formatting

* returning

* relocate

* trimming

* re-smite

* oops thusd tweak

* arachnids have slower metabolism i guess

* never mind the old behaviour is bad actually

* rider whyyy

* style changes and allat

* fix collision

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
2026-01-17 00:39:35 +00:00

51 lines
1.5 KiB
C#

using Content.Shared.Body.Events;
using Content.Shared.Gibbing;
using Content.Shared.Medical;
namespace Content.Shared.Body;
public sealed partial class BodySystem
{
private void InitializeRelay()
{
SubscribeLocalEvent<BodyComponent, ApplyMetabolicMultiplierEvent>(RefRelayBodyEvent);
SubscribeLocalEvent<BodyComponent, TryVomitEvent>(RefRelayBodyEvent);
SubscribeLocalEvent<BodyComponent, BeingGibbedEvent>(RefRelayBodyEvent);
}
private void RefRelayBodyEvent<T>(EntityUid uid, BodyComponent component, ref T args) where T : struct
{
RelayEvent((uid, component), ref args);
}
private void RelayBodyEvent<T>(EntityUid uid, BodyComponent component, T args) where T : class
{
RelayEvent((uid, component), args);
}
public void RelayEvent<T>(Entity<BodyComponent> ent, ref T args) where T : struct
{
var ev = new BodyRelayedEvent<T>(ent, args);
foreach (var organ in ent.Comp.Organs?.ContainedEntities ?? [])
{
RaiseLocalEvent(organ, ref ev);
}
args = ev.Args;
}
public void RelayEvent<T>(Entity<BodyComponent> ent, T args) where T : class
{
var ev = new BodyRelayedEvent<T>(ent, args);
foreach (var organ in ent.Comp.Organs?.ContainedEntities ?? [])
{
RaiseLocalEvent(organ, ref ev);
}
}
}
/// <summary>
/// Event wrapper for relayed events.
/// </summary>
[ByRefEvent]
public record struct BodyRelayedEvent<TEvent>(Entity<BodyComponent> Body, TEvent Args);