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:
@@ -15,5 +15,55 @@ namespace Content.Shared.GameObjects.Components.Body.Behavior
|
||||
IMechanism? Mechanism { get; }
|
||||
|
||||
void Update(float frameTime);
|
||||
|
||||
/// <summary>
|
||||
/// 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>
|
||||
void AddedToBody();
|
||||
|
||||
/// <summary>
|
||||
/// 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>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,72 +15,46 @@ namespace Content.Shared.GameObjects.Components.Body.Behavior
|
||||
|
||||
public abstract void Update(float frameTime);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the containing <see cref="IBodyPart"/> is attached to a
|
||||
/// <see cref="IBody"/>.
|
||||
/// For instance, attaching a head to a body will call this on the brain inside.
|
||||
/// </summary>
|
||||
public void AddedToBody()
|
||||
{
|
||||
OnAddedToBody();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the parent <see cref="Mechanism"/> is
|
||||
/// added into a <see cref="IBodyPart"/>.
|
||||
/// For instance, putting a brain into an empty head.
|
||||
/// </summary>
|
||||
public void AddedToPart()
|
||||
{
|
||||
OnAddedToPart();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the containing <see cref="IBodyPart"/> is removed from a
|
||||
/// <see cref="IBody"/>.
|
||||
/// For instance, cutting off ones head will call this on the brain inside.
|
||||
/// </summary>
|
||||
public void RemovedFromBody(IBody old)
|
||||
{
|
||||
OnRemovedFromBody(old);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the parent <see cref="Mechanism"/> is
|
||||
/// removed from a <see cref="IBodyPart"/>.
|
||||
/// For instance, taking a brain out of ones head.
|
||||
/// </summary>
|
||||
public void RemovedFromPart(IBodyPart old)
|
||||
{
|
||||
OnRemovedFromPart(old);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the containing <see cref="IBodyPart"/> is attached to a
|
||||
/// <see cref="IBody"/>.
|
||||
/// For instance, attaching a head to a body will call this on the brain inside.
|
||||
/// </summary>
|
||||
public void AddedToPartInBody()
|
||||
{
|
||||
OnAddedToPart();
|
||||
}
|
||||
|
||||
public void RemovedFromPartInBody(IBody? oldBody, IBodyPart? oldPart)
|
||||
{
|
||||
OnRemovedFromPartInBody(oldBody, oldPart);
|
||||
}
|
||||
|
||||
protected virtual void OnAddedToBody() { }
|
||||
|
||||
/// <summary>
|
||||
/// Called when the parent <see cref="Mechanism"/> is
|
||||
/// added into a <see cref="IBodyPart"/>.
|
||||
/// For instance, putting a brain into an empty head.
|
||||
/// </summary>
|
||||
protected virtual void OnAddedToPart() { }
|
||||
|
||||
/// <summary>
|
||||
/// Called when the containing <see cref="IBodyPart"/> is removed from a
|
||||
/// <see cref="IBody"/>.
|
||||
/// For instance, cutting off ones head will call this on the brain inside.
|
||||
/// </summary>
|
||||
protected virtual void OnRemovedFromBody(IBody old) { }
|
||||
|
||||
/// <summary>
|
||||
/// Called when the parent <see cref="Mechanism"/> is
|
||||
/// removed from a <see cref="IBodyPart"/>.
|
||||
/// For instance, taking a brain out of ones head.
|
||||
/// </summary>
|
||||
protected virtual void OnRemovedFromPart(IBodyPart old) { }
|
||||
|
||||
protected virtual void OnAddedToPartInBody() { }
|
||||
|
||||
protected virtual void OnRemovedFromPartInBody(IBody? oldBody, IBodyPart? oldPart) { }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user