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

@@ -8,14 +8,31 @@ namespace Content.Shared.Body.Systems;
public abstract partial class SharedBodySystem : EntitySystem
{
protected const string BodyContainerId = "BodyContainer";
/*
* See the body partial for how this works.
*/
/// <summary>
/// Container ID prefix for any body parts.
/// </summary>
protected const string PartSlotContainerIdPrefix = "body_part_slot_";
/// <summary>
/// Container ID for the ContainerSlot on the body entity itself.
/// </summary>
protected const string BodyRootContainerId = "body_root_part";
/// <summary>
/// Container ID prefix for any body organs.
/// </summary>
protected const string OrganSlotContainerIdPrefix = "body_organ_slot_";
[Dependency] protected readonly IPrototypeManager Prototypes = default!;
[Dependency] protected readonly SharedContainerSystem Containers = default!;
[Dependency] protected readonly DamageableSystem Damageable = default!;
[Dependency] protected readonly StandingStateSystem Standing = default!;
[Dependency] protected readonly MovementSpeedModifierSystem Movement = default!;
[Dependency] protected readonly SharedContainerSystem Containers = default!;
[Dependency] protected readonly SharedTransformSystem SharedTransform = default!;
[Dependency] protected readonly StandingStateSystem Standing = default!;
public override void Initialize()
{
@@ -23,6 +40,36 @@ public abstract partial class SharedBodySystem : EntitySystem
InitializeBody();
InitializeParts();
InitializeOrgans();
}
/// <summary>
/// Inverse of <see cref="GetPartSlotContainerId"/>
/// </summary>
protected static string? GetPartSlotContainerIdFromContainer(string containerSlotId)
{
// This is blursed
var slotIndex = containerSlotId.IndexOf(PartSlotContainerIdPrefix, StringComparison.Ordinal);
if (slotIndex < -1)
return null;
var slotId = containerSlotId.Remove(slotIndex, PartSlotContainerIdPrefix.Length);
return slotId;
}
/// <summary>
/// Gets the container Id for the specified slotId.
/// </summary>
public static string GetPartSlotContainerId(string slotId)
{
return PartSlotContainerIdPrefix + slotId;
}
/// <summary>
/// Gets the container Id for the specified slotId.
/// </summary>
public static string GetOrganContainerId(string slotId)
{
return OrganSlotContainerIdPrefix + slotId;
}
}