]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Change what items can be fultoned while stopping anchored items from fultoning (...
authorKacper Urbańczyk <mikrel071204@gmail.com>
Sat, 20 Jan 2024 04:57:05 +0000 (05:57 +0100)
committerGitHub <noreply@github.com>
Sat, 20 Jan 2024 04:57:05 +0000 (15:57 +1100)
* Check and restrict players from fultoning their equipped items

* Changed fulton whitelist to items and anchorables

* Stop from anchored items being fultoned

* Moved containermanager check to CanFulton function

* review

---------

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
Content.Server/Salvage/FultonSystem.cs
Content.Shared/Salvage/Fulton/FultonComponent.cs
Content.Shared/Salvage/Fulton/SharedFultonSystem.cs

index 323b71daeaeadfbfe8772a6c3ff9c1f426157ffd..a24bab458468be109a3e35b5059b32a29e8fb981 100644 (file)
@@ -11,7 +11,6 @@ namespace Content.Server.Salvage;
 public sealed class FultonSystem : SharedFultonSystem
 {
     [Dependency] private readonly IRobustRandom _random = default!;
-    [Dependency] private readonly SharedContainerSystem _container = default!;
 
     public override void Initialize()
     {
@@ -55,7 +54,8 @@ public sealed class FultonSystem : SharedFultonSystem
     {
         if (!Deleted(component.Beacon) &&
             TryComp<TransformComponent>(component.Beacon, out var beaconXform) &&
-            !_container.IsEntityOrParentInContainer(component.Beacon.Value, xform: beaconXform))
+            !Container.IsEntityOrParentInContainer(component.Beacon.Value, xform: beaconXform) &&
+            CanFulton(uid))
         {
             var xform = Transform(uid);
             var metadata = MetaData(uid);
index b3a0d4619308523aaf16a7ccba38c7ed5d4d1dc8..236ee18c3a3d04db4ee89d03acca36312bc2aba3 100644 (file)
@@ -39,9 +39,8 @@ public sealed partial class FultonComponent : Component
     {
         Components = new[]
         {
-            "EntityStorage",
             "Item",
-            "ReagentTank",
+            "Anchorable"
         }
     };
 
index d678b14b92f8268ae02be5f1eca8724bc4be22fc..adaef16608e550b14138497efdc443883ec0eea1 100644 (file)
@@ -26,6 +26,7 @@ public abstract partial class SharedFultonSystem : EntitySystem
     [Dependency] protected readonly SharedAudioSystem Audio = default!;
     [Dependency] private   readonly SharedDoAfterSystem _doAfter = default!;
     [Dependency] private   readonly FoldableSystem _foldable = default!;
+    [Dependency] protected readonly SharedContainerSystem Container = default!;
     [Dependency] private   readonly SharedPopupSystem _popup = default!;
     [Dependency] private   readonly SharedStackSystem _stack = default!;
     [Dependency] protected readonly SharedTransformSystem TransformSystem = default!;
@@ -138,7 +139,7 @@ public abstract partial class SharedFultonSystem : EntitySystem
             return;
         }
 
-        if (!CanFulton(args.Target.Value, uid, component))
+        if (!CanApplyFulton(args.Target.Value, component))
         {
             _popup.PopupClient(Loc.GetString("fulton-invalid"), uid, uid);
             return;
@@ -177,15 +178,27 @@ public abstract partial class SharedFultonSystem : EntitySystem
         return;
     }
 
-    private bool CanFulton(EntityUid targetUid, EntityUid uid, FultonComponent component)
+    protected bool CanApplyFulton(EntityUid targetUid, FultonComponent component)
     {
-        if (Transform(targetUid).Anchored)
+        if (!CanFulton(targetUid))
             return false;
 
         if (component.Whitelist?.IsValid(targetUid, EntityManager) != true)
-        {
             return false;
-        }
+
+        return true;
+    }
+
+    protected bool CanFulton(EntityUid uid)
+    {
+        var xform = Transform(uid);
+
+        if (xform.Anchored)
+            return false;
+
+        // Shouldn't need recursive container checks I think.
+        if (Container.IsEntityInContainer(uid))
+            return false;
 
         return true;
     }