using System; using System.Collections.Generic; using Content.Shared.BodySystem; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Serialization; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; using YamlDotNet.RepresentationModel; namespace Content.Server.BodySystem { /// /// This data class represents the state of a BodyPart in regards to everything surgery related - whether there's an incision on it, whether the bone is broken, etc. /// public abstract class ISurgeryData { /// /// The BodyPart this surgeryData is attached to. The ISurgeryData class should not exist without a BodyPart that it represents, and will not work correctly without it. /// protected BodyPart _parent; /// /// The BodyPartType of the parent PartType. /// protected BodyPartType _parentType => _parent.PartType; public delegate void SurgeryAction(BodyManagerComponent target, IEntity performer); public ISurgeryData(BodyPart parent) { _parent = parent; } /// /// Gets the delegate corresponding to the surgery step using the given SurgeryToolType. Returns null if no surgery step can be performed. /// public abstract SurgeryAction GetSurgeryStep(SurgeryToolType toolType); /// /// Returns whether the given SurgeryToolType can be used to perform a surgery. /// public bool CheckSurgery(SurgeryToolType toolType) { return GetSurgeryStep(toolType) != null; } /// /// Attempts to perform surgery with the given tooltype. Returns whether the operation was successful. /// /// /// The SurgeryToolType used for this surgery. /// /// The entity performing the surgery. public bool PerformSurgery(SurgeryToolType toolType, BodyManagerComponent target, IEntity performer) { SurgeryAction step = GetSurgeryStep(toolType); if (step == null) return false; step(target, performer); return true; } } }