Fix mechanism events not being called properly, add test (#2279)
* Add mechanism events when added/removed to/from body/parts * Change old usages * Add TODO * Remove BodyExtensions and IHasBody * Remove unnecessary extensions and fix wrong event call in mechanism behavior component * Complete test and fix event calls
This commit is contained in:
@@ -13,6 +13,25 @@ namespace Content.Shared.GameObjects.Components.Body.Behavior
|
||||
|
||||
public IMechanism? Mechanism => Owner.GetComponentOrNull<IMechanism>();
|
||||
|
||||
protected override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
|
||||
if (Part == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Body == null)
|
||||
{
|
||||
AddedToPart();
|
||||
}
|
||||
else
|
||||
{
|
||||
AddedToPartInBody();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void Update(float frameTime);
|
||||
|
||||
public void AddedToBody()
|
||||
@@ -37,7 +56,7 @@ namespace Content.Shared.GameObjects.Components.Body.Behavior
|
||||
|
||||
public void AddedToPartInBody()
|
||||
{
|
||||
OnAddedToPart();
|
||||
OnAddedToPartInBody();
|
||||
}
|
||||
|
||||
public void RemovedFromPartInBody(IBody? oldBody, IBodyPart? oldPart)
|
||||
|
||||
Reference in New Issue
Block a user