Finish script interface refactor
All checks were successful
Build / Build (push) Successful in 1m1s

This commit is contained in:
2025-07-06 10:27:56 +02:00
parent 83f6a183e3
commit 7c270a6d52
117 changed files with 669 additions and 648 deletions

View File

@@ -31,7 +31,7 @@ public static class TurnRunner
// they can then know this later on.)
foreach (var choice in queue.GetChoices().WhereNotNull())
{
choice.RunScriptHookInterface<IScriptOnBeforeTurnStart>(script => script.OnBeforeTurnStart(choice));
choice.RunScriptHook<IScriptOnBeforeTurnStart>(script => script.OnBeforeTurnStart(choice));
}
// Now we can properly begin executing choices.
@@ -60,15 +60,15 @@ public static class TurnRunner
{
scripts.Clear();
pokemon.GetOwnScripts(scripts);
scripts.RunScriptHookInterface<IScriptOnEndTurn>(x => x.OnEndTurn(pokemon, battle));
scripts.RunScriptHook<IScriptOnEndTurn>(x => x.OnEndTurn(pokemon, battle));
}
scripts.Clear();
side.GetOwnScripts(scripts);
scripts.RunScriptHookInterface<IScriptOnEndTurn>(x => x.OnEndTurn(side, battle));
scripts.RunScriptHook<IScriptOnEndTurn>(x => x.OnEndTurn(side, battle));
}
scripts.Clear();
battle.GetOwnScripts(scripts);
scripts.RunScriptHookInterface<IScriptOnEndTurn>(x => x.OnEndTurn(battle, battle));
scripts.RunScriptHook<IScriptOnEndTurn>(x => x.OnEndTurn(battle, battle));
}
}
@@ -77,7 +77,7 @@ public static class TurnRunner
/// </summary>
public static void ExecuteChoice(IBattle battle, ITurnChoice choice)
{
choice.RunScriptHook(x => x.ChangeTurnChoice(ref choice));
choice.RunScriptHook<IScriptChangeTurnChoice>(x => x.ChangeTurnChoice(ref choice));
if (choice is IPassChoice)
return;
if (battle.HasEnded)
@@ -90,7 +90,7 @@ public static class TurnRunner
{
case IMoveChoice moveChoice:
MoveTurnExecutor.ExecuteMoveChoice(battle, moveChoice);
moveChoice.RunScriptHook(script => script.OnAfterMoveChoice(moveChoice));
moveChoice.RunScriptHook<IScriptOnAfterMoveChoice>(script => script.OnAfterMoveChoice(moveChoice));
break;
case ISwitchChoice switchChoice:
ExecuteSwitchChoice(battle, switchChoice);
@@ -111,7 +111,7 @@ public static class TurnRunner
if (battleData == null)
return;
var preventSwitch = false;
fleeChoice.RunScriptHookInterface<IScriptPreventSelfSwitch>(script =>
fleeChoice.RunScriptHook<IScriptPreventSelfSwitch>(script =>
script.PreventSelfSwitch(fleeChoice, ref preventSwitch));
if (preventSwitch)
return;
@@ -121,7 +121,7 @@ public static class TurnRunner
continue;
foreach (var pokemon in side.Pokemon.WhereNotNull())
{
pokemon.RunScriptHookInterface<IScriptPreventOpponentSwitch>(script =>
pokemon.RunScriptHook<IScriptPreventOpponentSwitch>(script =>
script.PreventOpponentSwitch(fleeChoice, ref preventSwitch));
if (preventSwitch)
return;
@@ -142,7 +142,7 @@ public static class TurnRunner
return;
var preventFlee = false;
fleeChoice.RunScriptHookInterface<IScriptPreventSelfRunAway>(script =>
fleeChoice.RunScriptHook<IScriptPreventSelfRunAway>(script =>
script.PreventSelfRunAway(fleeChoice, ref preventFlee));
if (preventFlee)
return;
@@ -153,7 +153,7 @@ public static class TurnRunner
continue;
foreach (var pokemon in side.Pokemon.WhereNotNull())
{
pokemon.RunScriptHookInterface<IScriptPreventOpponentRunAway>(script =>
pokemon.RunScriptHook<IScriptPreventOpponentRunAway>(script =>
script.PreventOpponentRunAway(fleeChoice, ref preventFlee));
if (preventFlee)
return;