Files
bansonic_beta_main/Assets/scripts/Data/AllyHeroSkillSelectionValidator.cs
T

33 lines
910 B
C#

using System;
using System.Collections;
using UnityEngine;
public static class AllyHeroSkillSelectionValidator
{
public static IEnumerator ValidateAllHeroesAsync(int heroesPerFrame = 2, Action<bool> onCompleted = null)
{
AllyHero_SO[] heroes = RuntimeResourcesCache.LoadAllAllyHeroes();
bool anyChanged = false;
int processedThisFrame = 0;
int batchSize = Mathf.Max(1, heroesPerFrame);
for (int i = 0; i < heroes.Length; i++)
{
AllyHero_SO hero = heroes[i];
if (hero != null && hero.ValidateEquippedSkillSelections())
{
anyChanged = true;
}
processedThisFrame++;
if (processedThisFrame >= batchSize)
{
processedThisFrame = 0;
yield return null;
}
}
onCompleted?.Invoke(anyChanged);
}
}