using System.Collections.Generic; using Cielonos.MainGame.Characters; using Lean.Pool; using SLSUtilities.General; using UnityEngine; namespace Cielonos.MainGame { public partial class CombatManager { public class AttackAreaSubmodule : SubmoduleBase { public AttackAreaCollection playerAttackAreas; public AttackAreaCollection enemyAttackAreas; public AttackAreaSubmodule(CombatManager owner) : base(owner) { playerAttackAreas = new AttackAreaCollection(); enemyAttackAreas = new AttackAreaCollection(); } public void Reset() { playerAttackAreas = new AttackAreaCollection(); enemyAttackAreas = new AttackAreaCollection(); } public void Register(AttackAreaBase attackArea) { if (attackArea.creator.fraction == Fraction.Player) { playerAttackAreas.Add(attackArea); } else if (attackArea.creator.fraction == Fraction.Enemy) { enemyAttackAreas.Add(attackArea); } } public void Unregister(AttackAreaBase attackArea) { if (attackArea.creator.fraction == Fraction.Player) { playerAttackAreas.Remove(attackArea); } else if (attackArea.creator.fraction == Fraction.Enemy) { enemyAttackAreas.Remove(attackArea); } } public void DestroyAll() { playerAttackAreas.activeAttackAreas.For(area => { Destroy(area.topParent.gameObject); }); enemyAttackAreas.activeAttackAreas.For(area => { Destroy(area.topParent.gameObject); }); } } public class AttackAreaCollection { public List activeAttackAreas; public List activeNormalAreas; public List activeProjectiles; public AttackAreaCollection() { activeAttackAreas = new List(); activeNormalAreas = new List(); activeProjectiles = new List(); } public void Add(AttackAreaBase attackArea) { activeAttackAreas.Add(attackArea); if (attackArea is NormalArea normalArea) { activeNormalAreas.Add(normalArea); } else if (attackArea is Projectile projectile) { activeProjectiles.Add(projectile); } } public void Remove(AttackAreaBase attackArea) { activeAttackAreas.Remove(attackArea); if (attackArea is NormalArea normalArea) { activeNormalAreas.Remove(normalArea); } else if (attackArea is Projectile projectile) { activeProjectiles.Remove(projectile); } } } } }