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.
116 lines
3.8 KiB
116 lines
3.8 KiB
using System.Collections.Generic;
|
|
using Entitas;
|
|
|
|
namespace CoreGame.Render
|
|
{
|
|
/// <summary>
|
|
/// 暴风雪等区域实体, 定时释放技能
|
|
/// </summary>
|
|
public class ZoneSys : IExecuteSystem
|
|
{
|
|
private readonly IGroup<CombatEntity> m_ZoneGroup;
|
|
private readonly List<CombatEntity> m_CacheEntities = new List<CombatEntity>();
|
|
|
|
public ZoneSys(CombatContext contexts)
|
|
{
|
|
m_ZoneGroup = contexts.GetGroup(CombatMatcher.Zone);
|
|
}
|
|
|
|
public void Execute(float deltaTime)
|
|
{
|
|
m_ZoneGroup.GetEntities(m_CacheEntities);
|
|
for (int i = 0; i < m_CacheEntities.Count; i++)
|
|
{
|
|
ProcessZone(m_CacheEntities[i], deltaTime);
|
|
}
|
|
}
|
|
|
|
private void ProcessZone(CombatEntity entity, float deltaTime)
|
|
{
|
|
var zone = entity.zone;
|
|
if (zone.hasInvalidated)
|
|
return;
|
|
|
|
if (zone.duration < 0 || (zone.loopType == ZoneLoopType.Count && zone.loopCnt <= 0))
|
|
{
|
|
var attachAbilityProcess = false;
|
|
var endAbilityProcess = false;
|
|
if (zone.attachAbilityCtxSeq > 0)
|
|
{
|
|
if (entity.abilitySystem.HasAbilityProcess(zone.attachAbilityCtxSeq))
|
|
{
|
|
attachAbilityProcess = true;
|
|
}
|
|
else
|
|
{
|
|
entity.abilitySystem.UnGrantAbility(zone.attachAbilityCtxSeq);
|
|
}
|
|
}
|
|
|
|
if (zone.endAbilityCtxSeq > 0)
|
|
{
|
|
if (entity.abilitySystem.HasAbilityProcess(zone.endAbilityCtxSeq))
|
|
{
|
|
endAbilityProcess = true;
|
|
}
|
|
else if (ZoneSrv.ZoneActiveAbility(entity, zone.endAbilityCtxSeq, true))
|
|
{
|
|
ZoneSrv.InvalidateZone(entity);
|
|
endAbilityProcess = true;
|
|
}
|
|
}
|
|
|
|
if (attachAbilityProcess == false && endAbilityProcess == false)
|
|
{
|
|
ZoneSrv.DestroyZone(entity);
|
|
}
|
|
return;
|
|
}
|
|
|
|
|
|
zone.duration -= deltaTime;
|
|
|
|
if (zone.isFollow)
|
|
{
|
|
var targetEnt = Contexts.Combat.GetEntity(zone.targetEid);
|
|
var entityTransformProxy = entity.logicTransform;
|
|
if (targetEnt.IsValid())
|
|
{
|
|
var targetEntTransformProxy = targetEnt.logicTransform;
|
|
zone.lastPos = targetEntTransformProxy.position;
|
|
zone.lastDir = targetEntTransformProxy.forward;
|
|
}
|
|
else
|
|
{
|
|
if (zone.entInvalidDestroy)
|
|
{
|
|
ZoneSrv.DestroyZone(entity);
|
|
return;
|
|
}
|
|
}
|
|
entityTransformProxy.SetPosition(zone.lastPos + zone.offsetPos);
|
|
entityTransformProxy.SetDirection(zone.lastDir);
|
|
}
|
|
|
|
if (zone.loopType == ZoneLoopType.Time)
|
|
{
|
|
zone.accumulatedTime += deltaTime;
|
|
if (zone.accumulatedTime >= zone.interval)
|
|
{
|
|
zone.accumulatedTime -= zone.interval;
|
|
ZoneSrv.ZoneActiveAbility(entity, zone.attachAbilityCtxSeq, false);
|
|
}
|
|
}
|
|
else if (zone.loopType == ZoneLoopType.Count)
|
|
{
|
|
if (zone.loopCnt > 0)
|
|
{
|
|
if (ZoneSrv.ZoneActiveAbility(entity, zone.attachAbilityCtxSeq, false))
|
|
{
|
|
zone.loopCnt--;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|