using System.Collections.Generic; using CoreGame; using Entitas; namespace CoreGame.Render { public class RetryActiveAbilitySys : IExecuteSystem { private readonly IGroup m_Group; private readonly List m_CacheEntities = new(); public RetryActiveAbilitySys(Contexts contexts) { m_Group = contexts.combat.GetGroup(CombatMatcher.RetryActiveAbility); } public void Execute(float deltaTime) { m_Group.GetEntities(m_CacheEntities); if (m_CacheEntities.Count == 0) return; for (int i = 0; i < m_CacheEntities.Count; i++) { var entity = m_CacheEntities[i]; if (entity.isDead) continue; var retryActiveAbility = entity.retryActiveAbility; if (retryActiveAbility.abilityDataList == null || retryActiveAbility.abilityDataList.Count == 0) continue; for (int j = 0; j < retryActiveAbility.abilityDataList.Count; j++) { var data = retryActiveAbility.abilityDataList[j]; if (data.HasAttach == false) { data.GaSeq = entity.hasAbilitySystem ? entity.abilitySystem.AbilityContainer.GetUniqueAbilitySpecByGaid(data.abilityId) : -1; if (data.GaSeq <= 0) { var ctx = AbilitySrv.AttachActiveAbility(entity, data.abilityId); if (ctx != null) { data.GaSeq = ctx.gaSeq; data.CdAcc = data.cd; } } if (data.GaSeq > 0) { data.HasAttach = true; } } data.CdAcc -= deltaTime; if (data.CdAcc > 0) continue; var tryActivate = entity.abilitySystem.TryActivateAbility_WithSeq(data.GaSeq); if (tryActivate == false) { data.CdAcc = 0f; continue; } data.CdAcc += data.cd; } } } } }