Add arguments to part and mechanism event methods (#2293)
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
#nullable enable
|
||||
using Content.Shared.GameObjects.Components.Body.Mechanism;
|
||||
using Content.Shared.GameObjects.Components.Body.Part;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Body.Mechanism
|
||||
@@ -9,26 +7,5 @@ namespace Content.Client.GameObjects.Components.Body.Mechanism
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedMechanismComponent))]
|
||||
[ComponentReference(typeof(IMechanism))]
|
||||
public class MechanismComponent : SharedMechanismComponent
|
||||
{
|
||||
protected override void OnAddedToPart()
|
||||
{
|
||||
base.OnAddedToPart();
|
||||
|
||||
if (Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
{
|
||||
sprite.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRemovedFromPart(IBodyPart old)
|
||||
{
|
||||
base.OnRemovedFromPart(old);
|
||||
|
||||
if (Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
{
|
||||
sprite.Visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class MechanismComponent : SharedMechanismComponent { }
|
||||
}
|
||||
|
||||
@@ -35,16 +35,6 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
|
||||
public override void Update(float frameTime) { }
|
||||
|
||||
public bool AllAdded()
|
||||
{
|
||||
return WasAddedToBody && WasAddedToPart && WasAddedToPartInBody;
|
||||
}
|
||||
|
||||
public bool AllRemoved()
|
||||
{
|
||||
return WasRemovedFromBody && WasRemovedFromPart && WasRemovedFromPartInBody;
|
||||
}
|
||||
|
||||
public bool NoAdded()
|
||||
{
|
||||
return !WasAddedToBody && !WasAddedToPart && !WasAddedToPartInBody;
|
||||
@@ -75,23 +65,23 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
ResetRemoved();
|
||||
}
|
||||
|
||||
protected override void OnAddedToBody()
|
||||
protected override void OnAddedToBody(IBody body)
|
||||
{
|
||||
base.OnAddedToBody();
|
||||
base.OnAddedToBody(body);
|
||||
|
||||
WasAddedToBody = true;
|
||||
}
|
||||
|
||||
protected override void OnAddedToPart()
|
||||
protected override void OnAddedToPart(IBodyPart part)
|
||||
{
|
||||
base.OnAddedToPart();
|
||||
base.OnAddedToPart(part);
|
||||
|
||||
WasAddedToPart = true;
|
||||
}
|
||||
|
||||
protected override void OnAddedToPartInBody()
|
||||
protected override void OnAddedToPartInBody(IBody body, IBodyPart part)
|
||||
{
|
||||
base.OnAddedToPartInBody();
|
||||
base.OnAddedToPartInBody(body, part);
|
||||
|
||||
WasAddedToPartInBody = true;
|
||||
}
|
||||
@@ -110,7 +100,7 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
WasRemovedFromPart = true;
|
||||
}
|
||||
|
||||
protected override void OnRemovedFromPartInBody(IBody? oldBody, IBodyPart? oldPart)
|
||||
protected override void OnRemovedFromPartInBody(IBody oldBody, IBodyPart oldPart)
|
||||
{
|
||||
base.OnRemovedFromPartInBody(oldBody, oldPart);
|
||||
|
||||
|
||||
@@ -17,25 +17,25 @@ namespace Content.Server.GameObjects.Components.Body.Behavior
|
||||
{
|
||||
public override string Name => "Brain";
|
||||
|
||||
protected override void OnAddedToBody()
|
||||
protected override void OnAddedToBody(IBody body)
|
||||
{
|
||||
base.OnAddedToBody();
|
||||
base.OnAddedToBody(body);
|
||||
|
||||
HandleMind(Body!.Owner, Owner);
|
||||
HandleMind(body.Owner, Owner);
|
||||
}
|
||||
|
||||
protected override void OnAddedToPart()
|
||||
protected override void OnAddedToPart(IBodyPart part)
|
||||
{
|
||||
base.OnAddedToPart();
|
||||
base.OnAddedToPart(part);
|
||||
|
||||
HandleMind(Part!.Owner, Owner);
|
||||
HandleMind(part.Owner, Owner);
|
||||
}
|
||||
|
||||
protected override void OnAddedToPartInBody()
|
||||
protected override void OnAddedToPartInBody(IBody body, IBodyPart part)
|
||||
{
|
||||
base.OnAddedToPartInBody();
|
||||
base.OnAddedToPartInBody(body, part);
|
||||
|
||||
HandleMind(Body!.Owner, Owner);
|
||||
HandleMind(body.Owner, Owner);
|
||||
}
|
||||
|
||||
protected override void OnRemovedFromBody(IBody old)
|
||||
@@ -52,16 +52,16 @@ namespace Content.Server.GameObjects.Components.Body.Behavior
|
||||
HandleMind(Owner, old.Owner);
|
||||
}
|
||||
|
||||
protected override void OnRemovedFromPartInBody(IBody? oldBody, IBodyPart? oldPart)
|
||||
protected override void OnRemovedFromPartInBody(IBody oldBody, IBodyPart oldPart)
|
||||
{
|
||||
base.OnRemovedFromPartInBody(oldBody, oldPart);
|
||||
|
||||
HandleMind(oldBody!.Owner, Owner);
|
||||
HandleMind(oldBody.Owner, Owner);
|
||||
}
|
||||
|
||||
private void HandleMind(IEntity newEntity, IEntity oldEntity)
|
||||
{
|
||||
var newMind = newEntity.EnsureComponent<MindComponent>();
|
||||
newEntity.EnsureComponent<MindComponent>();
|
||||
var oldMind = oldEntity.EnsureComponent<MindComponent>();
|
||||
|
||||
oldMind.Mind?.TransferTo(newEntity);
|
||||
|
||||
@@ -157,25 +157,5 @@ namespace Content.Server.GameObjects.Components.Body
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnAddedToPart()
|
||||
{
|
||||
base.OnAddedToPart();
|
||||
|
||||
if (Owner.TryGetComponent(out SpriteComponent? sprite))
|
||||
{
|
||||
sprite.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRemovedFromPart(IBodyPart old)
|
||||
{
|
||||
base.OnRemovedFromPart(old);
|
||||
|
||||
if (Owner.TryGetComponent(out SpriteComponent? sprite))
|
||||
{
|
||||
sprite.Visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,10 @@ namespace Content.Shared.GameObjects.Components.Body.Behavior
|
||||
/// 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();
|
||||
/// <param name="body">
|
||||
/// The body that the containing <see cref="IMechanism"/> was added to.
|
||||
/// </param>
|
||||
void AddedToBody(IBody body);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the parent <see cref="IMechanism"/> is
|
||||
@@ -32,7 +35,10 @@ namespace Content.Shared.GameObjects.Components.Body.Behavior
|
||||
/// For instance, adding a brain to a dismembered head.
|
||||
/// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE!
|
||||
/// </summary>
|
||||
void AddedToPart();
|
||||
/// <param name="part">
|
||||
/// The part that the containing <see cref="IMechanism"/> was added to.
|
||||
/// </param>
|
||||
void AddedToPart(IBodyPart part);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the parent <see cref="IMechanism"/> is added to a
|
||||
@@ -40,7 +46,13 @@ namespace Content.Shared.GameObjects.Components.Body.Behavior
|
||||
/// 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();
|
||||
/// <param name="body">
|
||||
/// The body that the containing <see cref="IMechanism"/> was added to.
|
||||
/// </param>
|
||||
/// <param name="part">
|
||||
/// The part that the containing <see cref="IMechanism"/> was added to.
|
||||
/// </param>
|
||||
void AddedToPartInBody(IBody body, IBodyPart part);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the parent <see cref="IBodyPart"/> is removed from a
|
||||
@@ -48,6 +60,9 @@ namespace Content.Shared.GameObjects.Components.Body.Behavior
|
||||
/// For instance, removing a head with a brain inside from a body.
|
||||
/// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE!
|
||||
/// </summary>
|
||||
/// <param name="old">
|
||||
/// The body that the containing <see cref="IMechanism"/> was removed from.
|
||||
/// </param>
|
||||
void RemovedFromBody(IBody old);
|
||||
|
||||
/// <summary>
|
||||
@@ -57,6 +72,9 @@ namespace Content.Shared.GameObjects.Components.Body.Behavior
|
||||
/// For instance, removing a brain from a dismembered head.
|
||||
/// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE!
|
||||
/// </summary>
|
||||
/// <param name="old">
|
||||
/// The part that the containing <see cref="IMechanism"/> was removed from.
|
||||
/// </param>
|
||||
void RemovedFromPart(IBodyPart old);
|
||||
|
||||
/// <summary>
|
||||
@@ -65,6 +83,12 @@ namespace Content.Shared.GameObjects.Components.Body.Behavior
|
||||
/// 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);
|
||||
/// <param name="oldBody">
|
||||
/// The body that the containing <see cref="IMechanism"/> was removed from.
|
||||
/// </param>
|
||||
/// <param name="oldPart">
|
||||
/// The part that the containing <see cref="IMechanism"/> was removed from.
|
||||
/// </param>
|
||||
void RemovedFromPartInBody(IBody oldBody, IBodyPart oldPart);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Content.Shared.GameObjects.Components.Body.Mechanism;
|
||||
using Content.Shared.GameObjects.Components.Body.Part;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Body.Behavior
|
||||
{
|
||||
@@ -24,56 +25,78 @@ namespace Content.Shared.GameObjects.Components.Body.Behavior
|
||||
|
||||
if (Body == null)
|
||||
{
|
||||
AddedToPart();
|
||||
AddedToPart(Part);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddedToPartInBody();
|
||||
AddedToPartInBody(Body, Part);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void Update(float frameTime);
|
||||
|
||||
public void AddedToBody()
|
||||
public void AddedToBody(IBody body)
|
||||
{
|
||||
OnAddedToBody();
|
||||
DebugTools.AssertNotNull(Body);
|
||||
DebugTools.AssertNotNull(body);
|
||||
|
||||
OnAddedToBody(body);
|
||||
}
|
||||
|
||||
public void AddedToPart()
|
||||
public void AddedToPart(IBodyPart part)
|
||||
{
|
||||
OnAddedToPart();
|
||||
DebugTools.AssertNotNull(Part);
|
||||
DebugTools.AssertNotNull(part);
|
||||
|
||||
OnAddedToPart(part);
|
||||
}
|
||||
|
||||
public void AddedToPartInBody(IBody body, IBodyPart part)
|
||||
{
|
||||
DebugTools.AssertNotNull(Body);
|
||||
DebugTools.AssertNotNull(body);
|
||||
DebugTools.AssertNotNull(Part);
|
||||
DebugTools.AssertNotNull(part);
|
||||
|
||||
OnAddedToPartInBody(body, part);
|
||||
}
|
||||
|
||||
public void RemovedFromBody(IBody old)
|
||||
{
|
||||
DebugTools.AssertNull(Body);
|
||||
DebugTools.AssertNotNull(old);
|
||||
|
||||
OnRemovedFromBody(old);
|
||||
}
|
||||
|
||||
public void RemovedFromPart(IBodyPart old)
|
||||
{
|
||||
DebugTools.AssertNull(Part);
|
||||
DebugTools.AssertNotNull(old);
|
||||
|
||||
OnRemovedFromPart(old);
|
||||
}
|
||||
|
||||
public void AddedToPartInBody()
|
||||
public void RemovedFromPartInBody(IBody oldBody, IBodyPart oldPart)
|
||||
{
|
||||
OnAddedToPartInBody();
|
||||
}
|
||||
DebugTools.AssertNull(Body);
|
||||
DebugTools.AssertNull(Part);
|
||||
DebugTools.AssertNotNull(oldBody);
|
||||
DebugTools.AssertNotNull(oldPart);
|
||||
|
||||
public void RemovedFromPartInBody(IBody? oldBody, IBodyPart? oldPart)
|
||||
{
|
||||
OnRemovedFromPartInBody(oldBody, oldPart);
|
||||
}
|
||||
|
||||
protected virtual void OnAddedToBody() { }
|
||||
protected virtual void OnAddedToBody(IBody body) { }
|
||||
|
||||
protected virtual void OnAddedToPart() { }
|
||||
protected virtual void OnAddedToPart(IBodyPart part) { }
|
||||
|
||||
protected virtual void OnAddedToPartInBody(IBody body, IBodyPart part) { }
|
||||
|
||||
protected virtual void OnRemovedFromBody(IBody old) { }
|
||||
|
||||
protected virtual void OnRemovedFromPart(IBodyPart old) { }
|
||||
|
||||
protected virtual void OnAddedToPartInBody() { }
|
||||
|
||||
protected virtual void OnRemovedFromPartInBody(IBody? oldBody, IBodyPart? oldPart) { }
|
||||
protected virtual void OnRemovedFromPartInBody(IBody oldBody, IBodyPart oldPart) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,10 @@ namespace Content.Shared.GameObjects.Components.Body.Mechanism
|
||||
/// 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();
|
||||
/// <param name="body">
|
||||
/// The body that this <see cref="IMechanism"/> was added to.
|
||||
/// </param>
|
||||
void AddedToBody(IBody body);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the parent <see cref="IMechanism"/> is
|
||||
@@ -71,7 +74,10 @@ namespace Content.Shared.GameObjects.Components.Body.Mechanism
|
||||
/// For instance, adding a brain to a dismembered head.
|
||||
/// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE!
|
||||
/// </summary>
|
||||
void AddedToPart();
|
||||
/// <param name="part">
|
||||
/// The part that this <see cref="IMechanism"/> was added to.
|
||||
/// </param>
|
||||
void AddedToPart(IBodyPart part);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the parent <see cref="IMechanism"/> is added to a
|
||||
@@ -79,7 +85,13 @@ namespace Content.Shared.GameObjects.Components.Body.Mechanism
|
||||
/// 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();
|
||||
/// <param name="body">
|
||||
/// The body that this <see cref="IMechanism"/> was added to.
|
||||
/// </param>
|
||||
/// <param name="part">
|
||||
/// The part that this <see cref="IMechanism"/> was added to.
|
||||
/// </param>
|
||||
void AddedToPartInBody(IBody body, IBodyPart part);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the parent <see cref="IBodyPart"/> is removed from a
|
||||
@@ -87,6 +99,9 @@ namespace Content.Shared.GameObjects.Components.Body.Mechanism
|
||||
/// For instance, removing a head with a brain inside from a body.
|
||||
/// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE!
|
||||
/// </summary>
|
||||
/// <param name="old">
|
||||
/// The body that this <see cref="IMechanism"/> was removed from.
|
||||
/// </param>
|
||||
void RemovedFromBody(IBody old);
|
||||
|
||||
/// <summary>
|
||||
@@ -96,6 +111,9 @@ namespace Content.Shared.GameObjects.Components.Body.Mechanism
|
||||
/// For instance, removing a brain from a dismembered head.
|
||||
/// DO NOT CALL THIS DIRECTLY FROM OUTSIDE BODY SYSTEM CODE!
|
||||
/// </summary>
|
||||
/// <param name="old">
|
||||
/// The part that this <see cref="IMechanism"/> was removed from.
|
||||
/// </param>
|
||||
void RemovedFromPart(IBodyPart old);
|
||||
|
||||
/// <summary>
|
||||
@@ -104,6 +122,12 @@ namespace Content.Shared.GameObjects.Components.Body.Mechanism
|
||||
/// 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);
|
||||
/// <param name="oldBody">
|
||||
/// The body that this <see cref="IMechanism"/> was removed from.
|
||||
/// </param>
|
||||
/// <param name="oldPart">
|
||||
/// The part that this <see cref="IMechanism"/> was removed from.
|
||||
/// </param>
|
||||
void RemovedFromPartInBody(IBody oldBody, IBodyPart oldPart);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,9 @@ namespace Content.Shared.GameObjects.Components.Body.Mechanism
|
||||
public override string Name => "Mechanism";
|
||||
|
||||
private IBodyPart? _part;
|
||||
|
||||
protected readonly Dictionary<int, object> OptionsCache = new Dictionary<int, object>();
|
||||
|
||||
protected IBody? BodyCache;
|
||||
|
||||
protected int IdHash;
|
||||
|
||||
protected IEntity? PerformerCache;
|
||||
|
||||
public IBody? Body => Part?.Body;
|
||||
@@ -55,11 +51,11 @@ namespace Content.Shared.GameObjects.Components.Body.Mechanism
|
||||
{
|
||||
if (value.Body == null)
|
||||
{
|
||||
AddedToPart();
|
||||
AddedToPart(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddedToPartInBody();
|
||||
AddedToPartInBody(value.Body, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,20 +100,54 @@ namespace Content.Shared.GameObjects.Components.Body.Mechanism
|
||||
serializer.DataField(this, m => m.Compatibility, "compatibility", BodyPartCompatibility.Universal);
|
||||
}
|
||||
|
||||
public void AddedToBody()
|
||||
public void AddedToBody(IBody body)
|
||||
{
|
||||
DebugTools.AssertNotNull(Body);
|
||||
DebugTools.AssertNotNull(body);
|
||||
|
||||
OnAddedToBody();
|
||||
OnAddedToBody(body);
|
||||
|
||||
foreach (var behavior in Owner.GetAllComponents<IMechanismBehavior>())
|
||||
{
|
||||
behavior.AddedToBody();
|
||||
behavior.AddedToBody(body);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddedToPart(IBodyPart part)
|
||||
{
|
||||
DebugTools.AssertNotNull(Part);
|
||||
DebugTools.AssertNotNull(part);
|
||||
|
||||
Owner.Transform.AttachParent(part.Owner);
|
||||
OnAddedToPart(part);
|
||||
|
||||
foreach (var behavior in Owner.GetAllComponents<IMechanismBehavior>().ToArray())
|
||||
{
|
||||
behavior.AddedToPart(part);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddedToPartInBody(IBody body, IBodyPart part)
|
||||
{
|
||||
DebugTools.AssertNotNull(Body);
|
||||
DebugTools.AssertNotNull(body);
|
||||
DebugTools.AssertNotNull(Part);
|
||||
DebugTools.AssertNotNull(part);
|
||||
|
||||
Owner.Transform.AttachParent(part.Owner);
|
||||
OnAddedToPartInBody(body, part);
|
||||
|
||||
foreach (var behavior in Owner.GetAllComponents<IMechanismBehavior>())
|
||||
{
|
||||
behavior.AddedToPartInBody(body, part);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemovedFromBody(IBody old)
|
||||
{
|
||||
DebugTools.AssertNull(Body);
|
||||
DebugTools.AssertNotNull(old);
|
||||
|
||||
OnRemovedFromBody(old);
|
||||
|
||||
foreach (var behavior in Owner.GetAllComponents<IMechanismBehavior>())
|
||||
@@ -126,35 +156,11 @@ namespace Content.Shared.GameObjects.Components.Body.Mechanism
|
||||
}
|
||||
}
|
||||
|
||||
public void AddedToPart()
|
||||
{
|
||||
DebugTools.AssertNotNull(Part);
|
||||
|
||||
Owner.Transform.AttachParent(Part!.Owner);
|
||||
OnAddedToPart();
|
||||
|
||||
foreach (var behavior in Owner.GetAllComponents<IMechanismBehavior>().ToArray())
|
||||
{
|
||||
behavior.AddedToPart();
|
||||
}
|
||||
}
|
||||
|
||||
public void AddedToPartInBody()
|
||||
{
|
||||
DebugTools.AssertNotNull(Body);
|
||||
DebugTools.AssertNotNull(Part);
|
||||
|
||||
Owner.Transform.AttachParent(Part!.Owner);
|
||||
OnAddedToPartInBody();
|
||||
|
||||
foreach (var behavior in Owner.GetAllComponents<IMechanismBehavior>())
|
||||
{
|
||||
behavior.AddedToPartInBody();
|
||||
}
|
||||
}
|
||||
|
||||
public void RemovedFromPart(IBodyPart old)
|
||||
{
|
||||
DebugTools.AssertNull(Part);
|
||||
DebugTools.AssertNotNull(old);
|
||||
|
||||
Owner.Transform.AttachToGridOrMap();
|
||||
OnRemovedFromPart(old);
|
||||
|
||||
@@ -164,10 +170,15 @@ namespace Content.Shared.GameObjects.Components.Body.Mechanism
|
||||
}
|
||||
}
|
||||
|
||||
public void RemovedFromPartInBody(IBody? oldBody, IBodyPart? oldPart)
|
||||
public void RemovedFromPartInBody(IBody oldBody, IBodyPart oldPart)
|
||||
{
|
||||
DebugTools.AssertNull(Body);
|
||||
DebugTools.AssertNotNull(oldBody);
|
||||
DebugTools.AssertNull(Part);
|
||||
DebugTools.AssertNotNull(oldPart);
|
||||
|
||||
Owner.Transform.AttachToGridOrMap();
|
||||
OnRemovedFromPartInBody();
|
||||
OnRemovedFromPartInBody(oldBody, oldPart);
|
||||
|
||||
foreach (var behavior in Owner.GetAllComponents<IMechanismBehavior>())
|
||||
{
|
||||
@@ -175,16 +186,16 @@ namespace Content.Shared.GameObjects.Components.Body.Mechanism
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnAddedToBody() { }
|
||||
protected virtual void OnAddedToBody(IBody body) { }
|
||||
|
||||
protected virtual void OnAddedToPart(IBodyPart part) { }
|
||||
|
||||
protected virtual void OnAddedToPartInBody(IBody body, IBodyPart part) { }
|
||||
|
||||
protected virtual void OnRemovedFromBody(IBody old) { }
|
||||
|
||||
protected virtual void OnAddedToPart() { }
|
||||
|
||||
protected virtual void OnRemovedFromPart(IBodyPart old) { }
|
||||
|
||||
protected virtual void OnAddedToPartInBody() { }
|
||||
|
||||
protected virtual void OnRemovedFromPartInBody() { }
|
||||
protected virtual void OnRemovedFromPartInBody(IBody oldBody, IBodyPart oldPart) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
|
||||
if (value != null)
|
||||
{
|
||||
AddedToBody();
|
||||
AddedToBody(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -284,14 +284,14 @@ namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
return true;
|
||||
}
|
||||
|
||||
private void AddedToBody()
|
||||
private void AddedToBody(IBody body)
|
||||
{
|
||||
Owner.Transform.AttachParent(Body!.Owner);
|
||||
OnAddedToBody();
|
||||
OnAddedToBody(body);
|
||||
|
||||
foreach (var mechanism in _mechanisms)
|
||||
{
|
||||
mechanism.AddedToBody();
|
||||
mechanism.AddedToBody(body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnAddedToBody() { }
|
||||
protected virtual void OnAddedToBody(IBody body) { }
|
||||
|
||||
protected virtual void OnRemovedFromBody(IBody old) { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user