Files
tbd-station-14/Content.Shared/Body/Systems/SharedBodySystem.cs
Hannah Giovanna Dawson cdbe92d37d Update DamageableSystem to modern standards (#39417)
* Update DamageableSystem to modern standards

* DamageContainerId -> DamageContainerID with lint flag

* Replace strings with protoids

* Make CVar subscription declarations all consistently whitespaced

* ChangeDamage -> TryChangeDamage, cope with C# jank

* Revert event signature changes

* Restore a comment

* Re-add two queries

* Init the queries

* Use appearanceQuery in DamageChanged

* Use damageableQuery in TryChangeDamage

* Use damageableQuery in SetDamageModifierSetId

* Final cleanup, fix sandboxing

* Rectify ExplosionSystem:::ProcessEntity's call to TryChangeDamage

* Re-organize DamageableSystem

* first big fuck you breaking change.

* THATS A LOT OF DAMAGE!!!

* Fix test fails

* test fixes 2

* push it

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
2025-10-27 19:53:04 +00:00

78 lines
2.4 KiB
C#

using Content.Shared.Damage.Systems;
using Content.Shared.Movement.Systems;
using Content.Shared.Standing;
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
namespace Content.Shared.Body.Systems;
public abstract partial class SharedBodySystem : EntitySystem
{
/*
* See the body partial for how this works.
*/
/// <summary>
/// Container ID prefix for any body parts.
/// </summary>
public const string PartSlotContainerIdPrefix = "body_part_slot_";
/// <summary>
/// Container ID for the ContainerSlot on the body entity itself.
/// </summary>
public const string BodyRootContainerId = "body_root_part";
/// <summary>
/// Container ID prefix for any body organs.
/// </summary>
public const string OrganSlotContainerIdPrefix = "body_organ_slot_";
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] protected readonly IPrototypeManager Prototypes = default!;
[Dependency] protected readonly DamageableSystem Damageable = 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()
{
base.Initialize();
InitializeBody();
InitializeParts();
}
/// <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 < 0)
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;
}
}