]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Paradox Clones receive the implants the original has (#35906)
authorslarticodefast <161409025+slarticodefast@users.noreply.github.com>
Tue, 18 Mar 2025 05:21:56 +0000 (06:21 +0100)
committerGitHub <noreply@github.com>
Tue, 18 Mar 2025 05:21:56 +0000 (22:21 -0700)
* copy implants to paradox clones

* Minor fixes

---------

Co-authored-by: beck-thompson <beck314159@hotmail.com>
Content.Server/Cloning/CloningSystem.cs
Content.Shared/Cloning/CloningSettingsPrototype.cs
Resources/Prototypes/Entities/Mobs/Player/clone.yml

index 9a77c75f6455f2844898cd897cb6ab9ad9749d5b..b8aff813d25e94f444fbbcb341fa88e85eaf8cca 100644 (file)
@@ -5,6 +5,8 @@ using Content.Shared.Cloning.Events;
 using Content.Shared.Database;
 using Content.Shared.Humanoid;
 using Content.Shared.Inventory;
+using Content.Shared.Implants;
+using Content.Shared.Implants.Components;
 using Content.Shared.NameModifier.Components;
 using Content.Shared.StatusEffect;
 using Content.Shared.Stacks;
@@ -35,6 +37,7 @@ public sealed class CloningSystem : EntitySystem
     [Dependency] private readonly SharedContainerSystem _container = default!;
     [Dependency] private readonly SharedStorageSystem _storage = default!;
     [Dependency] private readonly SharedStackSystem _stack = default!;
+    [Dependency] private readonly SharedSubdermalImplantSystem _subdermalImplant = default!;
 
     /// <summary>
     ///     Spawns a clone of the given humanoid mob at the specified location or in nullspace.
@@ -90,7 +93,12 @@ public sealed class CloningSystem : EntitySystem
 
         // Copy storage on the mob itself as well.
         // This is needed for slime storage.
-        CopyStorage(original, clone.Value, settings.Whitelist, settings.Blacklist);
+        if (settings.CopyInternalStorage)
+            CopyStorage(original, clone.Value, settings.Whitelist, settings.Blacklist);
+
+        // copy implants and their storage contents
+        if (settings.CopyImplants)
+            CopyImplants(original, clone.Value, settings.CopyInternalStorage, settings.Whitelist, settings.Blacklist);
 
         var originalName = Name(original);
         if (TryComp<NameModifierComponent>(original, out var nameModComp)) // if the originals name was modified, use the unmodified name
@@ -196,4 +204,37 @@ public sealed class CloningSystem : EntitySystem
                 _storage.InsertAt(target, copy.Value, itemLocation, out _, playSound: false);
         }
     }
+
+    /// <summary>
+    ///     Copies all implants from one mob to another.
+    ///     Might result in duplicates if the target already has them.
+    ///     Can copy the storage inside a storage implant according to a whitelist and blacklist.
+    /// </summary>
+    /// <param name="original">Entity to copy implants from.</param>
+    /// <param name="target">Entity to copy implants to.</param>
+    /// <param name="copyStorage">If true will copy storage of the implants (E.g storage implant)</param>
+    /// <param name="whitelist">Whitelist for the storage copy (If copyStorage is true)</param>
+    /// <param name="blacklist">Blacklist for the storage copy (If copyStorage is true)</param>
+    public void CopyImplants(Entity<ImplantedComponent?> original, EntityUid target, bool copyStorage = false, EntityWhitelist? whitelist = null, EntityWhitelist? blacklist = null)
+    {
+        if (!Resolve(original, ref original.Comp, false))
+            return; // they don't have any implants to copy!
+
+        foreach (var originalImplant in original.Comp.ImplantContainer.ContainedEntities)
+        {
+            if (!HasComp<SubdermalImplantComponent>(originalImplant))
+                continue; // not an implant (should only happen with admin shenanigans)
+
+            var implantId = MetaData(originalImplant).EntityPrototype?.ID;
+
+            if (implantId == null)
+                continue;
+
+            var targetImplant = _subdermalImplant.AddImplant(target, implantId);
+
+            if (copyStorage && targetImplant != null)
+                CopyStorage(originalImplant, targetImplant.Value, whitelist, blacklist); // only needed for storage implants
+        }
+
+    }
 }
index fa5f4a35d70dcea4dd27c1d677e826651de10def..b5cfc0500dc282f3813f5c9b780d942a38d819f0 100644 (file)
@@ -36,6 +36,18 @@ public sealed partial class CloningSettingsPrototype : IPrototype, IInheritingPr
     [DataField]
     public SlotFlags? CopyEquipment = SlotFlags.All;
 
+    /// <summary>
+    ///     Whether or not to copy slime storage and storage implant contents.
+    /// </summary>
+    [DataField]
+    public bool CopyInternalStorage = true;
+
+    /// <summary>
+    ///     Whether or not to copy implants.
+    /// </summary>
+    [DataField]
+    public bool CopyImplants = true;
+
     /// <summary>
     ///     Whitelist for the equipment allowed to be copied.
     /// </summary>
index 8208c30095bb5af5d61f74fd29fd7d7736e86c28..38040f7cdfa54a82785ef317ea7becb003d7544b 100644 (file)
@@ -73,6 +73,8 @@
   parent: Antag
   forceCloning: false
   copyEquipment: null
+  copyInternalStorage: false
+  copyImplants: false
 
 # spawner