#nullable enable using Content.Shared.GameObjects.Components.Body.Mechanism; using Content.Shared.GameObjects.Components.Body.Part; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; namespace Content.Shared.GameObjects.Components.Body.Surgery { /// /// Represents the current surgery state of a . /// public abstract class SurgeryDataComponent : Component { protected delegate void SurgeryAction(IBodyPartContainer container, ISurgeon surgeon, IEntity performer); /// /// The this /// is attached to. /// protected IBodyPart? Parent => Owner.GetComponentOrNull(); /// /// The of the parent /// . /// protected BodyPartType? ParentType => Parent?.PartType; /// /// Returns a description of this entity. /// /// The description shown upon observing this entity. public abstract string GetDescription(); /// /// Returns whether a can be added into the /// this /// represents. /// public abstract bool CanAddMechanism(IMechanism mechanism); /// /// Returns whether the given can be connected /// to the this /// represents. /// public abstract bool CanAttachBodyPart(IBodyPart part); /// /// Gets the delegate corresponding to the surgery step using the given /// . /// /// /// The corresponding surgery action or null if no step can be /// performed. /// protected abstract SurgeryAction? GetSurgeryStep(SurgeryType toolType); /// /// Returns whether the given can be used to /// perform a surgery on the this /// represents. /// public bool CheckSurgery(SurgeryType toolType) { return GetSurgeryStep(toolType) != null; } /// /// Attempts to perform surgery of the given . /// /// /// The used for this surgery. /// /// /// The container where the surgery is being done. /// /// /// The entity being used to perform the surgery. /// /// The entity performing the surgery. /// True if successful, false otherwise. public bool PerformSurgery(SurgeryType surgeryType, IBodyPartContainer container, ISurgeon surgeon, IEntity performer) { var step = GetSurgeryStep(surgeryType); if (step == null) { return false; } step(container, surgeon, performer); return true; } } }