CatStation/Content.Shared/Mech/EntitySystems/SharedMechSystem.Relay.cs
AndrewFenriz 887835018c
Vehicle system: Mech & CardboardBox Integration (#43532)
* Part one of Vehicles

* Also we need this

* Part 1

* Part 1.1

* And we need this

* Part 2

* Part 2.1

* We REALLY need this

* Part 1 of integration

* Little fix

* Just fixes

* fixes (i'm tired)

* fix

* fix

* Apply suggestions from code review

Co-authored-by: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com>

* update

* fixed

* just for cleaner diff

* just in case

* I think this might be cleaner

* fix

* fix

* upd

* upd

* fix update

* small fix

* upd

* fix test?

* fix?

* remove initialize

* move attack to vehicle

---------

Co-authored-by: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com>
2026-07-21 00:14:11 +00:00

31 lines
800 B
C#

using Content.Shared.Interaction.Events;
using Content.Shared.Mech.Components;
namespace Content.Shared.Mech.EntitySystems;
public abstract partial class SharedMechSystem
{
[SubscribeLocalEvent]
private void OnGettingAttackedAttempt(Entity<MechComponent> ent, ref GettingAttackedAttemptEvent args)
{
RelayRefToPilot(ent, ref args);
}
private void RelayRefToPilot<T>(Entity<MechComponent> uid, ref T args) where T :struct
{
if (!Vehicle.TryGetOperator(uid.Owner, out var operatorEnt))
return;
var ev = new MechPilotRelayedEvent<T>(args);
RaiseLocalEvent(operatorEnt.Value, ref ev);
args = ev.Args;
}
}
[ByRefEvent]
public record struct MechPilotRelayedEvent<TEvent>(TEvent Args)
{
public TEvent Args = Args;
}