78 lines
2.5 KiB
C#
78 lines
2.5 KiB
C#
using System.Collections.Generic;
|
||
using Sirenix.OdinInspector;
|
||
using SLSUtilities.General;
|
||
using UnityEngine;
|
||
|
||
namespace Cielonos.MainGame
|
||
{
|
||
public partial class CombatManager : Singleton<CombatManager>, ISubstructureOwner
|
||
{
|
||
// CombatManager 只保存“战斗运行时服务”:敌人索引、站位协调、攻击区域、战斗房生命周期。
|
||
// Run/Map/Reward 等一局流程语义不应该直接塞进这里。
|
||
[ShowInInspector]
|
||
private EnemySubmodule enemySm;
|
||
|
||
[ShowInInspector]
|
||
private CoordinatorSubmodule coordinatorSm;
|
||
|
||
[ShowInInspector]
|
||
private AttackAreaSubmodule attackAreaSm;
|
||
|
||
[ShowInInspector]
|
||
private CombatRoomSubmodule combatRoomSm;
|
||
|
||
[Title("Formation")]
|
||
[SerializeField]
|
||
private FormationProfile formationProfile;
|
||
|
||
[ShowInInspector]
|
||
[SerializeReference]
|
||
private List<CombatSystemBase> combatSystems;
|
||
|
||
internal FormationProfile FormationProfile => formationProfile;
|
||
|
||
protected override void Awake()
|
||
{
|
||
base.Awake();
|
||
InitializeSubstructures();
|
||
}
|
||
|
||
public void InitializeSubstructures()
|
||
{
|
||
enemySm ??= new EnemySubmodule(this);
|
||
coordinatorSm ??= new CoordinatorSubmodule(this);
|
||
attackAreaSm ??= new AttackAreaSubmodule(this);
|
||
combatRoomSm ??= new CombatRoomSubmodule(this);
|
||
}
|
||
|
||
private void Update()
|
||
{
|
||
coordinatorSm.CleanupTimeoutSectors();
|
||
coordinatorSm.TickFormationFrameAutoRefresh();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 重置一次战斗遭遇的所有运行时缓存。
|
||
/// MapManager 切换 Zone 时只需要调用这个入口,不再逐个触碰 CombatManager 的内部子模块。
|
||
/// </summary>
|
||
public void ResetEncounter()
|
||
{
|
||
attackAreaSm.Reset();
|
||
combatRoomSm.Reset();
|
||
}
|
||
}
|
||
|
||
public partial class CombatManager
|
||
{
|
||
public static EnemySubmodule EnemySm => Instance.enemySm;
|
||
public static CoordinatorSubmodule CoordinatorSm => Instance.coordinatorSm;
|
||
public static AttackAreaSubmodule AttackAreaSm => Instance.attackAreaSm;
|
||
public static CombatRoomSubmodule CombatRoomSm => Instance.combatRoomSm;
|
||
|
||
/// <summary>
|
||
/// 静态 facade,供 MapManager 等全局流程在切换场景时统一重置战斗遭遇。
|
||
/// </summary>
|
||
public static void ResetCurrentEncounter() => Instance.ResetEncounter();
|
||
}
|
||
}
|