多轮审查评估
This commit is contained in:
@@ -44,16 +44,16 @@ namespace BaseGames.Core.Assets
|
||||
// ── Config ScriptableObjects ─────────────────────────────────────
|
||||
public const string DataFootstepCatalog = "Config/FootstepCatalog";
|
||||
|
||||
/// <summary>
|
||||
/// Addressable 标签常量(用于批量加载)。
|
||||
/// 注意:这里是标签名称而非资产地址,不会被 AddressKeyValidator 校验。
|
||||
/// </summary>
|
||||
public static class Labels
|
||||
{
|
||||
public const string Enemy = "Enemy";
|
||||
public const string Poolable = "Poolable";
|
||||
public const string BGM = "BGM";
|
||||
public const string Charms = "Charms";
|
||||
}
|
||||
/// <summary>
|
||||
/// Addressable 标签常量(用于批量加载)。
|
||||
/// 注意:这里是标签名称而非资产地址,不会被 AddressKeyValidator 校验。
|
||||
/// </summary>
|
||||
public static class Labels
|
||||
{
|
||||
public const string Enemy = "Enemy";
|
||||
public const string Poolable = "Poolable";
|
||||
public const string BGM = "BGM";
|
||||
public const string Charms = "Charms";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,12 +42,7 @@ namespace BaseGames.Core
|
||||
{
|
||||
yield return new WaitForSeconds(_deathAnimDuration);
|
||||
yield return new WaitForSeconds(_deathScreenDelay);
|
||||
|
||||
// 局部订阅确认事件,不依赖类级 bool 字段
|
||||
bool confirmed = false;
|
||||
var sub = _onDeathScreenConfirmed?.Subscribe(() => confirmed = true);
|
||||
yield return new WaitUntil(() => confirmed);
|
||||
sub?.Dispose();
|
||||
// 确认等待由 GameManager.DeathFlow 统一处理,此处仅负责动画延迟
|
||||
}
|
||||
|
||||
public IEnumerator StartRespawnCoroutine()
|
||||
|
||||
@@ -62,6 +62,7 @@ namespace BaseGames.Core
|
||||
/// <summary>场景/房间标识符,对应 RoomEnteredCondition.sceneName。与 Unity Build Settings 场景名对齐。</summary>
|
||||
public static class Scene
|
||||
{
|
||||
public const string MainMenu = "Scene_MainMenu"; // 与 AddressKeys.SceneMainMenu 对齐
|
||||
public const string Forest = "Scene_Forest";
|
||||
public const string Cave = "Scene_Cave";
|
||||
public const string Castle = "Scene_Castle";
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace BaseGames.Core
|
||||
public bool FullScreen = true;
|
||||
|
||||
public string Language = "zh-CN";
|
||||
|
||||
public bool ShowSpeedrunTimer = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -55,6 +57,7 @@ namespace BaseGames.Core
|
||||
TargetFPS = DefaultTargetFPS,
|
||||
FullScreen = DefaultFullScreen,
|
||||
Language = DefaultLanguage,
|
||||
ShowSpeedrunTimer = ShowSpeedrunTimer,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,37 +9,21 @@ using BaseGames.Core.Events;
|
||||
namespace BaseGames.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Addressables 场景加载器。
|
||||
/// 监听 EVT_SceneLoadRequest,Additive 加载指定场景,完成后发布 EVT_SceneLoaded。
|
||||
/// 完整实现由 SceneService 包装调用。
|
||||
/// Addressables 场景加载器(纯工具组件,由 SceneService 驱动)。
|
||||
/// 采用"先加载新、再卸载旧"策略,保证加载失败时旧场景仍可用。
|
||||
/// 加载完成后发布 EVT_SceneLoaded 事件。
|
||||
/// 不直接订阅 SceneLoadRequestEventChannelSO;事件分发由 SceneService 负责。
|
||||
/// </summary>
|
||||
[DefaultExecutionOrder(-950)]
|
||||
public class SceneLoader : MonoBehaviour
|
||||
{
|
||||
[Header("Event Channels - Listen")]
|
||||
[SerializeField] private SceneLoadRequestEventChannelSO _onSceneLoadRequest;
|
||||
|
||||
[Header("Event Channels - Raise")]
|
||||
[SerializeField] private StringEventChannelSO _onSceneLoaded;
|
||||
|
||||
private string _currentRoomScene;
|
||||
private AsyncOperationHandle<SceneInstance> _currentHandle;
|
||||
private readonly CompositeDisposable _subs = new();
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_onSceneLoadRequest?.Subscribe(HandleRequest).AddTo(_subs);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_subs.Clear();
|
||||
}
|
||||
|
||||
private void HandleRequest(SceneLoadRequest request)
|
||||
=> StartCoroutine(LoadSceneCoroutine(request));
|
||||
|
||||
private IEnumerator LoadSceneCoroutine(SceneLoadRequest request)
|
||||
public IEnumerator LoadSceneCoroutine(SceneLoadRequest request)
|
||||
{
|
||||
// 先加载新场景(Additive),成功后再卸载旧场景
|
||||
// 顺序保证:若加载失败,旧场景仍保持可用,不会出现无场景的空状态
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using BaseGames.Core.Assets;
|
||||
using BaseGames.Core.Events;
|
||||
|
||||
namespace BaseGames.Core
|
||||
@@ -28,13 +28,12 @@ namespace BaseGames.Core
|
||||
[SerializeField] private SceneLoadRequestEventChannelSO _onSceneLoadRequest;
|
||||
|
||||
[Header("Event Channels - Raise")]
|
||||
[SerializeField] private StringEventChannelSO _onSceneLoaded;
|
||||
[SerializeField] private VoidEventChannelSO _onFadeInRequest;
|
||||
[SerializeField] private VoidEventChannelSO _onFadeOutRequest;
|
||||
[SerializeField] private VoidEventChannelSO _onFadeInRequest;
|
||||
[SerializeField] private VoidEventChannelSO _onFadeOutRequest;
|
||||
|
||||
[SerializeField] private SceneLoader _sceneLoader;
|
||||
[SerializeField] private float _fadeDuration = 0.3f;
|
||||
|
||||
private string _currentRoomScene;
|
||||
private readonly CompositeDisposable _subscriptions = new();
|
||||
|
||||
private void OnEnable()
|
||||
@@ -52,33 +51,25 @@ namespace BaseGames.Core
|
||||
_onFadeOutRequest?.Raise();
|
||||
yield return new WaitForSeconds(_fadeDuration);
|
||||
|
||||
if (!string.IsNullOrEmpty(_currentRoomScene))
|
||||
{
|
||||
var unload = SceneManager.UnloadSceneAsync(_currentRoomScene);
|
||||
yield return new WaitUntil(() => unload.isDone);
|
||||
}
|
||||
if (_sceneLoader != null)
|
||||
yield return StartCoroutine(_sceneLoader.LoadSceneCoroutine(request));
|
||||
else
|
||||
Debug.LogError("[SceneService] _sceneLoader 未赋值,场景加载中断。请在 Inspector 中绑定 SceneLoader 组件。");
|
||||
|
||||
var load = SceneManager.LoadSceneAsync(request.SceneName, LoadSceneMode.Additive);
|
||||
yield return new WaitUntil(() => load.isDone);
|
||||
|
||||
_currentRoomScene = request.SceneName;
|
||||
_onSceneLoaded?.Raise(request.SceneName);
|
||||
_onFadeInRequest?.Raise();
|
||||
}
|
||||
|
||||
public IEnumerator UnloadCurrentRoomCoroutine()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_currentRoomScene)) yield break;
|
||||
var op = SceneManager.UnloadSceneAsync(_currentRoomScene);
|
||||
yield return new WaitUntil(() => op.isDone);
|
||||
_currentRoomScene = null;
|
||||
if (_sceneLoader != null)
|
||||
yield return StartCoroutine(_sceneLoader.UnloadCurrentCoroutine());
|
||||
}
|
||||
|
||||
public IEnumerator LoadMainMenuCoroutine()
|
||||
{
|
||||
yield return LoadSceneCoroutine(new SceneLoadRequest
|
||||
{
|
||||
SceneName = "MainMenu",
|
||||
SceneName = AddressKeys.SceneMainMenu,
|
||||
EntryTransitionId = null,
|
||||
ShowLoadingScreen = false,
|
||||
IsRespawn = false
|
||||
|
||||
Reference in New Issue
Block a user