using System.Collections.Generic; using CoreGame; using CoreGame; using CoreGame.Render; using Entitas; public sealed class DestroyDestroyEntCombatSystem : ICleanupSystem { readonly IGroup _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(); } } }