@@ -119,6 +119,11 @@ namespace Content.Server.Tools
|
||||
if (!Resolve(tool, ref toolComponent, false))
|
||||
return false;
|
||||
|
||||
var ev = new ToolUserAttemptUseEvent(user, target);
|
||||
RaiseLocalEvent(user, ref ev);
|
||||
if (ev.Cancelled)
|
||||
return false;
|
||||
|
||||
if (!ToolStartUse(tool, user, fuel, toolQualitiesNeeded, toolComponent))
|
||||
return false;
|
||||
|
||||
@@ -173,6 +178,11 @@ namespace Content.Server.Tools
|
||||
if (!Resolve(tool, ref toolComponent, false))
|
||||
return false;
|
||||
|
||||
var ev = new ToolUserAttemptUseEvent(user, target);
|
||||
RaiseLocalEvent(user, ref ev);
|
||||
if (ev.Cancelled)
|
||||
return false;
|
||||
|
||||
if (!ToolStartUse(tool, user, fuel, toolQualitiesNeeded, toolComponent))
|
||||
return false;
|
||||
|
||||
@@ -306,6 +316,23 @@ namespace Content.Server.Tools
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event raised on the user of a tool to see if they can actually use it.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public struct ToolUserAttemptUseEvent
|
||||
{
|
||||
public EntityUid User;
|
||||
public EntityUid? Target;
|
||||
public bool Cancelled = false;
|
||||
|
||||
public ToolUserAttemptUseEvent(EntityUid user, EntityUid? target)
|
||||
{
|
||||
User = user;
|
||||
Target = target;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempt event called *after* any do afters to see if the tool usage should succeed or not.
|
||||
/// You can use this event to consume any fuel needed.
|
||||
|
||||
Reference in New Issue
Block a user