Adds a lot more move effects
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Static;
|
||||
|
||||
namespace PkmnLib.Dynamic.ScriptHandling;
|
||||
|
||||
@@ -42,4 +44,27 @@ public static class ScriptExecution
|
||||
}
|
||||
}
|
||||
|
||||
public static void RunItemScript(this IItem item, ScriptResolver scriptResolver, IPokemon? target)
|
||||
{
|
||||
if (!scriptResolver.TryResolveBattleItemScript(item, out var itemScript))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!itemScript.IsItemUsable)
|
||||
return;
|
||||
|
||||
itemScript.OnInitialize(item.BattleEffect!.Parameters);
|
||||
var requiresTarget = itemScript.RequiresTarget;
|
||||
if (requiresTarget)
|
||||
{
|
||||
if (target == null)
|
||||
throw new ArgumentNullException(nameof(target), "Item script requires a target.");
|
||||
itemScript.OnUseWithTarget(target);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemScript.OnUse();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public interface IScriptSet : IEnumerable<ScriptContainer>
|
||||
/// Gets a script from the set using its type.
|
||||
/// </summary>
|
||||
T? Get<T>() where T : Script;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Removes a script from the set using its unique name.
|
||||
/// </summary>
|
||||
@@ -43,6 +43,11 @@ public interface IScriptSet : IEnumerable<ScriptContainer>
|
||||
/// </summary>
|
||||
void Clear();
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the set has a script with the given type.
|
||||
/// </summary>
|
||||
bool Contains<T>() where T : Script => Contains(ScriptUtils.ResolveName<T>());
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the set has a script with the given name.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user