From 57481181889473c5520b7c9ea0597008767f786d Mon Sep 17 00:00:00 2001 From: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> Date: Mon, 3 Nov 2025 14:05:56 +0100 Subject: [PATCH] Clone toolshed commands (#41261) * init * fuck this file its such a mess why wont anyone sort this holy shit * review --- Content.Server/Cloning/CloningSystem.cs | 8 ++ .../Toolshed/Commands/Misc/CloneCommand.cs | 82 +++++++++++++++++++ Content.Shared/Cloning/SharedCloningSystem.cs | 12 +++ .../en-US/commands/toolshed-commands.ftl | 10 +++ 4 files changed, 112 insertions(+) create mode 100644 Content.Server/Toolshed/Commands/Misc/CloneCommand.cs diff --git a/Content.Server/Cloning/CloningSystem.cs b/Content.Server/Cloning/CloningSystem.cs index 6e0f38ad51..40f8a36dfa 100644 --- a/Content.Server/Cloning/CloningSystem.cs +++ b/Content.Server/Cloning/CloningSystem.cs @@ -84,6 +84,14 @@ public sealed partial class CloningSystem : SharedCloningSystem return true; } + public override void CloneComponents(EntityUid original, EntityUid clone, ProtoId settings) + { + if (!_prototype.Resolve(settings, out var proto)) + return; + + CloneComponents(original, clone, proto); + } + public override void CloneComponents(EntityUid original, EntityUid clone, CloningSettingsPrototype settings) { var componentsToCopy = settings.Components; diff --git a/Content.Server/Toolshed/Commands/Misc/CloneCommand.cs b/Content.Server/Toolshed/Commands/Misc/CloneCommand.cs new file mode 100644 index 0000000000..d7434c48c9 --- /dev/null +++ b/Content.Server/Toolshed/Commands/Misc/CloneCommand.cs @@ -0,0 +1,82 @@ +using Content.Server.Administration; +using Content.Server.Humanoid; +using Content.Shared.Administration; +using Content.Shared.Cloning; +using Content.Shared.Inventory; +using Robust.Shared.Prototypes; +using Robust.Shared.Toolshed; + +namespace Content.Server.Cloning.Commands; + +[ToolshedCommand, AdminCommand(AdminFlags.Fun)] +public sealed class CloneCommand : ToolshedCommand +{ + private HumanoidAppearanceSystem? _appearance; + private CloningSystem? _cloning; + private MetaDataSystem? _metadata; + + [CommandImplementation("humanoidappearance")] + public IEnumerable HumanoidAppearance([PipedArgument] IEnumerable targets, EntityUid source, bool rename) + { + _appearance ??= GetSys(); + _metadata ??= GetSys(); + + foreach (var ent in targets) + { + _appearance.CloneAppearance(source, ent); + + if (rename) + _metadata.SetEntityName(ent, MetaData(source).EntityName, raiseEvents: true); + + yield return ent; + } + } + + [CommandImplementation("comps")] + public IEnumerable Comps([PipedArgument] IEnumerable targets, EntityUid source, ProtoId settings) + { + _cloning ??= GetSys(); + + foreach (var ent in targets) + { + _cloning.CloneComponents(source, ent, settings); + yield return ent; + } + } + + [CommandImplementation("equipment")] + public IEnumerable Equipment([PipedArgument] IEnumerable targets, EntityUid source, SlotFlags flags) + { + _cloning ??= GetSys(); + + foreach (var ent in targets) + { + _cloning.CopyEquipment(source, ent, flags); + yield return ent; + } + } + + [CommandImplementation("implants")] + public IEnumerable Implants([PipedArgument] IEnumerable targets, EntityUid source, bool copyStorage) + { + _cloning ??= GetSys(); + + foreach (var ent in targets) + { + _cloning.CopyImplants(source, ent, copyStorage); + yield return ent; + } + } + + [CommandImplementation("storage")] + public IEnumerable InternalStorage([PipedArgument] IEnumerable targets, EntityUid source) + { + _cloning ??= GetSys(); + + foreach (var ent in targets) + { + _cloning.CopyStorage(source, ent); + yield return ent; + } + } +} diff --git a/Content.Shared/Cloning/SharedCloningSystem.cs b/Content.Shared/Cloning/SharedCloningSystem.cs index d8ab8a2aa1..e44264fb41 100644 --- a/Content.Shared/Cloning/SharedCloningSystem.cs +++ b/Content.Shared/Cloning/SharedCloningSystem.cs @@ -1,3 +1,5 @@ +using Robust.Shared.Prototypes; + namespace Content.Shared.Cloning; public abstract partial class SharedCloningSystem : EntitySystem @@ -11,4 +13,14 @@ public abstract partial class SharedCloningSystem : EntitySystem public virtual void CloneComponents(EntityUid original, EntityUid clone, CloningSettingsPrototype settings) { } + + /// + /// Copy components from one entity to another based on a CloningSettingsPrototype. + /// + /// The orignal Entity to clone components from. + /// The target Entity to clone components to. + /// The clone settings prototype id containing the list of components to clone. + public virtual void CloneComponents(EntityUid original, EntityUid clone, ProtoId settings) + { + } } diff --git a/Resources/Locale/en-US/commands/toolshed-commands.ftl b/Resources/Locale/en-US/commands/toolshed-commands.ftl index 218235338c..85eae1ef3d 100644 --- a/Resources/Locale/en-US/commands/toolshed-commands.ftl +++ b/Resources/Locale/en-US/commands/toolshed-commands.ftl @@ -16,6 +16,16 @@ command-description-bank-set = Sets the money for the given bank account. command-description-bank-amount = Returns the money for the given bank account. +command-description-clone-humanoidappearance = + Clones the humanoid appearance of provided entity to all input entities. +command-description-clone-comps = + Clones all components from the provided entity to all input entities. Only works for supported components. +command-description-clone-equipment = + Clones the equipment from the provided entity to all input entities. Uses base prototypes, meaning changes to equipment won't persist to the cloned versions. +command-description-clone-implants = + Clones the implants from the provided entity to all input entities. Uses base prototypes, meaning changes to implants won't persist to the cloned versions. +command-description-clone-storage = + Clones the storage from the provided entity to all input entities. Uses base prototypes, meaning changes to contents won't persist to the cloned versions. command-description-jobs-jobs = Returns all jobs on a station. command-description-jobs-job = -- 2.51.2