Refactoring body system to use containers and general body cleanup (#20202)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Jezithyr
2023-09-21 00:23:02 -07:00
committed by GitHub
parent d888d9ad67
commit 31b2c9f830
38 changed files with 1298 additions and 1098 deletions

View File

@@ -1,5 +1,6 @@
using Content.Server.Body.Systems;
using Content.Shared.Administration;
using Content.Shared.Body.Part;
using Robust.Shared.Console;
namespace Content.Server.Administration.Commands
@@ -11,7 +12,7 @@ namespace Content.Server.Administration.Commands
public string Command => "addbodypart";
public string Description => "Adds a given entity to a containing body.";
public string Help => "Usage: addbodypart <entity uid> <body uid> <part slot>";
public string Help => "Usage: addbodypart <entity uid> <body uid> <part slot> <part type>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
@@ -37,7 +38,10 @@ namespace Content.Server.Administration.Commands
var parentId = _entManager.GetEntity(parentNetId);
var bodySystem = _entManager.System<BodySystem>();
if (bodySystem.TryCreatePartSlotAndAttach(parentId, args[2], childId))
if (Enum.TryParse<BodyPartType>(args[3], out var partType) &&
bodySystem.TryCreatePartSlotAndAttach(parentId, args[2], childId, partType))
{
shell.WriteLine($@"Added {childId} to {parentId}.");
}

View File

@@ -35,7 +35,7 @@ namespace Content.Server.Administration.Commands
var bodySystem = _entManager.System<BodySystem>();
if (bodySystem.AddOrganToFirstValidSlot(organId, partId))
if (bodySystem.AddOrganToFirstValidSlot(partId.Value, organId.Value))
{
shell.WriteLine($@"Added {organId} to {partId}.");
}

View File

@@ -27,16 +27,10 @@ namespace Content.Server.Administration.Commands
return;
}
var bodySystem = _entManager.System<BodySystem>();
if (bodySystem.DropPart(entityUid))
{
shell.WriteLine($"Removed body part {_entManager.ToPrettyString(entityUid.Value)}.");
}
else
{
shell.WriteError("Was not a body part, or did not have a parent.");
}
// TODO: THIS IS JUST A MECHANISM COPYPASTE
var xformSystem = _entManager.System<SharedTransformSystem>();
xformSystem.AttachToGridOrMap(entityUid.Value);
shell.WriteLine($"Removed body part {_entManager.ToPrettyString(entityUid.Value)}");
}
}
}

View File

@@ -27,16 +27,9 @@ namespace Content.Server.Administration.Commands
return;
}
var bodySystem = _entManager.System<BodySystem>();
if (bodySystem.DropOrgan(entityUid))
{
shell.WriteLine($"Removed organ {_entManager.ToPrettyString(entityUid.Value)}");
}
else
{
shell.WriteError("Was not a mechanism, or did not have a parent.");
}
var xformSystem = _entManager.System<SharedTransformSystem>();
xformSystem.AttachToGridOrMap(entityUid.Value);
shell.WriteLine($"Removed organ {_entManager.ToPrettyString(entityUid.Value)}");
}
}
}

View File

@@ -76,6 +76,7 @@ public sealed partial class AdminVerbSystem
[Dependency] private readonly VomitSystem _vomitSystem = default!;
[Dependency] private readonly WeldableSystem _weldableSystem = default!;
[Dependency] private readonly SharedContentEyeSystem _eyeSystem = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
// All smite verbs have names so invokeverb works.
private void AddSmiteVerbs(GetVerbsEvent<Verb> args)
@@ -293,8 +294,7 @@ public sealed partial class AdminVerbSystem
if (HasComp<BrainComponent>(xform.Owner) || HasComp<EyeComponent>(xform.Owner))
continue;
var coordinates = baseXform.Coordinates.Offset(_random.NextVector2(0.5f, 0.75f));
_bodySystem.DropOrganAt(organ.Owner, coordinates, organ);
_transformSystem.AttachToGridOrMap(organ.Owner);
}
_popupSystem.PopupEntity(Loc.GetString("admin-smite-vomit-organs-self"), args.Target,
@@ -317,7 +317,7 @@ public sealed partial class AdminVerbSystem
var baseXform = Transform(args.Target);
foreach (var part in _bodySystem.GetBodyChildrenOfType(args.Target, BodyPartType.Hand))
{
_bodySystem.DropPartAt(part.Id, baseXform.Coordinates, part.Component);
_transformSystem.AttachToGridOrMap(part.Id);
}
_popupSystem.PopupEntity(Loc.GetString("admin-smite-remove-hands-self"), args.Target,
args.Target, PopupType.LargeCaution);
@@ -339,7 +339,7 @@ public sealed partial class AdminVerbSystem
var baseXform = Transform(args.Target);
foreach (var part in _bodySystem.GetBodyChildrenOfType(body.Owner, BodyPartType.Hand, body))
{
_bodySystem.DropPartAt(part.Id, baseXform.Coordinates, part.Component);
_transformSystem.AttachToGridOrMap(part.Id);
break;
}
_popupSystem.PopupEntity(Loc.GetString("admin-smite-remove-hands-self"), args.Target,