#nullable enable using Content.Shared.GameObjects.Components.Body.Mechanism; using Content.Shared.GameObjects.Components.Body.Part; using Robust.Shared.GameObjects; namespace Content.Shared.GameObjects.Components.Body.Behavior { public abstract class MechanismBehaviorComponent : Component, IMechanismBehavior { public IBody? Body => Part?.Body; public IBodyPart? Part => Mechanism?.Part; public IMechanism? Mechanism => Owner.GetComponentOrNull(); public abstract void Update(float frameTime); /// /// Called when the containing is attached to a /// . /// For instance, attaching a head to a body will call this on the brain inside. /// public void AddedToBody() { OnAddedToBody(); } /// /// Called when the parent is /// added into a . /// For instance, putting a brain into an empty head. /// public void AddedToPart() { OnAddedToPart(); } /// /// Called when the containing is removed from a /// . /// For instance, cutting off ones head will call this on the brain inside. /// public void RemovedFromBody(IBody old) { OnRemovedFromBody(old); } /// /// Called when the parent is /// removed from a . /// For instance, taking a brain out of ones head. /// public void RemovedFromPart(IBodyPart old) { OnRemovedFromPart(old); } /// /// Called when the containing is attached to a /// . /// For instance, attaching a head to a body will call this on the brain inside. /// protected virtual void OnAddedToBody() { } /// /// Called when the parent is /// added into a . /// For instance, putting a brain into an empty head. /// protected virtual void OnAddedToPart() { } /// /// Called when the containing is removed from a /// . /// For instance, cutting off ones head will call this on the brain inside. /// protected virtual void OnRemovedFromBody(IBody old) { } /// /// Called when the parent is /// removed from a . /// For instance, taking a brain out of ones head. /// protected virtual void OnRemovedFromPart(IBodyPart old) { } } }