Items can be used on Pokemon outside of battle, and we want the user of the library to be able to check for what changed. This allows for example a heal event to be sent back to the user of the library after using an item.
This commit is contained in:
7 files changed
+21
-17
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using PkmnLib.Dynamic.Events;
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Static;
|
||||
|
||||
@@ -95,7 +96,8 @@ public static class ScriptExecution
|
||||
/// <summary>
|
||||
/// Executes a script on an item.
|
||||
/// </summary>
|
||||
public static void RunItemScript(this IItem item, ScriptResolver scriptResolver, IPokemon? target)
|
||||
public static void RunItemScript(this IItem item, ScriptResolver scriptResolver, IPokemon? target,
|
||||
EventHook eventHook)
|
||||
{
|
||||
if (!scriptResolver.TryResolveBattleItemScript(item, out var itemScript))
|
||||
{
|
||||
@@ -110,11 +112,11 @@ public static class ScriptExecution
|
||||
{
|
||||
if (target == null)
|
||||
throw new ArgumentNullException(nameof(target), "Item script requires a target.");
|
||||
itemScript.OnUseWithTarget(target);
|
||||
itemScript.OnUseWithTarget(target, eventHook);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemScript.OnUse();
|
||||
itemScript.OnUse(eventHook);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user