using Entitas; using System.Collections.Generic; using Game; public class EntityDestroySystem : IExecuteSystem, IInitializeSystem { private IGroup _entities; private List _deleteEntities; public void Initialize() { _entities = Util.GetGroup(GameMatcher.ID); _deleteEntities = new List(); } public void Execute() { foreach (var entity in _entities) { if (entity.iD.Data.IsDestroy) { _deleteEntities.Add(entity); } } foreach (var deleteEntity in _deleteEntities) { ResetComponent(deleteEntity); deleteEntity.Destroy(); } _deleteEntities.Clear(); } public void ResetComponent(GameEntity entity) { var master = Util.GetMaster(); var entityId = entity.ID(); if (entity.hasID) { Util.ClearId(entity); } if (entity.hasView) { Util.ClearView(entity); } if (entity.hasMove) { Util.ClearMove(entity); } if (entity.hasTimeline) { Util.EndSkillTimeline(entity); } if (entity.hasCombo) { Util.ClearCombo(entity); } if (entity.hasSkill) { Util.ClearSkill(entity); } if (entity.hasHp) { Util.ClearHp(entity); } if (entity.hasAI) { Util.ClearAI(entity); } if (entity.hasBuff) { Util.ClearBuff(entity); } if (entity.hasBullet) { Util.ClearBullet(entity); } if (entity.hasPoint) { Util.ClearPoint(entity); } if (entity.hasMasterSoul) { Util.ClearMasterSoul(entity); } if (entity.hasInteract) { Util.ClearInteract(entity); } if (master.combo.TargetLock == entityId) { master.combo.TargetLock = 0; } if (master.combo.TargetLastLockTime.ContainsKey(entityId)) { master.combo.TargetLastLockTime.Remove(entityId); } } }