]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix mech double interactions (#14672)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Fri, 24 Mar 2023 01:42:43 +0000 (14:42 +1300)
committerGitHub <noreply@github.com>
Fri, 24 Mar 2023 01:42:43 +0000 (12:42 +1100)
Content.Server/Mech/Systems/MechSystem.cs
Content.Shared/Interaction/Components/InteractionRelayComponent.cs
Content.Shared/Interaction/SharedInteractionSystem.cs
Content.Shared/Mech/EntitySystems/SharedMechSystem.cs

index ab307673c62d689a3a4d55c29ee7a13d5c276dae..cf41335f35968686c2e159b1b6c6111f14c146de 100644 (file)
@@ -195,7 +195,7 @@ public sealed class MechSystem : SharedMechSystem
                 Priority = 1, // Promote to top to make ejecting the ALT-click action
                 Act = () =>
                 {
-                    if (args.User == component.PilotSlot.ContainedEntity)
+                    if (args.User == uid || args.User == component.PilotSlot.ContainedEntity)
                     {
                         TryEject(uid, component);
                         return;
index bd8bdf3b880f7a2e931b5abefdb4d24a0fdb4183..9ae63c35277fdab853dfe5a792d3ab6268809ecf 100644 (file)
@@ -7,6 +7,8 @@ namespace Content.Shared.Interaction.Components;
 /// Relays an entities interactions to another entity.
 /// This doesn't raise the same events, but just relays
 /// the clicks of the mouse.
+///
+/// Note that extreme caution should be taken when using this, as this will probably bypass many normal can-interact checks.
 /// </summary>
 [RegisterComponent, NetworkedComponent]
 [Access(typeof(SharedInteractionSystem))]
index 8314d36b125e8cccae7e5be54a42a0299c20d6e4..c3fbb299ab77df5b56472629eae47bde70b51c16 100644 (file)
@@ -240,7 +240,12 @@ namespace Content.Shared.Interaction
         {
             if (TryComp<InteractionRelayComponent>(user, out var relay) && relay.RelayEntity is not null)
             {
-                UserInteraction(relay.RelayEntity.Value, coordinates, target, altInteract, checkCanInteract, checkAccess, checkCanUse);
+                // TODO this needs to be handled better. This probably bypasses many complex can-interact checks in weird roundabout ways.
+                if (_actionBlockerSystem.CanInteract(user, target))
+                {
+                    UserInteraction(relay.RelayEntity.Value, coordinates, target, altInteract, checkCanInteract, checkAccess, checkCanUse);
+                    return;
+                }
             }
 
             if (target != null && Deleted(target.Value))
index 114e7f96209eeb3cf4c601345b6438b416c2143d..70e8405240f80254eca44c74ea09a7f9fc04395a 100644 (file)
@@ -125,6 +125,7 @@ public abstract class SharedMechSystem : EntitySystem
         if (pilot == null)
             return;
 
+        // TODO why is this being blocked?
         if (!_timing.IsFirstTimePredicted)
             return;
 
@@ -165,6 +166,8 @@ public abstract class SharedMechSystem : EntitySystem
 
         var rider = EnsureComp<MechPilotComponent>(pilot);
         var relay = EnsureComp<RelayInputMoverComponent>(pilot);
+
+        // Warning: this bypasses most normal interaction blocking components on the user, like drone laws and the like.
         var irelay = EnsureComp<InteractionRelayComponent>(pilot);
 
         _mover.SetRelay(pilot, mech, relay);