Further work on the script interface rework
This commit is contained in:
@@ -861,7 +861,8 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
if (BattleData != null)
|
||||
{
|
||||
var prevented = false;
|
||||
this.RunScriptHook(script => script.PreventHeldItemConsume(this, HeldItem, ref prevented));
|
||||
this.RunScriptHookInterface<IScriptPreventHeldItemConsume>(script =>
|
||||
script.PreventHeldItemConsume(this, HeldItem, ref prevented));
|
||||
if (prevented)
|
||||
return false;
|
||||
BattleData.MarkItemAsConsumed(HeldItem);
|
||||
@@ -879,7 +880,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
{
|
||||
// TODO: actually consume the item
|
||||
|
||||
this.RunScriptHook(x => x.OnAfterItemConsume(this, item));
|
||||
this.RunScriptHookInterface<IScriptOnAfterItemConsume>(x => x.OnAfterItemConsume(this, item));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1055,7 +1056,8 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
if (BattleData is not null && !forceDamage)
|
||||
{
|
||||
var dmg = damage;
|
||||
this.RunScriptHook(script => script.ChangeIncomingDamage(this, source, ref dmg));
|
||||
this.RunScriptHookInterface<IScriptChangeIncomingDamage>(script =>
|
||||
script.ChangeIncomingDamage(this, source, ref dmg));
|
||||
damage = dmg;
|
||||
}
|
||||
if (damage == 0)
|
||||
@@ -1075,7 +1077,8 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
BatchId = batchId,
|
||||
});
|
||||
// And allow scripts to execute.
|
||||
this.RunScriptHook(script => script.OnDamage(this, source, CurrentHealth, newHealth));
|
||||
this.RunScriptHookInterface<IScriptOnDamage>(script =>
|
||||
script.OnDamage(this, source, CurrentHealth, newHealth));
|
||||
}
|
||||
|
||||
CurrentHealth = newHealth;
|
||||
@@ -1104,10 +1107,10 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
BattleData.Battle.EventHook.Invoke(new FaintEvent(this));
|
||||
|
||||
// Allow scripts to trigger based on the faint.
|
||||
this.RunScriptHook(script => script.OnFaint(this, source));
|
||||
this.RunScriptHookInterface<IScriptOnFaint>(script => script.OnFaint(this, source));
|
||||
foreach (var ally in BattleData.BattleSide.Pokemon.WhereNotNull().Where(x => x != this))
|
||||
{
|
||||
ally.RunScriptHook(script => script.OnAllyFaint(ally, this));
|
||||
ally.RunScriptHookInterface<IScriptOnAllyFaint>(script => script.OnAllyFaint(ally, this));
|
||||
}
|
||||
|
||||
// Make sure the OnRemove script is run.
|
||||
|
||||
Reference in New Issue
Block a user