Show paradox clones in deadchat (#35940)

show clones in deadchat
This commit is contained in:
slarticodefast
2025-03-26 16:30:14 +01:00
committed by GitHub
parent 6d63e3c1f4
commit 9ff43f344e
6 changed files with 100 additions and 2 deletions

View File

@@ -0,0 +1,48 @@
using Content.Shared.NameModifier.EntitySystems;
using Content.Shared.Mind.Components;
namespace Content.Shared.Mind;
/// <summary>
/// Relays events raised on a mobs body to its mind and mind role entities.
/// Useful for events that should be raised both on the body and the mind.
/// </summary>
public abstract partial class SharedMindSystem : EntitySystem
{
public void InitializeRelay()
{
// for name modifiers that depend on certain mind roles
SubscribeLocalEvent<MindContainerComponent, RefreshNameModifiersEvent>(RelayRefToMind);
}
protected void RelayToMind<T>(EntityUid uid, MindContainerComponent component, T args) where T : class
{
var ev = new MindRelayedEvent<T>(args);
if (TryGetMind(uid, out var mindId, out var mindComp, component))
{
RaiseLocalEvent(mindId, ref ev);
foreach (var role in mindComp.MindRoles)
RaiseLocalEvent(role, ref ev);
}
}
protected void RelayRefToMind<T>(EntityUid uid, MindContainerComponent component, ref T args) where T : class
{
var ev = new MindRelayedEvent<T>(args);
if (TryGetMind(uid, out var mindId, out var mindComp, component))
{
RaiseLocalEvent(mindId, ref ev);
foreach (var role in mindComp.MindRoles)
RaiseLocalEvent(role, ref ev);
}
args = ev.Args;
}
}
[ByRefEvent]
public record struct MindRelayedEvent<TEvent>(TEvent Args);