diff --git a/Content.Server/Tools/ToolSystem.cs b/Content.Server/Tools/ToolSystem.cs
index 06bdcbaa42..6d94e3c7fb 100644
--- a/Content.Server/Tools/ToolSystem.cs
+++ b/Content.Server/Tools/ToolSystem.cs
@@ -40,7 +40,10 @@ namespace Content.Server.Tools
private void OnDoAfterComplete(ToolDoAfterComplete ev)
{
// Actually finish the tool use! Depending on whether that succeeds or not, either event will be broadcast.
- RaiseLocalEvent(ToolFinishUse(ev.Uid, ev.UserUid, ev.Fuel) ? ev.CompletedEvent : ev.CancelledEvent);
+ if(ToolFinishUse(ev.Uid, ev.UserUid, ev.Fuel))
+ RaiseLocalEvent(ev.CompletedEvent);
+ else if(ev.CancelledEvent != null)
+ RaiseLocalEvent(ev.CancelledEvent);
}
private void OnDoAfterCancelled(ToolDoAfterCancelled ev)
@@ -83,7 +86,8 @@ namespace Content.Server.Tools
/// to see whether using the tool succeeded or not. If the is zero,
/// this simply returns whether using the tool succeeded or not.
public bool UseTool(EntityUid tool, EntityUid user, EntityUid? target, float fuel,
- float doAfterDelay, IEnumerable toolQualitiesNeeded, object doAfterCompleteEvent, object doAfterCancelledEvent,
+ float doAfterDelay, IEnumerable toolQualitiesNeeded,
+ object? doAfterCompleteEvent = null, object? doAfterCancelledEvent = null,
Func? doAfterCheck = null, ToolComponent? toolComponent = null)
{
// No logging here, after all that'd mean the caller would need to check if the component is there or not.
@@ -103,8 +107,8 @@ namespace Content.Server.Tools
BreakOnTargetMove = true,
BreakOnUserMove = true,
NeedHand = true,
- BroadcastFinishedEvent = new ToolDoAfterComplete(doAfterCompleteEvent, doAfterCancelledEvent, tool, user, fuel),
- BroadcastCancelledEvent = new ToolDoAfterCancelled(doAfterCancelledEvent),
+ BroadcastFinishedEvent = doAfterCompleteEvent != null ? new ToolDoAfterComplete(doAfterCompleteEvent, doAfterCancelledEvent, tool, user, fuel) : null,
+ BroadcastCancelledEvent = doAfterCancelledEvent != null ? new ToolDoAfterCancelled(doAfterCancelledEvent) : null,
};
_doAfterSystem.DoAfter(doAfterArgs);
@@ -231,12 +235,12 @@ namespace Content.Server.Tools
private class ToolDoAfterComplete : EntityEventArgs
{
public readonly object CompletedEvent;
- public readonly object CancelledEvent;
+ public readonly object? CancelledEvent;
public readonly EntityUid Uid;
public readonly EntityUid UserUid;
public readonly float Fuel;
- public ToolDoAfterComplete(object completedEvent, object cancelledEvent, EntityUid uid, EntityUid userUid, float fuel)
+ public ToolDoAfterComplete(object completedEvent, object? cancelledEvent, EntityUid uid, EntityUid userUid, float fuel)
{
CompletedEvent = completedEvent;
Uid = uid;