Update documentation for body system code (#2556)
This commit is contained in:
@@ -4,7 +4,7 @@ using Robust.Shared.Serialization;
|
||||
namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to determine whether a BodyPart can connect to another BodyPart.
|
||||
/// Determines whether two <see cref="IBodyPart"/>s can connect.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public enum BodyPartCompatibility
|
||||
|
||||
@@ -7,16 +7,46 @@ namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
{
|
||||
public static class BodyPartExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if the given <see cref="IBodyPart"/> has the specified property.
|
||||
/// </summary>
|
||||
/// <param name="part">The <see cref="IBodyPart"/> to check in.</param>
|
||||
/// <param name="type">
|
||||
/// The type of <see cref="IBodyPartProperty"/> to check for.
|
||||
/// </param>
|
||||
/// <returns>true if found, false otherwise.</returns>
|
||||
public static bool HasProperty(this IBodyPart part, Type type)
|
||||
{
|
||||
return part.Owner.HasComponent(type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the given <see cref="IBodyPart"/> has the specified property.
|
||||
/// </summary>
|
||||
/// <param name="part">The <see cref="IBodyPart"/> to check in.</param>
|
||||
/// <typeparam name="T">
|
||||
/// The type of <see cref="IBodyPartProperty"/> to check for.
|
||||
/// </typeparam>
|
||||
/// <returns>true if found, false otherwise.</returns>
|
||||
public static bool HasProperty<T>(this IBodyPart part) where T : class, IBodyPartProperty
|
||||
{
|
||||
return part.HasProperty(typeof(T));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to retrieve the <see cref="IBodyPartProperty"/> with the
|
||||
/// specified type.
|
||||
/// </summary>
|
||||
/// <param name="part">The <see cref="IBodyPart"/> to search in.</param>
|
||||
/// <param name="type">
|
||||
/// The type of <see cref="IBodyPartProperty"/> to search for.
|
||||
/// </param>
|
||||
/// <param name="property">
|
||||
/// The property, if it was found. Null otherwise.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// true if a component with the specified type was found, false otherwise.
|
||||
/// </returns>
|
||||
public static bool TryGetProperty(this IBodyPart part, Type type,
|
||||
[NotNullWhen(true)] out IBodyPartProperty? property)
|
||||
{
|
||||
@@ -29,6 +59,20 @@ namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
return (property = component as IBodyPartProperty) != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to retrieve the <see cref="IBodyPartProperty"/> with the
|
||||
/// specified type.
|
||||
/// </summary>
|
||||
/// <param name="part">The <see cref="IBodyPart"/> to search in.</param>
|
||||
/// <typeparam name="T">
|
||||
/// The type of <see cref="IBodyPartProperty"/> to search for.
|
||||
/// </typeparam>
|
||||
/// <param name="property">
|
||||
/// The property, if it was found. Null otherwise.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// true if a component with the specified type was found, false otherwise.
|
||||
/// </returns>
|
||||
public static bool TryGetProperty<T>(this IBodyPart part, [NotNullWhen(true)] out T? property) where T : class, IBodyPartProperty
|
||||
{
|
||||
return part.Owner.TryGetComponent(out property);
|
||||
|
||||
@@ -3,6 +3,9 @@ using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the symmetry of a <see cref="IBodyPart"/>.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public enum BodyPartSymmetry
|
||||
{
|
||||
|
||||
@@ -4,8 +4,7 @@ using Robust.Shared.Serialization;
|
||||
namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
{
|
||||
/// <summary>
|
||||
/// Each BodyPart has a BodyPartType used to determine a variety of things.
|
||||
/// For instance, what slots it can fit into.
|
||||
/// Defines the type of a <see cref="IBodyPart"/>.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public enum BodyPartType
|
||||
|
||||
@@ -9,6 +9,10 @@ namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
{
|
||||
public interface IBodyPart : IComponent, IBodyPartContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="IBody"/> to which this <see cref="IBodyPart"/> is
|
||||
/// attached to.
|
||||
/// </summary>
|
||||
IBody? Body { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -19,9 +23,8 @@ namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
BodyPartType PartType { 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.
|
||||
/// Determines how many mechanisms can be fit inside this
|
||||
/// <see cref="IBodyPart"/>.
|
||||
/// </summary>
|
||||
int Size { get; }
|
||||
|
||||
@@ -29,16 +32,20 @@ namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
/// <summary>
|
||||
/// Collection of all <see cref="IMechanism"/>s currently inside this
|
||||
/// <see cref="IBodyPart"/>.
|
||||
/// To add and remove from this list see <see cref="AddMechanism"/> and
|
||||
/// To add and remove from this list see <see cref="TryAddMechanism"/> and
|
||||
/// <see cref="RemoveMechanism"/>
|
||||
/// </summary>
|
||||
IReadOnlyCollection<IMechanism> Mechanisms { get; }
|
||||
|
||||
/// <summary>
|
||||
/// If body part is vital
|
||||
/// Whether or not the owning <see cref="Body"/> will die if all
|
||||
/// <see cref="IBodyPart"/>s of this type are removed from it.
|
||||
/// </summary>
|
||||
public bool IsVital { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The symmetry of this <see cref="IBodyPart"/>.
|
||||
/// </summary>
|
||||
public BodyPartSymmetry Symmetry { get; }
|
||||
|
||||
/// <summary>
|
||||
@@ -70,6 +77,16 @@ namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
/// <returns>True if it can be added, false otherwise.</returns>
|
||||
bool CanAddMechanism(IMechanism mechanism);
|
||||
|
||||
/// <summary>
|
||||
/// Tries to add a <see cref="IMechanism"/> to this body.
|
||||
/// </summary>
|
||||
/// <param name="mechanism">The mechanism to add.</param>
|
||||
/// <param name="force">
|
||||
/// Whether or not to check if the mechanism is compatible.
|
||||
/// Passing true does not guarantee it to be added, for example if
|
||||
/// it was already added before.
|
||||
/// </param>
|
||||
/// <returns>true if added, false otherwise even if it was already added.</returns>
|
||||
bool TryAddMechanism(IMechanism mechanism, bool force = false);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
{
|
||||
@@ -6,8 +7,13 @@ namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
/// This interface gives components behavior when a body part
|
||||
/// is added to their owning entity.
|
||||
/// </summary>
|
||||
public interface IBodyPartAdded
|
||||
public interface IBodyPartAdded : IComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Called when a <see cref="IBodyPart"/> is added to the
|
||||
/// entity owning this component.
|
||||
/// </summary>
|
||||
/// <param name="args">Information about the part that was added.</param>
|
||||
void BodyPartAdded(BodyPartAddedEventArgs args);
|
||||
}
|
||||
|
||||
@@ -19,8 +25,14 @@ namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
Slot = slot;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The part that was added.
|
||||
/// </summary>
|
||||
public IBodyPart Part { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The slot that <see cref="Part"/> was added to.
|
||||
/// </summary>
|
||||
public string Slot { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
{
|
||||
/// <summary>
|
||||
/// 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="IBody"/> holds many
|
||||
/// <see cref="IBodyPart"/>s, each of which have an upward reference to it).
|
||||
/// Defines a component as being capable of containing parts.
|
||||
/// Used during surgery.
|
||||
/// </summary>
|
||||
// TODO BODY Remove
|
||||
public interface IBodyPartContainer
|
||||
|
||||
@@ -8,6 +8,11 @@ namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
/// </summary>
|
||||
public interface IBodyPartRemoved
|
||||
{
|
||||
/// <summary>
|
||||
/// Called when a <see cref="IBodyPart"/> is removed from the
|
||||
/// entity owning this component.
|
||||
/// </summary>
|
||||
/// <param name="args">Information about the part that was removed.</param>
|
||||
void BodyPartRemoved(BodyPartRemovedEventArgs args);
|
||||
}
|
||||
|
||||
@@ -19,8 +24,14 @@ namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
Slot = slot;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The part that was removed.
|
||||
/// </summary>
|
||||
public IBodyPart Part { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The slot that <see cref="Part"/> was removed from.
|
||||
/// </summary>
|
||||
public string Slot { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,9 @@ namespace Content.Shared.GameObjects.Components.Body.Part.Property
|
||||
{
|
||||
/// <summary>
|
||||
/// Property attachable to a <see cref="IBodyPart"/>.
|
||||
/// For example, this is used to define the speed capabilities of a
|
||||
/// leg. The movement system will look for a LegProperty on all BodyParts.
|
||||
/// For example, this is used to define the speed capabilities of a leg.
|
||||
/// The movement system will look for a <see cref="LegComponent"/> on all
|
||||
/// <see cref="IBodyPart"/>.
|
||||
/// </summary>
|
||||
public abstract class BodyPartPropertyComponent : Component, IBodyPartProperty
|
||||
{
|
||||
|
||||
@@ -3,13 +3,16 @@ using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Body.Part.Property
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the length of a <see cref="IBodyPart"/>.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public class ExtensionComponent : BodyPartPropertyComponent
|
||||
{
|
||||
public override string Name => "Extension";
|
||||
|
||||
/// <summary>
|
||||
/// Current distance (in tiles).
|
||||
/// Current distance in tiles.
|
||||
/// </summary>
|
||||
public float Distance { get; set; }
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
namespace Content.Shared.GameObjects.Components.Body.Part.Property
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines an entity as being able to pick up items
|
||||
/// Defines a <see cref="IBodyPart"/> as being able to grasp around an entity,
|
||||
/// for example picking up an item.
|
||||
/// </summary>
|
||||
// TODO BODY Implement
|
||||
[RegisterComponent]
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Body.Part.Property
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a property for a <see cref="IBodyPart"/>.
|
||||
/// </summary>
|
||||
public interface IBodyPartProperty : IComponent
|
||||
{
|
||||
bool Active { get; set; }
|
||||
|
||||
@@ -3,13 +3,16 @@ using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Body.Part.Property
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the speed at which a <see cref="IBodyPart"/> can move.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public class LegComponent : BodyPartPropertyComponent
|
||||
{
|
||||
public override string Name => "Leg";
|
||||
|
||||
/// <summary>
|
||||
/// Speed (in tiles per second).
|
||||
/// Speed in tiles per second.
|
||||
/// </summary>
|
||||
public float Speed { get; set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user