]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Aghost Now Can Drop Things Wherever They Want (#23502)
authorGeekyhobo <66805063+Geekyhobo@users.noreply.github.com>
Thu, 4 Jan 2024 05:31:58 +0000 (00:31 -0500)
committerGitHub <noreply@github.com>
Thu, 4 Jan 2024 05:31:58 +0000 (16:31 +1100)
* Aghost Now Can Drop Things Wherever They Want

* update admin CL

* Update Resources/Changelog/Admin.yml

* Update Resources/Prototypes/tags.yml

* Update Resources/Prototypes/tags.yml

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs
Resources/Changelog/Admin.yml
Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml
Resources/Prototypes/tags.yml

index 7d2244fbbbb9b75090f930fc45cd2a5ece2a7970..42201ab6af9328bdb2479469e998168466d0a5ea 100644 (file)
@@ -1,6 +1,7 @@
 using System.Numerics;
 using Content.Shared.Hands.Components;
 using Content.Shared.Interaction;
+using Content.Shared.Tag;
 using Robust.Shared.Containers;
 using Robust.Shared.Map;
 
@@ -8,6 +9,7 @@ namespace Content.Shared.Hands.EntitySystems;
 
 public abstract partial class SharedHandsSystem
 {
+    [Dependency] private readonly TagSystem _tagSystem = default!;
     private void InitializeDrop()
     {
         SubscribeLocalEvent<HandsComponent, EntRemovedFromContainerMessage>(HandleEntityRemoved);
@@ -30,6 +32,12 @@ public abstract partial class SharedHandsSystem
             _virtualSystem.Delete((args.Entity, @virtual), uid);
     }
 
+    private bool ShouldIgnoreRestrictions(EntityUid user)
+    {
+        //Checks if the Entity is something that shouldn't care about drop distance or walls ie Aghost
+        return !_tagSystem.HasTag(user, "BypassDropChecks");
+    }
+
     /// <summary>
     ///     Checks whether an entity can drop a given entity. Will return false if they are not holding the entity.
     /// </summary>
@@ -153,20 +161,24 @@ public abstract partial class SharedHandsSystem
     }
 
     /// <summary>
-    ///     Calculates the final location a dropped item will end up at, accounting for max drop range and collision along the targeted drop path.
+    ///     Calculates the final location a dropped item will end up at, accounting for max drop range and collision along the targeted drop path, Does a check to see if a user should bypass those checks as well.
     /// </summary>
     private Vector2 GetFinalDropCoordinates(EntityUid user, MapCoordinates origin, MapCoordinates target)
     {
         var dropVector = target.Position - origin.Position;
         var requestedDropDistance = dropVector.Length();
+        var dropLength = dropVector.Length();
 
-        if (dropVector.Length() > SharedInteractionSystem.InteractionRange)
+        if (ShouldIgnoreRestrictions(user))
         {
-            dropVector = dropVector.Normalized() * SharedInteractionSystem.InteractionRange;
-            target = new MapCoordinates(origin.Position + dropVector, target.MapId);
-        }
+            if (dropVector.Length() > SharedInteractionSystem.InteractionRange)
+            {
+                dropVector = dropVector.Normalized() * SharedInteractionSystem.InteractionRange;
+                target = new MapCoordinates(origin.Position + dropVector, target.MapId);
+            }
 
-        var dropLength = _interactionSystem.UnobstructedDistance(origin, target, predicate: e => e == user);
+            dropLength = _interactionSystem.UnobstructedDistance(origin, target, predicate: e => e == user);
+        }
 
         if (dropLength < requestedDropDistance)
             return origin.Position + dropVector.Normalized() * dropLength;
index 5144dd9dad40152bcd22d52eb0c5577db3854644..50b38cdf7ec055a37dde983e3f37c0e011e72427 100644 (file)
@@ -81,3 +81,8 @@ Entries:
   - {message: 'Fixed not being able to right click in AHelps and the players and objects tabs.', type: Fix}
   id: 13
   time: '2023-12-21T06:34:00.0000000+00:00'
+- author: Geekyhobo
+  changes:
+    - {message: 'Fixed AGhosts not being able to drop items past the default range.', type: Fix}
+  id: 14
+  time: '2024-1-4T01:30:00.0000000+00:00'
index 2ea093060d122b39b6e075d46b5896e39eb6d065..3d6b173f3d528d6585014cd774242ca0cea6ef18 100644 (file)
@@ -11,6 +11,7 @@
     - InstantDoAfters
     - CanPilot
     - BypassInteractionRangeChecks
+    - BypassDropChecks
   - type: Input
     context: "aghost"
   - type: Ghost
index df6bf7cd24e80905bc8618ee26cf897424496bec..fd73e8adfcc6ad098cc3c4fb62fcabd7736144e0 100644 (file)
   id: BulletFoam
 
 - type: Tag
-  id: BypassInteractionRangeChecks
+  id: BypassDropChecks
 
+- type: Tag
+  id: BypassInteractionRangeChecks
+  
 - type: Tag
   id: CableCoil