#nullable enable using Content.Server.Body.Mechanisms; using Content.Shared.GameObjects.Components.Body; using Robust.Shared.Interfaces.GameObjects; namespace Content.Server.Body.Surgery { /// /// This data class represents the state of a in regards to everything surgery related - /// whether there's an incision on it, whether the bone is broken, etc. /// public abstract class SurgeryData { protected delegate void SurgeryAction(IBodyPartContainer container, ISurgeon surgeon, IEntity performer); /// /// The this surgeryData is attached to. /// The class should not exist without a /// that it represents, and will throw errors if it /// is null. /// protected readonly IBodyPart Parent; protected SurgeryData(IBodyPart parent) { Parent = parent; } /// /// The of the parent . /// protected BodyPartType ParentType => Parent.PartType; /// /// Returns the description of this current to be shown /// upon observing the given entity. /// public abstract string GetDescription(IEntity target); /// /// Returns whether a can be installed into the /// this represents. /// public abstract bool CanInstallMechanism(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 BodyPart this /// represents. /// public bool CheckSurgery(SurgeryType toolType) { return GetSurgeryStep(toolType) != null; } /// /// Attempts to perform surgery of the given . Returns whether the operation was successful. /// /// 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. 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; } } }