forked from space-syndicate/space-station-14
Clone toolshed commands (#41261)
* init * fuck this file its such a mess why wont anyone sort this holy shit * review
This commit is contained in:
@@ -84,6 +84,14 @@ public sealed partial class CloningSystem : SharedCloningSystem
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void CloneComponents(EntityUid original, EntityUid clone, ProtoId<CloningSettingsPrototype> 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;
|
||||
|
||||
82
Content.Server/Toolshed/Commands/Misc/CloneCommand.cs
Normal file
82
Content.Server/Toolshed/Commands/Misc/CloneCommand.cs
Normal file
@@ -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<EntityUid> HumanoidAppearance([PipedArgument] IEnumerable<EntityUid> targets, EntityUid source, bool rename)
|
||||
{
|
||||
_appearance ??= GetSys<HumanoidAppearanceSystem>();
|
||||
_metadata ??= GetSys<MetaDataSystem>();
|
||||
|
||||
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<EntityUid> Comps([PipedArgument] IEnumerable<EntityUid> targets, EntityUid source, ProtoId<CloningSettingsPrototype> settings)
|
||||
{
|
||||
_cloning ??= GetSys<CloningSystem>();
|
||||
|
||||
foreach (var ent in targets)
|
||||
{
|
||||
_cloning.CloneComponents(source, ent, settings);
|
||||
yield return ent;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandImplementation("equipment")]
|
||||
public IEnumerable<EntityUid> Equipment([PipedArgument] IEnumerable<EntityUid> targets, EntityUid source, SlotFlags flags)
|
||||
{
|
||||
_cloning ??= GetSys<CloningSystem>();
|
||||
|
||||
foreach (var ent in targets)
|
||||
{
|
||||
_cloning.CopyEquipment(source, ent, flags);
|
||||
yield return ent;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandImplementation("implants")]
|
||||
public IEnumerable<EntityUid> Implants([PipedArgument] IEnumerable<EntityUid> targets, EntityUid source, bool copyStorage)
|
||||
{
|
||||
_cloning ??= GetSys<CloningSystem>();
|
||||
|
||||
foreach (var ent in targets)
|
||||
{
|
||||
_cloning.CopyImplants(source, ent, copyStorage);
|
||||
yield return ent;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandImplementation("storage")]
|
||||
public IEnumerable<EntityUid> InternalStorage([PipedArgument] IEnumerable<EntityUid> targets, EntityUid source)
|
||||
{
|
||||
_cloning ??= GetSys<CloningSystem>();
|
||||
|
||||
foreach (var ent in targets)
|
||||
{
|
||||
_cloning.CopyStorage(source, ent);
|
||||
yield return ent;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy components from one entity to another based on a CloningSettingsPrototype.
|
||||
/// </summary>
|
||||
/// <param name="original">The orignal Entity to clone components from.</param>
|
||||
/// <param name="clone">The target Entity to clone components to.</param>
|
||||
/// <param name="settings">The clone settings prototype id containing the list of components to clone.</param>
|
||||
public virtual void CloneComponents(EntityUid original, EntityUid clone, ProtoId<CloningSettingsPrototype> settings)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user