Add mechanism events when being added/removed to/from body/parts (#2271)

* Add mechanism events when added/removed to/from body/parts

* Change old usages

* Add TODO
This commit is contained in:
DrSmugleaf
2020-10-16 14:42:33 +02:00
committed by GitHub
parent 435fb2630e
commit bd30a73026
8 changed files with 257 additions and 79 deletions

View File

@@ -52,20 +52,55 @@ namespace Content.Shared.GameObjects.Components.Body.Mechanism
/// </summary>
BodyPartCompatibility Compatibility { get; set; }
// TODO BODY Turn these into event listeners so they dont need to be exposed
/// <summary>
/// Called when the part housing this mechanism is added to a body.
/// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY PART CODE!
/// Called when the containing <see cref="IBodyPart"/> is attached to a
/// <see cref="IBody"/>.
/// For instance, attaching a head with a brain inside to a body.
/// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE!
/// </summary>
/// <param name="old">The previous body, if any.</param>
/// <param name="current">The new body.</param>
void OnBodyAdd(IBody? old, IBody current);
void AddedToBody();
/// <summary>
/// Called when the part housing this mechanism is removed from
/// a body.
/// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY PART CODE!
/// Called when the parent <see cref="IMechanism"/> is
/// added into a <see cref="IBodyPart"/> that is not attached to a
/// <see cref="IBody"/>.
/// For instance, adding a brain to a dismembered head.
/// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE!
/// </summary>
/// <param name="old">The old body.</param>
void OnBodyRemove(IBody old);
void AddedToPart();
/// <summary>
/// Called when the parent <see cref="IBodyPart"/> is removed from a
/// <see cref="IBody"/>.
/// For instance, removing a head with a brain inside from a body.
/// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE!
/// </summary>
void RemovedFromBody(IBody old);
/// <summary>
/// Called when the parent <see cref="IMechanism"/> is
/// removed from a <see cref="IBodyPart"/> that is not attached to a
/// <see cref="IBody"/>.
/// For instance, removing a brain from a dismembered head.
/// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE!
/// </summary>
void RemovedFromPart(IBodyPart old);
/// <summary>
/// Called when the parent <see cref="IMechanism"/> is added to a
/// <see cref="IBodyPart"/> that is attached to a <see cref="IBody"/>.
/// For instance, adding a brain to a head that is attached to a body.
/// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE!
/// </summary>
void AddedToPartInBody();
/// <summary>
/// Called when the parent <see cref="IMechanism"/> is removed from a
/// <see cref="IBodyPart"/> that is attached to a <see cref="IBody"/>.
/// For instance, removing a brain from a head that is attached to a body.
/// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE!
/// </summary>
void RemovedFromPartInBody(IBody? oldBody, IBodyPart? oldPart);
}
}