This commit is contained in:
parent
8a857ed232
commit
7b25161a8d
@ -123,6 +123,8 @@ public static class MoveTurnExecutor
|
||||
executingMove.RunScriptHookInterface<IScriptOnAfterMove>(x => x.OnAfterMove(executingMove));
|
||||
}
|
||||
|
||||
private static readonly ThreadLocal<List<TypeIdentifier>> TypeListCache = new(() => []);
|
||||
|
||||
private static void ExecuteMoveChoiceForTarget(IBattle battle, IExecutingMove executingMove, IPokemon target)
|
||||
{
|
||||
var failed = false;
|
||||
@ -173,7 +175,11 @@ public static class MoveTurnExecutor
|
||||
|
||||
hitData.Type = hitType;
|
||||
|
||||
var types = new List<TypeIdentifier>(target.Types);
|
||||
// We re-use the TypeListCache to avoid allocating a new list every time.
|
||||
var types = TypeListCache.Value;
|
||||
types.Clear();
|
||||
types.AddRange(target.Types);
|
||||
|
||||
executingMove.RunScriptHook(x => x.ChangeTypesForMove(executingMove, target, hitIndex, types));
|
||||
target.RunScriptHook(x => x.ChangeTypesForIncomingMove(executingMove, target, hitIndex, types));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user