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.

48 lines
1.4 KiB

1 month ago
using System.Collections.Generic;
using CoreGame;
using CoreGame;
using CoreGame.Render;
using Entitas;
public sealed class DestroyDestroyEntCombatSystem : ICleanupSystem
{
readonly IGroup<CombatEntity> _group;
public DestroyDestroyEntCombatSystem(Contexts contexts)
{
_group = contexts.combat.GetGroup(CombatMatcher.DestroyEnt);
}
public void Cleanup()
{
LevelWaveComponent lc = null;
var levelWaveEnt = Contexts.Combat.LevelWave;
if (levelWaveEnt != null)
lc = levelWaveEnt.levelWave;
_group.GetEntities(Contexts.s_CacheEntities);
foreach (var e in Contexts.s_CacheEntities)
{
var lifeBindMe = e.lifeBindMe;
if (lifeBindMe != null)
{
for (int i = 0; i < lifeBindMe.children.Count; i++)
{
var childEid = lifeBindMe.children[i];
var childEnt = Contexts.Combat.GetEntity(childEid);
if (childEnt != null)
{
childEnt.isDead = true;
childEnt.isDestroyEnt = true;
}
}
lifeBindMe.children.Clear();
}
lc?.RemoveLifeEnt(e.creationIndex);
e.ResetTagAggregator();
e.ClearAllEvent();
e.Destroy();
}
}
}