diff --git a/Content.Server/GameObjects/Components/Body/BodyComponent.cs b/Content.Server/GameObjects/Components/Body/BodyComponent.cs index a440612a85..6de7cb07cf 100644 --- a/Content.Server/GameObjects/Components/Body/BodyComponent.cs +++ b/Content.Server/GameObjects/Components/Body/BodyComponent.cs @@ -17,32 +17,33 @@ namespace Content.Server.GameObjects.Components.Body [ComponentReference(typeof(IBody))] public class BodyComponent : SharedBodyComponent, IRelayMoveInput { - private Container _container = default!; + private Container _partContainer = default!; protected override bool CanAddPart(string slot, IBodyPart part) { - return base.CanAddPart(slot, part) && _container.CanInsert(part.Owner); + return base.CanAddPart(slot, part) && + _partContainer.CanInsert(part.Owner); } protected override void OnAddPart(string slot, IBodyPart part) { base.OnAddPart(slot, part); - _container.Insert(part.Owner); + _partContainer.Insert(part.Owner); } protected override void OnRemovePart(string slot, IBodyPart part) { base.OnRemovePart(slot, part); - _container.ForceRemove(part.Owner); + _partContainer.ForceRemove(part.Owner); } public override void Initialize() { base.Initialize(); - _container = ContainerManagerComponent.Ensure($"{Name}-{nameof(BodyComponent)}", Owner); + _partContainer = ContainerManagerComponent.Ensure($"{Name}-{nameof(BodyComponent)}", Owner); foreach (var (slot, partId) in PartIds) { diff --git a/Content.Server/GameObjects/Components/Body/Part/BodyPartComponent.cs b/Content.Server/GameObjects/Components/Body/Part/BodyPartComponent.cs index fce65d607c..8d5c568689 100644 --- a/Content.Server/GameObjects/Components/Body/Part/BodyPartComponent.cs +++ b/Content.Server/GameObjects/Components/Body/Part/BodyPartComponent.cs @@ -9,6 +9,7 @@ using Content.Shared.GameObjects.Components.Body.Surgery; using Content.Shared.Interfaces; using Content.Shared.Interfaces.GameObjects.Components; using Robust.Server.GameObjects; +using Robust.Server.GameObjects.Components.Container; using Robust.Server.GameObjects.Components.UserInterface; using Robust.Server.Interfaces.GameObjects; using Robust.Server.Interfaces.Player; @@ -26,39 +27,39 @@ namespace Content.Server.GameObjects.Components.Body.Part public class BodyPartComponent : SharedBodyPartComponent, IAfterInteract { private readonly Dictionary _optionsCache = new Dictionary(); - private IBody? _owningBodyCache; - private int _idHash; - private IEntity? _surgeonCache; + private Container _mechanismContainer = default!; [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(SurgeryUIKey.Key); + public override bool CanAddMechanism(IMechanism mechanism) + { + return base.CanAddMechanism(mechanism) && + _mechanismContainer.CanInsert(mechanism.Owner); + } + protected override void OnAddMechanism(IMechanism mechanism) { base.OnAddMechanism(mechanism); - if (mechanism.Owner.TryGetComponent(out SpriteComponent? sprite)) - { - sprite.Visible = false; - } + _mechanismContainer.Insert(mechanism.Owner); } protected override void OnRemoveMechanism(IMechanism mechanism) { base.OnRemoveMechanism(mechanism); - if (mechanism.Owner.TryGetComponent(out SpriteComponent? sprite)) - { - sprite.Visible = true; - } + _mechanismContainer.Remove(mechanism.Owner); } public override void Initialize() { base.Initialize(); + _mechanismContainer = ContainerManagerComponent.Ensure($"{Name}-{nameof(BodyPartComponent)}", Owner); + // This is ran in Startup as entities spawned in Initialize // are not synced to the client since they are assumed to be // identical on it diff --git a/Content.Shared/GameObjects/Components/Body/Behavior/IMechanismBehavior.cs b/Content.Shared/GameObjects/Components/Body/Behavior/IMechanismBehavior.cs index 85213d442c..edbf8e5d42 100644 --- a/Content.Shared/GameObjects/Components/Body/Behavior/IMechanismBehavior.cs +++ b/Content.Shared/GameObjects/Components/Body/Behavior/IMechanismBehavior.cs @@ -17,8 +17,6 @@ namespace Content.Shared.GameObjects.Components.Body.Behavior /// IMechanism? Mechanism { get; } - void Update(float frameTime); - /// /// Called when the containing is attached to a /// . diff --git a/Content.Shared/GameObjects/Components/Body/Part/SharedBodyPartComponent.cs b/Content.Shared/GameObjects/Components/Body/Part/SharedBodyPartComponent.cs index f86ff22c3b..0b6c4a3504 100644 --- a/Content.Shared/GameObjects/Components/Body/Part/SharedBodyPartComponent.cs +++ b/Content.Shared/GameObjects/Components/Body/Part/SharedBodyPartComponent.cs @@ -210,7 +210,7 @@ namespace Content.Shared.GameObjects.Components.Body.Part return SurgeryDataComponent?.CanAttachBodyPart(part) ?? false; } - public bool CanAddMechanism(IMechanism mechanism) + public virtual bool CanAddMechanism(IMechanism mechanism) { DebugTools.AssertNotNull(mechanism);