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.
55 lines
1.9 KiB
55 lines
1.9 KiB
using System;
|
|
using System.Collections.Generic;
|
|
|
|
using Entitas;
|
|
|
|
namespace CoreGame.Render
|
|
{
|
|
public class SummonExistSys : IExecuteSystem
|
|
{
|
|
private CombatContext m_Context;
|
|
private IGroup<CombatEntity> m_SummonGroup;
|
|
private readonly List<CombatEntity> m_CacheEntities = new List<CombatEntity>();
|
|
|
|
public SummonExistSys(CombatContext context)
|
|
{
|
|
m_Context = context;
|
|
var matcher = (Matcher<CombatEntity>)Matcher<CombatEntity>.AllOf(CombatComponentsLookup.Summon);
|
|
matcher.componentNames = CombatComponentsLookup.componentNames;
|
|
m_SummonGroup = m_Context.GetGroup(matcher);
|
|
}
|
|
|
|
public void Execute(float deltaTime)
|
|
{
|
|
m_SummonGroup.GetEntities(m_CacheEntities);
|
|
foreach (var ent in m_CacheEntities)
|
|
{
|
|
var summon = ent.summon;
|
|
summon.maxExistTime -= deltaTime;
|
|
if (summon.maxExistTime <= 0f)
|
|
{
|
|
ent.DispatchEvent(ClientEvent.OnEntityBeKill, null);
|
|
}
|
|
|
|
switch (summon.survivalType)
|
|
{
|
|
case SummonSurvivalType.AttackCount:
|
|
if (summon.survivalParam1 <= 0.1f)
|
|
{
|
|
ent.DispatchEvent(ClientEvent.OnEntityBeKill, null);
|
|
}
|
|
break;
|
|
case SummonSurvivalType.DurationTime:
|
|
summon.survivalParam1 -= deltaTime;
|
|
if (summon.survivalParam1 <= 0f)
|
|
{
|
|
ent.DispatchEvent(ClientEvent.OnEntityBeKill, null);
|
|
}
|
|
break;
|
|
default:
|
|
throw new ArgumentOutOfRangeException();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|