prevent magnet deconstruction when active (#19849)
* raise ToolUseAttemptEvent on target as well as tool * prevent using tools on magnet when active --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -180,16 +180,27 @@ public abstract partial class SharedToolSystem : EntitySystem
|
||||
if (!Resolve(tool, ref toolComponent))
|
||||
return false;
|
||||
|
||||
// check if the tool can do what's required
|
||||
if (!toolComponent.Qualities.ContainsAll(toolQualitiesNeeded))
|
||||
return false;
|
||||
|
||||
// check if the user allows using the tool
|
||||
var ev = new ToolUserAttemptUseEvent(target);
|
||||
RaiseLocalEvent(user, ref ev);
|
||||
if (ev.Cancelled)
|
||||
return false;
|
||||
|
||||
if (!toolComponent.Qualities.ContainsAll(toolQualitiesNeeded))
|
||||
// check if the tool allows being used
|
||||
var beforeAttempt = new ToolUseAttemptEvent(user);
|
||||
RaiseLocalEvent(tool, beforeAttempt);
|
||||
if (beforeAttempt.Cancelled)
|
||||
return false;
|
||||
|
||||
var beforeAttempt = new ToolUseAttemptEvent(user);
|
||||
RaiseLocalEvent(tool, beforeAttempt, false);
|
||||
// check if the target allows using the tool
|
||||
if (target != null && target != tool)
|
||||
{
|
||||
RaiseLocalEvent(target.Value, beforeAttempt);
|
||||
}
|
||||
|
||||
return !beforeAttempt.Cancelled;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user