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:
@@ -169,7 +169,7 @@ namespace Content.Server.GameObjects.Components.Body
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.AttachedEntity.TryGetBody(out var body))
|
||||
if (!player.AttachedEntity.TryGetComponent(out IBody? body))
|
||||
{
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
|
||||
@@ -216,7 +216,7 @@ namespace Content.Server.GameObjects.Components.Body
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.AttachedEntity.TryGetBody(out var body))
|
||||
if (!player.AttachedEntity.TryGetComponent(out IBody? body))
|
||||
{
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Content.Server.GameObjects.Components.Body
|
||||
PerformerCache = null;
|
||||
BodyCache = null;
|
||||
|
||||
if (eventArgs.Target.TryGetBody(out var body))
|
||||
if (eventArgs.Target.TryGetComponent(out IBody? body))
|
||||
{
|
||||
SendBodyPartListToUser(eventArgs, body);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Content.Server.GameObjects.Components.Body.Part
|
||||
_surgeonCache = null;
|
||||
_owningBodyCache = null;
|
||||
|
||||
if (eventArgs.Target.TryGetBody(out var body))
|
||||
if (eventArgs.Target.TryGetComponent(out IBody? body))
|
||||
{
|
||||
SendSlots(eventArgs, body);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Content.Server.GameObjects.Components.Body
|
||||
_callbackCache = null;
|
||||
|
||||
// Attempt surgery on a body by sending a list of operable parts for the client to choose from
|
||||
if (eventArgs.Target.TryGetBody(out var body))
|
||||
if (eventArgs.Target.TryGetComponent(out IBody? body))
|
||||
{
|
||||
// Create dictionary to send to client (text to be shown : data sent back if selected)
|
||||
var toSend = new Dictionary<string, int>();
|
||||
|
||||
Reference in New Issue
Block a user