Fix for holoparasite's ability to attack the host through mech (#36659)
This commit is contained in:
40
Content.Shared/Mech/EntitySystems/SharedMechSystem.Relay.cs
Normal file
40
Content.Shared/Mech/EntitySystems/SharedMechSystem.Relay.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Mech.Components;
|
||||
|
||||
namespace Content.Shared.Mech.EntitySystems;
|
||||
|
||||
public abstract partial class SharedMechSystem
|
||||
{
|
||||
private void InitializeRelay()
|
||||
{
|
||||
SubscribeLocalEvent<MechComponent, GettingAttackedAttemptEvent>(RelayRefToPilot);
|
||||
}
|
||||
|
||||
private void RelayToPilot<T>(Entity<MechComponent> uid, T args) where T : class
|
||||
{
|
||||
if (uid.Comp.PilotSlot.ContainedEntity is not { } pilot)
|
||||
return;
|
||||
|
||||
var ev = new MechPilotRelayedEvent<T>(args);
|
||||
|
||||
RaiseLocalEvent(pilot, ref ev);
|
||||
}
|
||||
|
||||
private void RelayRefToPilot<T>(Entity<MechComponent> uid, ref T args) where T :struct
|
||||
{
|
||||
if (uid.Comp.PilotSlot.ContainedEntity is not { } pilot)
|
||||
return;
|
||||
|
||||
var ev = new MechPilotRelayedEvent<T>(args);
|
||||
|
||||
RaiseLocalEvent(pilot, ref ev);
|
||||
|
||||
args = ev.Args;
|
||||
}
|
||||
}
|
||||
|
||||
[ByRefEvent]
|
||||
public record struct MechPilotRelayedEvent<TEvent>(TEvent Args)
|
||||
{
|
||||
public TEvent Args = Args;
|
||||
}
|
||||
Reference in New Issue
Block a user