Files

109 lines
3.5 KiB
C#
Raw Permalink Normal View History

2025-12-24 16:58:51 -05:00
using System.Collections.Generic;
using Cielonos.MainGame.Characters;
2026-05-23 08:27:50 -04:00
using Lean.Pool;
using SLSUtilities.General;
2025-12-24 16:58:51 -05:00
using UnityEngine;
namespace Cielonos.MainGame
{
2026-05-23 08:27:50 -04:00
public partial class CombatManager
2025-12-24 16:58:51 -05:00
{
2026-05-23 08:27:50 -04:00
public class AttackAreaSubmodule : SubmoduleBase<CombatManager>
2025-12-24 16:58:51 -05:00
{
public AttackAreaCollection playerAttackAreas;
public AttackAreaCollection enemyAttackAreas;
2026-05-23 08:27:50 -04:00
public AttackAreaSubmodule(CombatManager owner) : base(owner)
2025-12-24 16:58:51 -05:00
{
playerAttackAreas = new AttackAreaCollection();
enemyAttackAreas = new AttackAreaCollection();
}
2026-02-13 09:22:11 -05:00
public void Reset()
{
playerAttackAreas = new AttackAreaCollection();
enemyAttackAreas = new AttackAreaCollection();
}
2025-12-24 16:58:51 -05:00
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);
}
}
2026-05-23 08:27:50 -04:00
public void DestroyAll()
{
playerAttackAreas.activeAttackAreas.For(area =>
{
Destroy(area.topParent.gameObject);
});
enemyAttackAreas.activeAttackAreas.For(area =>
{
Destroy(area.topParent.gameObject);
});
}
2025-12-24 16:58:51 -05:00
}
public class AttackAreaCollection
{
public List<AttackAreaBase> activeAttackAreas;
public List<NormalArea> activeNormalAreas;
public List<Projectile> activeProjectiles;
public AttackAreaCollection()
{
activeAttackAreas = new List<AttackAreaBase>();
activeNormalAreas = new List<NormalArea>();
activeProjectiles = new List<Projectile>();
}
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);
}
}
}
}
}