Add EventHook parameter to item use scripts
All checks were successful
Build / Build (push) Successful in 47s
All checks were successful
Build / Build (push) Successful in 47s
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:
@@ -340,7 +340,8 @@ public interface IPokemon : IScriptSource, IDeepCloneable
|
||||
/// Heals the Pokemon by a specific amount. Unless allow_revive is set to true, this will not
|
||||
/// heal if the Pokemon has 0 health. If the amount healed is 0, this will return false.
|
||||
/// </summary>
|
||||
bool Heal(uint heal, bool allowRevive = false, EventBatchId batchId = default, bool forceHeal = false);
|
||||
bool Heal(uint heal, bool allowRevive = false, EventBatchId batchId = default, bool forceHeal = false,
|
||||
EventHook? customEventHook = null);
|
||||
|
||||
/// <summary>
|
||||
/// Restores all PP of the Pokemon.
|
||||
@@ -1118,7 +1119,8 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Heal(uint heal, bool allowRevive, EventBatchId batchId = default, bool forceHeal = false)
|
||||
public bool Heal(uint heal, bool allowRevive, EventBatchId batchId = default, bool forceHeal = false,
|
||||
EventHook? customEventHook = null)
|
||||
{
|
||||
if (IsFainted && !allowRevive)
|
||||
return false;
|
||||
@@ -1137,7 +1139,8 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
}
|
||||
|
||||
var newHealth = CurrentHealth + heal;
|
||||
BattleData?.Battle.EventHook.Invoke(new HealEvent(this, CurrentHealth, newHealth)
|
||||
customEventHook ??= BattleData?.Battle.EventHook;
|
||||
customEventHook?.Invoke(new HealEvent(this, CurrentHealth, newHealth)
|
||||
{
|
||||
BatchId = batchId,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user