Add body part and body manager interfaces (#1939)

* Add body part and body manager interfaces

* Merge fixes
This commit is contained in:
DrSmugleaf
2020-08-30 11:26:52 +02:00
committed by GitHub
parent a8aa088058
commit 827eab17d0
16 changed files with 393 additions and 322 deletions

View File

@@ -48,7 +48,7 @@ namespace Content.Server.Body
var slot = part.GetHashCode().ToString();
body.Template.Slots.Add(slot, BodyPartType.Hand);
body.InstallBodyPart(part, slot);
body.TryAddPart(slot, part, true);
}
}

View File

@@ -14,13 +14,11 @@ using Content.Shared.Damage.DamageContainer;
using Content.Shared.Damage.ResistanceSet;
using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.Components.Damage;
using Robust.Server.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Reflection;
using Robust.Shared.Interfaces.Serialization;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
@@ -34,19 +32,10 @@ namespace Content.Server.Body
/// which coordinates functions between BodyParts, or a
/// <see cref="DroppedBodyPartComponent"/>.
/// </summary>
public class BodyPart
public class BodyPart : IBodyPart
{
/// <summary>
/// The body that this body part is in, if any.
/// </summary>
private BodyManagerComponent? _body;
private IBodyManagerComponent? _body;
/// <summary>
/// Set of all <see cref="Mechanism"/> currently inside this
/// <see cref="BodyPart"/>.
/// To add and remove from this list see <see cref="AddMechanism"/> and
/// <see cref="RemoveMechanism"/>
/// </summary>
private readonly HashSet<Mechanism> _mechanisms = new HashSet<Mechanism>();
public BodyPart(BodyPartPrototype data)
@@ -64,11 +53,8 @@ namespace Content.Server.Body
LoadFromPrototype(data);
}
/// <summary>
/// The body that this body part is in, if any.
/// </summary>
[ViewVariables]
public BodyManagerComponent? Body
public IBodyManagerComponent? Body
{
get => _body;
set
@@ -111,91 +97,48 @@ namespace Content.Server.Body
[ViewVariables]
private HashSet<IExposeData> Properties { get; }
/// <summary>
/// The name of this <see cref="BodyPart"/>, often displayed to the user.
/// For example, it could be named "advanced robotic arm".
/// </summary>
[ViewVariables]
public string Name { get; private set; }
[ViewVariables] public string Name { get; private set; }
/// <summary>
/// Plural version of this <see cref="BodyPart"/> name.
/// </summary>
[ViewVariables]
public string Plural { get; private set; }
[ViewVariables] public string Plural { get; private set; }
/// <summary>
/// Path to the RSI that represents this <see cref="BodyPart"/>.
/// </summary>
[ViewVariables]
public string RSIPath { get; private set; }
[ViewVariables] public string RSIPath { get; private set; }
/// <summary>
/// RSI state that represents this <see cref="BodyPart"/>.
/// </summary>
[ViewVariables]
public string RSIState { get; private set; }
[ViewVariables] public string RSIState { get; private set; }
/// <summary>
/// RSI map keys that this body part changes on the sprite.
/// </summary>
[ViewVariables]
public Enum? RSIMap { get; set; }
[ViewVariables] public Enum? RSIMap { get; set; }
/// <summary>
/// RSI color of this body part.
/// </summary>
// TODO: SpriteComponent rework
public Color? RSIColor { get; set; }
[ViewVariables] public Color? RSIColor { get; set; }
/// <summary>
/// <see cref="BodyPartType"/> that this <see cref="BodyPart"/> is considered
/// to be.
/// For example, <see cref="BodyPartType.Arm"/>.
/// </summary>
[ViewVariables]
public BodyPartType PartType { get; private set; }
[ViewVariables] public BodyPartType PartType { get; private set; }
/// <summary>
/// Determines many things: how many mechanisms can be fit inside this
/// <see cref="BodyPart"/>, whether a body can fit through tiny crevices, etc.
/// </summary>
[ViewVariables]
private int Size { get; set; }
[ViewVariables] public int Size { get; private set; }
/// <summary>
/// Max HP of this <see cref="BodyPart"/>.
/// </summary>
[ViewVariables]
public int MaxDurability { get; private set; }
[ViewVariables] public int MaxDurability { get; private set; }
/// <summary>
/// Current HP of this <see cref="BodyPart"/> based on sum of all damage types.
/// </summary>
[ViewVariables]
public int CurrentDurability => MaxDurability - Damage.TotalDamage;
[ViewVariables] public int CurrentDurability => MaxDurability - Damage.TotalDamage;
// TODO: Individual body part damage
/// <summary>
/// Current damage dealt to this <see cref="BodyPart"/>.
/// Current damage dealt to this <see cref="IBodyPart"/>.
/// </summary>
[ViewVariables]
public DamageContainer Damage { get; private set; }
/// <summary>
/// Armor of this <see cref="BodyPart"/> against damages.
/// Armor of this <see cref="IBodyPart"/> against damages.
/// </summary>
[ViewVariables]
public ResistanceSet Resistances { get; private set; }
/// <summary>
/// At what HP this <see cref="BodyPart"/> destroyed.
/// At what HP this <see cref="IBodyPart"/> destroyed.
/// </summary>
[ViewVariables]
public int DestroyThreshold { get; private set; }
/// <summary>
/// What types of BodyParts this <see cref="BodyPart"/> can easily attach to.
/// What types of BodyParts this <see cref="IBodyPart"/> can easily attach to.
/// For the most part, most limbs aren't universal and require extra work to
/// attach between types.
/// </summary>
@@ -204,14 +147,15 @@ namespace Content.Server.Body
/// <summary>
/// Set of all <see cref="Mechanism"/> currently inside this
/// <see cref="BodyPart"/>.
/// <see cref="IBodyPart"/>.
/// </summary>
[ViewVariables]
public IReadOnlyCollection<Mechanism> Mechanisms => _mechanisms;
/// <summary>
/// This method is called by <see cref="BodyManagerComponent.Update"/>
/// before <see cref="MetabolismComponent.Update"/> is called.
/// This method is called by
/// <see cref="IBodyManagerComponent.PreMetabolism"/> before
/// <see cref="MetabolismComponent.Update"/> is called.
/// </summary>
public void PreMetabolism(float frameTime)
{
@@ -222,8 +166,9 @@ namespace Content.Server.Body
}
/// <summary>
/// This method is called by <see cref="BodyManagerComponent.Update"/>
/// after <see cref="MetabolismComponent.Update"/> is called.
/// This method is called by
/// <see cref="IBodyManagerComponent.PostMetabolism"/> after
/// <see cref="MetabolismComponent.Update"/> is called.
/// </summary>
public void PostMetabolism(float frameTime)
{
@@ -258,9 +203,10 @@ namespace Content.Server.Body
/// <param name="property">The property if found, null otherwise.</param>
/// <typeparam name="T">The type of the property to find.</typeparam>
/// <returns>True if successful, false otherwise.</returns>
public bool TryGetProperty<T>(out T property)
public bool TryGetProperty<T>([NotNullWhen(true)] out T? property) where T : BodyPartProperty
{
property = (T) Properties.First(x => x.GetType() == typeof(T));
property = (T?) Properties.FirstOrDefault(x => x.GetType() == typeof(T));
return property != null;
}
@@ -269,20 +215,21 @@ namespace Content.Server.Body
/// The resulting <see cref="BodyPartProperty"/> will be null if unsuccessful.
/// </summary>
/// <returns>True if successful, false otherwise.</returns>
public bool TryGetProperty(Type propertyType, out BodyPartProperty property)
public bool TryGetProperty(Type propertyType, [NotNullWhen(true)] out BodyPartProperty? property)
{
property = (BodyPartProperty) Properties.First(x => x.GetType() == propertyType);
property = (BodyPartProperty?) Properties.First(x => x.GetType() == propertyType);
return property != null;
}
/// <summary>
/// Checks if the given type <see cref="T"/> is on this <see cref="BodyPart"/>.
/// Checks if the given type <see cref="T"/> is on this <see cref="IBodyPart"/>.
/// </summary>
/// <typeparam name="T">
/// The subtype of <see cref="BodyPartProperty"/> to look for.
/// </typeparam>
/// <returns>
/// True if this <see cref="BodyPart"/> has a property of type
/// True if this <see cref="IBodyPart"/> has a property of type
/// <see cref="T"/>, false otherwise.
/// </returns>
public bool HasProperty<T>() where T : BodyPartProperty
@@ -292,13 +239,13 @@ namespace Content.Server.Body
/// <summary>
/// Checks if a subtype of <see cref="BodyPartProperty"/> is on this
/// <see cref="BodyPart"/>.
/// <see cref="IBodyPart"/>.
/// </summary>
/// <param name="propertyType">
/// The subtype of <see cref="BodyPartProperty"/> to look for.
/// </param>
/// <returns>
/// True if this <see cref="BodyPart"/> has a property of type
/// True if this <see cref="IBodyPart"/> has a property of type
/// <see cref="propertyType"/>, false otherwise.
/// </returns>
public bool HasProperty(Type propertyType)
@@ -306,21 +253,11 @@ namespace Content.Server.Body
return Properties.Count(x => x.GetType() == propertyType) > 0;
}
/// <summary>
/// Checks if another <see cref="BodyPart"/> can be connected to this one.
/// </summary>
/// <param name="toBeConnected">The part to connect.</param>
/// <returns>True if it can be connected, false otherwise.</returns>
public bool CanAttachBodyPart(BodyPart toBeConnected)
public bool CanAttachPart(IBodyPart part)
{
return SurgeryData.CanAttachBodyPart(toBeConnected);
return SurgeryData.CanAttachBodyPart(part);
}
/// <summary>
/// Checks if a <see cref="Mechanism"/> can be installed on this
/// <see cref="BodyPart"/>.
/// </summary>
/// <returns>True if it can be installed, false otherwise.</returns>
public bool CanInstallMechanism(Mechanism mechanism)
{
return SizeUsed + mechanism.Size <= Size &&
@@ -336,7 +273,7 @@ namespace Content.Server.Body
/// <param name="mechanism">The mechanism to try to install.</param>
/// <returns>
/// True if successful, false if there was an error
/// (e.g. not enough room in <see cref="BodyPart"/>).
/// (e.g. not enough room in <see cref="IBodyPart"/>).
/// </returns>
private bool TryInstallMechanism(Mechanism mechanism)
{
@@ -352,7 +289,7 @@ namespace Content.Server.Body
/// <summary>
/// Tries to install a <see cref="DroppedMechanismComponent"/> into this
/// <see cref="BodyPart"/>, potentially deleting the dropped
/// <see cref="IBodyPart"/>, potentially deleting the dropped
/// <see cref="IEntity"/>.
/// </summary>
/// <param name="droppedMechanism">The mechanism to install.</param>
@@ -364,21 +301,13 @@ namespace Content.Server.Body
{
if (!TryInstallMechanism(droppedMechanism.ContainedMechanism))
{
return false; //Installing the mechanism failed for some reason.
return false; // Installing the mechanism failed for some reason.
}
droppedMechanism.Owner.Delete();
return true;
}
/// <summary>
/// Tries to remove the given <see cref="Mechanism"/> reference from
/// this <see cref="BodyPart"/>.
/// </summary>
/// <returns>
/// The newly spawned <see cref="DroppedMechanismComponent"/>, or null
/// if there was an error in spawning the entity or removing the mechanism.
/// </returns>
public bool TryDropMechanism(IEntity dropLocation, Mechanism mechanismTarget,
[NotNullWhen(true)] out DroppedMechanismComponent dropped)
{
@@ -403,11 +332,11 @@ namespace Content.Server.Body
/// <summary>
/// Tries to destroy the given <see cref="Mechanism"/> in this
/// <see cref="BodyPart"/>. Does NOT spawn a dropped entity.
/// <see cref="IBodyPart"/>. Does NOT spawn a dropped entity.
/// </summary>
/// <summary>
/// Tries to destroy the given <see cref="Mechanism"/> in this
/// <see cref="BodyPart"/>.
/// <see cref="IBodyPart"/>.
/// </summary>
/// <param name="mechanismTarget">The mechanism to destroy.</param>
/// <returns>True if successful, false otherwise.</returns>
@@ -421,18 +350,13 @@ namespace Content.Server.Body
return true;
}
/// <summary>
/// Checks if the given <see cref="SurgeryType"/> can be used on
/// the current state of this <see cref="BodyPart"/>.
/// </summary>
/// <returns>True if it can be used, false otherwise.</returns>
public bool SurgeryCheck(SurgeryType toolType)
public bool SurgeryCheck(SurgeryType surgery)
{
return SurgeryData.CheckSurgery(toolType);
return SurgeryData.CheckSurgery(surgery);
}
/// <summary>
/// Attempts to perform surgery on this <see cref="BodyPart"/> with the given
/// Attempts to perform surgery on this <see cref="IBodyPart"/> with the given
/// tool.
/// </summary>
/// <returns>True if successful, false if there was an error.</returns>
@@ -474,7 +398,7 @@ namespace Content.Server.Body
/// <summary>
/// Tries to remove the given <see cref="mechanism"/> from this
/// <see cref="BodyPart"/>.
/// <see cref="IBodyPart"/>.
/// </summary>
/// <param name="mechanism">The mechanism to remove.</param>
/// <returns>True if it was removed, false otherwise.</returns>
@@ -515,7 +439,7 @@ namespace Content.Server.Body
/// <summary>
/// Loads the given <see cref="BodyPartPrototype"/>.
/// Current data on this <see cref="BodyPart"/> will be overwritten!
/// Current data on this <see cref="IBodyPart"/> will be overwritten!
/// </summary>
protected virtual void LoadFromPrototype(BodyPartPrototype data)
{

View File

@@ -21,7 +21,7 @@ namespace Content.Server.Body
[ViewVariables] public string Name { get; private set; }
/// <summary>
/// Maps a template slot to the ID of the <see cref="BodyPart"/> that should
/// Maps a template slot to the ID of the <see cref="IBodyPart"/> that should
/// fill it. E.g. "right arm" : "BodyPart.arm.basic_human".
/// </summary>
[ViewVariables]

View File

@@ -0,0 +1,131 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Content.Server.Body.Mechanisms;
using Content.Server.GameObjects.Components.Body;
using Content.Shared.Body.Part.Properties;
using Content.Shared.GameObjects.Components.Body;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Maths;
namespace Content.Server.Body
{
public interface IBodyPart
{
/// <summary>
/// The body that this body part is currently in, if any.
/// </summary>
IBodyManagerComponent? Body { get; set; }
/// <summary>
/// <see cref="BodyPartType"/> that this <see cref="IBodyPart"/> is considered
/// to be.
/// For example, <see cref="BodyPartType.Arm"/>.
/// </summary>
BodyPartType PartType { get; }
/// <summary>
/// The name of this <see cref="IBodyPart"/>, often displayed to the user.
/// For example, it could be named "advanced robotic arm".
/// </summary>
public string Name { get; }
/// <summary>
/// Plural version of this <see cref="IBodyPart"/> name.
/// </summary>
public string Plural { get; }
/// <summary>
/// Determines many things: how many mechanisms can be fit inside this
/// <see cref="IBodyPart"/>, whether a body can fit through tiny crevices,
/// etc.
/// </summary>
int Size { get; }
/// <summary>
/// Max HP of this <see cref="IBodyPart"/>.
/// </summary>
int MaxDurability { get; }
/// <summary>
/// Current HP of this <see cref="IBodyPart"/> based on sum of all damage types.
/// </summary>
int CurrentDurability { get; }
/// <summary>
/// Collection of all <see cref="Mechanism"/>s currently inside this
/// <see cref="IBodyPart"/>.
/// To add and remove from this list see <see cref="AddMechanism"/> and
/// <see cref="RemoveMechanism"/>
/// </summary>
IReadOnlyCollection<Mechanism> Mechanisms { get; }
/// <summary>
/// Path to the RSI that represents this <see cref="IBodyPart"/>.
/// </summary>
public string RSIPath { get; }
/// <summary>
/// RSI state that represents this <see cref="IBodyPart"/>.
/// </summary>
public string RSIState { get; }
/// <summary>
/// RSI map keys that this body part changes on the sprite.
/// </summary>
public Enum? RSIMap { get; set; }
/// <summary>
/// RSI color of this body part.
/// </summary>
// TODO: SpriteComponent rework
public Color? RSIColor { get; set; }
bool HasProperty<T>() where T : BodyPartProperty;
bool HasProperty(Type type);
bool TryGetProperty<T>([NotNullWhen(true)] out T? property) where T : BodyPartProperty;
void PreMetabolism(float frameTime);
void PostMetabolism(float frameTime);
bool SpawnDropped([NotNullWhen(true)] out IEntity? dropped);
/// <summary>
/// Checks if the given <see cref="SurgeryType"/> can be used on
/// the current state of this <see cref="IBodyPart"/>.
/// </summary>
/// <returns>True if it can be used, false otherwise.</returns>
bool SurgeryCheck(SurgeryType surgery);
/// <summary>
/// Checks if another <see cref="IBodyPart"/> can be connected to this one.
/// </summary>
/// <param name="part">The part to connect.</param>
/// <returns>True if it can be connected, false otherwise.</returns>
bool CanAttachPart(IBodyPart part);
/// <summary>
/// Checks if a <see cref="Mechanism"/> can be installed on this
/// <see cref="IBodyPart"/>.
/// </summary>
/// <returns>True if it can be installed, false otherwise.</returns>
bool CanInstallMechanism(Mechanism mechanism);
/// <summary>
/// Tries to remove the given <see cref="Mechanism"/> reference from
/// this <see cref="IBodyPart"/>.
/// </summary>
/// <returns>
/// The newly spawned <see cref="DroppedMechanismComponent"/>, or null
/// if there was an error in spawning the entity or removing the mechanism.
/// </returns>
bool TryDropMechanism(IEntity dropLocation, Mechanism mechanismTarget,
[NotNullWhen(true)] out DroppedMechanismComponent dropped);
bool DestroyMechanism(Mechanism mechanism);
}
}

View File

@@ -7,11 +7,11 @@ namespace Content.Server.Body
/// Making a class inherit from this interface allows you to do many things with
/// it in the <see cref="SurgeryData"/> class.
/// This includes passing it as an argument to a
/// <see cref="SurgeryData.SurgeryAction"/> delegate, as to later typecast it back
/// to the original class type.
/// Every BodyPart also needs an <see cref="IBodyPartContainer"/> to be its parent
/// (i.e. the <see cref="BodyManagerComponent"/> holds many <see cref="BodyPart"/>,
/// each of which have an upward reference to it).
/// <see cref="SurgeryData.SurgeryAction"/> delegate, as to later typecast
/// it back to the original class type.
/// Every BodyPart also needs an <see cref="IBodyPartContainer"/> to be
/// its parent (i.e. the <see cref="BodyManagerComponent"/> holds many
/// <see cref="IBodyPart"/>, each of which have an upward reference to it).
/// </summary>
public interface IBodyPartContainer
{

View File

@@ -70,7 +70,7 @@ namespace Content.Server.Body.Mechanisms.Behaviors
}
/// <summary>
/// Called when the containing <see cref="BodyPart"/> is attached to a
/// Called when the containing <see cref="IBodyPart"/> is attached to a
/// <see cref="BodyManagerComponent"/>.
/// For instance, attaching a head to a body will call this on the brain inside.
/// </summary>
@@ -82,7 +82,7 @@ namespace Content.Server.Body.Mechanisms.Behaviors
/// <summary>
/// Called when the parent <see cref="Mechanisms.Mechanism"/> is
/// installed into a <see cref="BodyPart"/>.
/// installed into a <see cref="IBodyPart"/>.
/// For instance, putting a brain into an empty head.
/// </summary>
public void InstalledIntoPart()
@@ -92,22 +92,22 @@ namespace Content.Server.Body.Mechanisms.Behaviors
}
/// <summary>
/// Called when the containing <see cref="BodyPart"/> is removed from a
/// Called when the containing <see cref="IBodyPart"/> is removed from a
/// <see cref="BodyManagerComponent"/>.
/// For instance, cutting off ones head will call this on the brain inside.
/// </summary>
public void RemovedFromBody(BodyManagerComponent old)
public void RemovedFromBody(IBodyManagerComponent old)
{
OnRemovedFromBody(old);
TryRemoveNetwork(old);
}
/// <summary>
/// Called when the parent <see cref="Mechanisms.Mechanism"/> is removed from a
/// <see cref="BodyPart"/>.
/// Called when the parent <see cref="Mechanisms.Mechanism"/> is
/// removed from a <see cref="IBodyPart"/>.
/// For instance, taking a brain out of ones head.
/// </summary>
public void RemovedFromPart(BodyPart old)
public void RemovedFromPart(IBodyPart old)
{
OnRemovedFromPart(old);
TryRemoveNetwork(old.Body);
@@ -121,7 +121,7 @@ namespace Content.Server.Body.Mechanisms.Behaviors
}
}
private void TryRemoveNetwork(BodyManagerComponent? body)
private void TryRemoveNetwork(IBodyManagerComponent? body)
{
if (Network != null)
{
@@ -137,7 +137,7 @@ namespace Content.Server.Body.Mechanisms.Behaviors
protected virtual void OnRemove() { }
/// <summary>
/// Called when the containing <see cref="BodyPart"/> is attached to a
/// Called when the containing <see cref="IBodyPart"/> is attached to a
/// <see cref="BodyManagerComponent"/>.
/// For instance, attaching a head to a body will call this on the brain inside.
/// </summary>
@@ -145,24 +145,24 @@ namespace Content.Server.Body.Mechanisms.Behaviors
/// <summary>
/// Called when the parent <see cref="Mechanisms.Mechanism"/> is
/// installed into a <see cref="BodyPart"/>.
/// installed into a <see cref="IBodyPart"/>.
/// For instance, putting a brain into an empty head.
/// </summary>
protected virtual void OnInstalledIntoPart() { }
/// <summary>
/// Called when the containing <see cref="BodyPart"/> is removed from a
/// Called when the containing <see cref="IBodyPart"/> is removed from a
/// <see cref="BodyManagerComponent"/>.
/// For instance, cutting off ones head will call this on the brain inside.
/// </summary>
protected virtual void OnRemovedFromBody(BodyManagerComponent old) { }
protected virtual void OnRemovedFromBody(IBodyManagerComponent old) { }
/// <summary>
/// Called when the parent <see cref="Mechanisms.Mechanism"/> is removed from a
/// <see cref="BodyPart"/>.
/// Called when the parent <see cref="Mechanisms.Mechanism"/> is
/// removed from a <see cref="IBodyPart"/>.
/// For instance, taking a brain out of ones head.
/// </summary>
protected virtual void OnRemovedFromPart(BodyPart old) { }
protected virtual void OnRemovedFromPart(IBodyPart old) { }
/// <summary>
/// Called every update when this behavior is connected to a

View File

@@ -12,13 +12,13 @@ using Robust.Shared.ViewVariables;
namespace Content.Server.Body.Mechanisms
{
/// <summary>
/// Data class representing a persistent item inside a <see cref="BodyPart"/>.
/// Data class representing a persistent item inside a <see cref="IBodyPart"/>.
/// This includes livers, eyes, cameras, brains, explosive implants,
/// binary communicators, and other things.
/// </summary>
public class Mechanism
{
private BodyPart? _part;
private IBodyPart? _part;
public Mechanism(MechanismPrototype data)
{
@@ -91,13 +91,13 @@ namespace Content.Server.Body.Mechanisms
/// <summary>
/// Determines a handful of things - mostly whether this
/// <see cref="Mechanism"/> can fit into a <see cref="BodyPart"/>.
/// <see cref="Mechanism"/> can fit into a <see cref="IBodyPart"/>.
/// </summary>
[ViewVariables]
public int Size { get; set; }
/// <summary>
/// What kind of <see cref="BodyPart"/> this <see cref="Mechanism"/> can be
/// What kind of <see cref="IBodyPart"/> this <see cref="Mechanism"/> can be
/// easily installed into.
/// </summary>
[ViewVariables]
@@ -109,9 +109,9 @@ namespace Content.Server.Body.Mechanisms
[ViewVariables]
private List<MechanismBehavior> Behaviors { get; }
public BodyManagerComponent? Body => Part?.Body;
public IBodyManagerComponent? Body => Part?.Body;
public BodyPart? Part
public IBodyPart? Part
{
get => _part;
set
@@ -202,7 +202,7 @@ namespace Content.Server.Body.Mechanisms
}
}
public void RemovedFromBody(BodyManagerComponent old)
public void RemovedFromBody(IBodyManagerComponent old)
{
foreach (var behavior in Behaviors)
{
@@ -211,7 +211,7 @@ namespace Content.Server.Body.Mechanisms
}
/// <summary>
/// This method is called by <see cref="BodyPart.PreMetabolism"/> before
/// This method is called by <see cref="IBodyPart.PreMetabolism"/> before
/// <see cref="MetabolismComponent.Update"/> is called.
/// </summary>
public void PreMetabolism(float frameTime)
@@ -223,7 +223,7 @@ namespace Content.Server.Body.Mechanisms
}
/// <summary>
/// This method is called by <see cref="BodyPart.PostMetabolism"/> after
/// This method is called by <see cref="IBodyPart.PostMetabolism"/> after
/// <see cref="MetabolismComponent.Update"/> is called.
/// </summary>
public void PostMetabolism(float frameTime)

View File

@@ -23,7 +23,7 @@ namespace Content.Server.Body.Surgery
private bool _skinRetracted;
private bool _vesselsClamped;
public BiologicalSurgeryData(BodyPart parent) : base(parent) { }
public BiologicalSurgeryData(IBodyPart parent) : base(parent) { }
protected override SurgeryAction? GetSurgeryStep(SurgeryType toolType)
{
@@ -123,7 +123,7 @@ namespace Content.Server.Body.Surgery
return _skinOpened && _vesselsClamped && _skinRetracted;
}
public override bool CanAttachBodyPart(BodyPart part)
public override bool CanAttachBodyPart(IBodyPart part)
{
return true;
// TODO: if a bodypart is disconnected, you should have to do some surgery to allow another bodypart to be attached.
@@ -216,8 +216,7 @@ namespace Content.Server.Body.Surgery
}
}
private void RemoveOrganSurgeryCallback(Mechanism target, IBodyPartContainer container,
ISurgeon surgeon,
private void RemoveOrganSurgeryCallback(Mechanism target, IBodyPartContainer container, ISurgeon surgeon,
IEntity performer)
{
if (target == null || !Parent.Mechanisms.Contains(target))

View File

@@ -6,7 +6,7 @@ using Robust.Shared.Interfaces.GameObjects;
namespace Content.Server.Body.Surgery
{
/// <summary>
/// This data class represents the state of a <see cref="BodyPart"/> in regards to everything surgery related -
/// This data class represents the state of a <see cref="IBodyPart"/> in regards to everything surgery related -
/// whether there's an incision on it, whether the bone is broken, etc.
/// </summary>
public abstract class SurgeryData
@@ -14,40 +14,40 @@ namespace Content.Server.Body.Surgery
protected delegate void SurgeryAction(IBodyPartContainer container, ISurgeon surgeon, IEntity performer);
/// <summary>
/// The <see cref="BodyPart"/> this surgeryData is attached to.
/// The <see cref="IBodyPart"/> this surgeryData is attached to.
/// The <see cref="SurgeryData"/> class should not exist without a
/// <see cref="BodyPart"/> that it represents, and will throw errors if it
/// <see cref="IBodyPart"/> that it represents, and will throw errors if it
/// is null.
/// </summary>
protected readonly BodyPart Parent;
protected readonly IBodyPart Parent;
protected SurgeryData(BodyPart parent)
protected SurgeryData(IBodyPart parent)
{
Parent = parent;
}
/// <summary>
/// The <see cref="BodyPartType"/> of the parent <see cref="BodyPart"/>.
/// The <see cref="BodyPartType"/> of the parent <see cref="IBodyPart"/>.
/// </summary>
protected BodyPartType ParentType => Parent.PartType;
/// <summary>
/// Returns the description of this current <see cref="BodyPart"/> to be shown
/// Returns the description of this current <see cref="IBodyPart"/> to be shown
/// upon observing the given entity.
/// </summary>
public abstract string GetDescription(IEntity target);
/// <summary>
/// Returns whether a <see cref="Mechanism"/> can be installed into the
/// <see cref="BodyPart"/> this <see cref="SurgeryData"/> represents.
/// <see cref="IBodyPart"/> this <see cref="SurgeryData"/> represents.
/// </summary>
public abstract bool CanInstallMechanism(Mechanism mechanism);
/// <summary>
/// Returns whether the given <see cref="BodyPart"/> can be connected to the
/// <see cref="BodyPart"/> this <see cref="SurgeryData"/> represents.
/// Returns whether the given <see cref="IBodyPart"/> can be connected to the
/// <see cref="IBodyPart"/> this <see cref="SurgeryData"/> represents.
/// </summary>
public abstract bool CanAttachBodyPart(BodyPart part);
public abstract bool CanAttachBodyPart(IBodyPart part);
/// <summary>
/// Gets the delegate corresponding to the surgery step using the given