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 in regards to everything surgery related - whether there's an incision on it, whether the bone is broken, etc. /// public abstract class ISurgeryData { /// /// The this surgeryData is attached to. The ISurgeryData class should not exist without a that it /// represents, and will throw errors if it is null. /// protected BodyPart _parent; /// /// The of the parent . /// protected BodyPartType _parentType => _parent.PartType; public delegate void SurgeryAction(IBodyPartContainer container, ISurgeon surgeon, IEntity performer); public ISurgeryData(BodyPart parent) { _parent = parent; } /// /// 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 ISurgeryData represents. /// public abstract bool CanInstallMechanism(Mechanism toBeInstalled); /// /// Returns whether the given can be connected to the this ISurgeryData represents. /// public abstract bool CanAttachBodyPart(BodyPart toBeConnected); /// /// Gets the delegate corresponding to the surgery step using the given . Returns null if no surgery step can be performed. /// public 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 entity performing the surgery. public bool PerformSurgery(SurgeryType surgeryType, IBodyPartContainer container, ISurgeon surgeon, IEntity performer) { SurgeryAction step = GetSurgeryStep(surgeryType); if (step == null) return false; step(container, surgeon, performer); return true; } } }