diff --git a/Content.Client/Body/Systems/BodySystem.cs b/Content.Client/Body/Systems/BodySystem.cs index bab785525b..172728a955 100644 --- a/Content.Client/Body/Systems/BodySystem.cs +++ b/Content.Client/Body/Systems/BodySystem.cs @@ -1,7 +1,13 @@ -using Content.Shared.Body.Systems; +using Content.Shared.Body.Components; +using Content.Shared.Body.Prototypes; +using Content.Shared.Body.Systems; namespace Content.Client.Body.Systems; public sealed class BodySystem : SharedBodySystem { + protected override void InitBody(BodyComponent body, BodyPrototype prototype) + { + return; + } } diff --git a/Content.Server/Body/Systems/BodySystem.cs b/Content.Server/Body/Systems/BodySystem.cs index b1728e7411..46c276f45a 100644 --- a/Content.Server/Body/Systems/BodySystem.cs +++ b/Content.Server/Body/Systems/BodySystem.cs @@ -6,7 +6,9 @@ using Content.Server.Kitchen.Components; using Content.Server.Mind.Components; using Content.Shared.Body.Components; using Content.Shared.Body.Part; +using Content.Shared.Body.Prototypes; using Content.Shared.Body.Systems; +using Content.Shared.Coordinates; using Content.Shared.Humanoid; using Content.Shared.MobState.Components; using Content.Shared.Movement.Events; @@ -113,6 +115,21 @@ public sealed class BodySystem : SharedBodySystem return true; } + protected override void InitBody(BodyComponent body, BodyPrototype prototype) + { + var root = prototype.Slots[prototype.Root]; + var bodyId = Spawn(root.Part, body.Owner.ToCoordinates()); + var partComponent = Comp(bodyId); + var slot = new BodyPartSlot(root.Part, body.Owner, partComponent.PartType); + body.Root = slot; + partComponent.Body = bodyId; + + Containers.EnsureContainer(body.Owner, BodyContainerId); + + AttachPart(bodyId, slot, partComponent); + InitPart(partComponent, prototype, prototype.Root); + } + public override HashSet GibBody(EntityUid? bodyId, bool gibOrgans = false, BodyComponent? body = null) { if (bodyId == null || !Resolve(bodyId.Value, ref body, false)) diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs index 94997c152e..593b54e271 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs @@ -14,23 +14,12 @@ public partial class SharedBodySystem { public void InitializeBody() { - SubscribeLocalEvent(OnBodyMapInit); SubscribeLocalEvent(OnBodyInit); SubscribeLocalEvent(OnBodyGetState); SubscribeLocalEvent(OnBodyHandleState); } - private void OnBodyMapInit(EntityUid bodyId, BodyComponent body, MapInitEvent args) - { - // ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract - if (body.Prototype == null || body.Root != null) - return; - - var prototype = Prototypes.Index(body.Prototype); - InitBody(body, prototype); - } - private void OnBodyInit(EntityUid bodyId, BodyComponent body, ComponentInit args) { // ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract @@ -75,22 +64,9 @@ public partial class SharedBodySystem return true; } - private void InitBody(BodyComponent body, BodyPrototype prototype) - { - var root = prototype.Slots[prototype.Root]; - var bodyId = Spawn(root.Part, body.Owner.ToCoordinates()); - var partComponent = Comp(bodyId); - var slot = new BodyPartSlot(root.Part, body.Owner, partComponent.PartType); - body.Root = slot; - partComponent.Body = bodyId; + protected abstract void InitBody(BodyComponent body, BodyPrototype prototype); - Containers.EnsureContainer(body.Owner, BodyContainerId); - - AttachPart(bodyId, slot, partComponent); - InitPart(partComponent, prototype, prototype.Root); - } - - private void InitPart(BodyPartComponent parent, BodyPrototype prototype, string slotId, HashSet? initialized = null) + protected void InitPart(BodyPartComponent parent, BodyPrototype prototype, string slotId, HashSet? initialized = null) { initialized ??= new HashSet(); diff --git a/Content.Shared/Body/Systems/SharedBodySystem.cs b/Content.Shared/Body/Systems/SharedBodySystem.cs index fa54886b1c..b91aea1628 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.cs @@ -7,7 +7,7 @@ namespace Content.Shared.Body.Systems; public abstract partial class SharedBodySystem : EntitySystem { - private const string BodyContainerId = "BodyContainer"; + protected const string BodyContainerId = "BodyContainer"; [Dependency] protected readonly IPrototypeManager Prototypes = default!;