Fix for holoparasite's ability to attack the host through mech (#36659)
This commit is contained in:
parent
dbbf45c407
commit
fd6597d3da
|
|
@ -10,6 +10,7 @@ using Content.Shared.Hands.EntitySystems;
|
||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Interaction.Events;
|
using Content.Shared.Interaction.Events;
|
||||||
|
using Content.Shared.Mech.EntitySystems;
|
||||||
using Content.Shared.Mobs;
|
using Content.Shared.Mobs;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Robust.Shared.Audio.Systems;
|
using Robust.Shared.Audio.Systems;
|
||||||
|
|
@ -56,6 +57,8 @@ namespace Content.Server.Guardian
|
||||||
SubscribeLocalEvent<GuardianHostComponent, GuardianToggleActionEvent>(OnPerformAction);
|
SubscribeLocalEvent<GuardianHostComponent, GuardianToggleActionEvent>(OnPerformAction);
|
||||||
|
|
||||||
SubscribeLocalEvent<GuardianComponent, AttackAttemptEvent>(OnGuardianAttackAttempt);
|
SubscribeLocalEvent<GuardianComponent, AttackAttemptEvent>(OnGuardianAttackAttempt);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<GuardianHostComponent, MechPilotRelayedEvent<GettingAttackedAttemptEvent>>(OnPilotAttackAttempt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGuardianShutdown(EntityUid uid, GuardianComponent component, ComponentShutdown args)
|
private void OnGuardianShutdown(EntityUid uid, GuardianComponent component, ComponentShutdown args)
|
||||||
|
|
@ -144,6 +147,16 @@ namespace Content.Server.Guardian
|
||||||
args.Cancel();
|
args.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnPilotAttackAttempt(Entity<GuardianHostComponent> uid, ref MechPilotRelayedEvent<GettingAttackedAttemptEvent> args)
|
||||||
|
{
|
||||||
|
if (args.Args.Cancelled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_popupSystem.PopupCursor(Loc.GetString("guardian-attack-host"), args.Args.Attacker, PopupType.LargeCaution);
|
||||||
|
|
||||||
|
args.Args.Cancelled = true;
|
||||||
|
}
|
||||||
|
|
||||||
public void ToggleGuardian(EntityUid user, GuardianHostComponent hostComponent)
|
public void ToggleGuardian(EntityUid user, GuardianHostComponent hostComponent)
|
||||||
{
|
{
|
||||||
if (!TryComp<GuardianComponent>(hostComponent.HostedGuardian, out var guardianComponent))
|
if (!TryComp<GuardianComponent>(hostComponent.HostedGuardian, out var guardianComponent))
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using Content.Shared.DoAfter;
|
using Content.Shared.DoAfter;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Shared.Guardian;
|
namespace Content.Shared.Guardian;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -36,7 +36,7 @@ namespace Content.Shared.Mech.EntitySystems;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles all of the interactions, UI handling, and items shennanigans for <see cref="MechComponent"/>
|
/// Handles all of the interactions, UI handling, and items shennanigans for <see cref="MechComponent"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class SharedMechSystem : EntitySystem
|
public abstract partial class SharedMechSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IGameTiming _timing = default!;
|
[Dependency] private readonly IGameTiming _timing = default!;
|
||||||
[Dependency] private readonly INetManager _net = default!;
|
[Dependency] private readonly INetManager _net = default!;
|
||||||
|
|
@ -74,6 +74,8 @@ public abstract class SharedMechSystem : EntitySystem
|
||||||
SubscribeLocalEvent<MechPilotComponent, EntGotRemovedFromContainerMessage>(OnEntGotRemovedFromContainer);
|
SubscribeLocalEvent<MechPilotComponent, EntGotRemovedFromContainerMessage>(OnEntGotRemovedFromContainer);
|
||||||
SubscribeLocalEvent<MechEquipmentComponent, ShotAttemptedEvent>(OnShotAttempted); // Goobstation
|
SubscribeLocalEvent<MechEquipmentComponent, ShotAttemptedEvent>(OnShotAttempted); // Goobstation
|
||||||
Subs.CVar(_config, GoobCVars.MechGunOutsideMech, value => _canUseMechGunOutside = value, true); // Goobstation
|
Subs.CVar(_config, GoobCVars.MechGunOutsideMech, value => _canUseMechGunOutside = value, true); // Goobstation
|
||||||
|
|
||||||
|
InitializeRelay();
|
||||||
}
|
}
|
||||||
// GoobStation: Fixes scram implants or teleports locking the pilot out of being able to move.
|
// GoobStation: Fixes scram implants or teleports locking the pilot out of being able to move.
|
||||||
private void OnEntGotRemovedFromContainer(EntityUid uid, MechPilotComponent component, EntGotRemovedFromContainerMessage args)
|
private void OnEntGotRemovedFromContainer(EntityUid uid, MechPilotComponent component, EntGotRemovedFromContainerMessage args)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue