You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

70 lines
2.5 KiB

using System.Collections.Generic;
using CoreGame;
using Entitas;
namespace CoreGame.Render
{
public class RetryActiveAbilitySys : IExecuteSystem
{
private readonly IGroup<CombatEntity> m_Group;
private readonly List<CombatEntity> 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;
}
}
}
}
}