mech bug fixes (#13155)

* mech bug fixes

* struct events

* fug
This commit is contained in:
Nemanja
2022-12-24 16:33:08 -05:00
committed by GitHub
parent 455939afc1
commit 56bdfad912
5 changed files with 46 additions and 11 deletions

View File

@@ -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.