Add enemy respawner and related components for room lifecycle management
- Implemented EnemyRespawner to manage enemy spawning and respawning within rooms. - Added IRoomLifecycle interface for room activation and dormancy handling. - Created supporting classes and metadata for enemy perception and threat assessment. - Established streaming system components for room state management and transitions. - Added necessary metadata files for new scripts to ensure proper integration with Unity.
This commit is contained in:
35
Assets/_Game/Scripts/Core/ISceneLoadCoordinator.cs
Normal file
35
Assets/_Game/Scripts/Core/ISceneLoadCoordinator.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
|
||||
namespace BaseGames.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// 场景加载协调器接口。
|
||||
/// <para>
|
||||
/// 定义于 <c>BaseGames.Core</c> 以避免 <see cref="SceneService"/> 对
|
||||
/// <c>BaseGames.World.Streaming</c> 产生直接依赖。
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// 由流式加载系统(RoomStreamingManager)实现并在 Awake 中向
|
||||
/// <see cref="ServiceLocator"/> 注册。当注册存在时,<see cref="SceneService"/>
|
||||
/// 将符合条件的场景加载请求委托给本接口,确保房间生命周期(Dormant / Active / Cooling)
|
||||
/// 得到完整维护;否则退回到 SceneLoader 原生路径。
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public interface ISceneLoadCoordinator
|
||||
{
|
||||
/// <summary>
|
||||
/// 判断给定场景地址是否应由流式系统管理(而非 SceneLoader 直接加载)。
|
||||
/// <para>约定:以 <c>"Room_"</c> 前缀开头的地址均属于流式系统管辖范围。</para>
|
||||
/// </summary>
|
||||
bool OwnsScene(string sceneName);
|
||||
|
||||
/// <summary>
|
||||
/// 以完整流式路径加载并激活指定房间
|
||||
/// (Load → Dormant → Active,同时将前一个 Active 房间送入冷却队列)。
|
||||
/// </summary>
|
||||
/// <param name="sceneName">Addressable key(等同于 RoomId,前缀 "Room_")。</param>
|
||||
/// <param name="entryTransitionId">目标房间出生点 ID;null 表示使用默认出生点。</param>
|
||||
/// <param name="isRespawn">true = 复活流程,玩家应在最近存档点出生。</param>
|
||||
IEnumerator LoadAndActivateCoroutine(string sceneName, string entryTransitionId, bool isRespawn);
|
||||
}
|
||||
}
|
||||
11
Assets/_Game/Scripts/Core/ISceneLoadCoordinator.cs.meta
Normal file
11
Assets/_Game/Scripts/Core/ISceneLoadCoordinator.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cddf13c179a032c4293e181de7e8470f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
11
Assets/_Game/Scripts/Core/ITransitionDirector.cs.meta
Normal file
11
Assets/_Game/Scripts/Core/ITransitionDirector.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba229944271875048b97b953793bf37e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -104,10 +104,23 @@ namespace BaseGames.Core
|
||||
if (fadeDuration > 0f)
|
||||
yield return new WaitForSeconds(fadeDuration);
|
||||
|
||||
if (_sceneLoader != null)
|
||||
// 流式模式优先:若流式协调器已注册且声明对本场景的所有权,委托给流式系统加载。
|
||||
// 这确保复活 / 快速传送等使用 Room/Scene 类型的路径也能正确触发冷却和卸载生命周期,
|
||||
// 避免前一房间在 RoomStreamingManager 中永远停留在 Active 状态。
|
||||
var coordinator = ServiceLocator.GetOrDefault<ISceneLoadCoordinator>();
|
||||
if (coordinator != null && coordinator.OwnsScene(request.SceneName))
|
||||
{
|
||||
yield return StartCoroutine(coordinator.LoadAndActivateCoroutine(
|
||||
request.SceneName, request.EntryTransitionId, request.IsRespawn));
|
||||
}
|
||||
else if (_sceneLoader != null)
|
||||
{
|
||||
yield return StartCoroutine(_sceneLoader.LoadSceneCoroutine(request));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("[SceneService] _sceneLoader 未赋值,场景加载中断。请在 Inspector 中绑定 SceneLoader 组件。");
|
||||
}
|
||||
|
||||
// 通知:WorldStateRegistry 已就绪,场景物体应在此帧内从中读取存档状态并应用初始状态。
|
||||
// 订阅者(WorldStateRegistrySaver、各场景 StateApplier 等)会在同一帧同步执行。
|
||||
|
||||
Reference in New Issue
Block a user