v10 全量评审:修复 TD-06 至 TD-12(InputReader 移除资产扫描回退 / EmergencySave 解除 LocalFileStorage 直接依赖 / AccessibilityManager 注册 IAccessibilityService / HUDController HP/SpringIcon SetActive 复用 / MovingPlatform 缓存 WaitForSeconds / RewardSO IRewardTarget 解耦 Quest←Player 依赖 / CrashReporter 频率限制崩溃日志)
This commit is contained in:
@@ -25,6 +25,7 @@ namespace BaseGames.Cutscene
|
||||
|
||||
private PlayableDirector _director;
|
||||
private readonly CompositeDisposable _subs = new();
|
||||
private System.Action _onCompletedCallback;
|
||||
|
||||
/// <summary>是否正在播放过场。</summary>
|
||||
public bool IsPlaying => _director != null && _director.state == PlayState.Playing;
|
||||
@@ -58,10 +59,15 @@ namespace BaseGames.Cutscene
|
||||
Debug.LogWarning($"[CutsceneManager] 找不到 cutsceneId='{cutsceneId}'");
|
||||
}
|
||||
|
||||
/// <summary>播放指定过场 SO。</summary>
|
||||
public void PlayCutscene(CutsceneSO cutscene)
|
||||
/// <summary>
|
||||
/// 播放指定过场 SO。
|
||||
/// <paramref name="onCompleted"/>:过场完全结束(PlayableDirector.stopped)后调用,
|
||||
/// 可用于写入存档 flag 等需要在播完后执行的逻辑。
|
||||
/// </summary>
|
||||
public void PlayCutscene(CutsceneSO cutscene, System.Action onCompleted = null)
|
||||
{
|
||||
if (cutscene == null || IsPlaying) return;
|
||||
_onCompletedCallback = onCompleted;
|
||||
_director.playableAsset = cutscene.Timeline;
|
||||
|
||||
// 应用 Track → GameObject 绑定
|
||||
@@ -102,6 +108,10 @@ namespace BaseGames.Cutscene
|
||||
_director.stopped -= OnCutsceneStopped;
|
||||
_inputReader?.EnableGameplayInput();
|
||||
_onCutsceneEnded?.Raise();
|
||||
// 取出并调用完成回调(清空后调用,防止回调内再次触发 PlayCutscene 时覆盖)
|
||||
var cb = _onCompletedCallback;
|
||||
_onCompletedCallback = null;
|
||||
cb?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,8 +71,15 @@ namespace BaseGames.Cutscene
|
||||
&& _worldState.HasFlag($"cutscene_played_{_cutscene.cutsceneId}"))
|
||||
return;
|
||||
|
||||
_cutsceneManager.PlayCutscene(_cutscene);
|
||||
_worldState?.SetFlag($"cutscene_played_{_cutscene.cutsceneId}");
|
||||
// 捕获局部变量,避免回调内通过 this 访问被销毁的对象
|
||||
var cutsceneId = _cutscene.cutsceneId;
|
||||
var worldState = _worldState;
|
||||
|
||||
_cutsceneManager.PlayCutscene(_cutscene, onCompleted: () =>
|
||||
{
|
||||
// 过场完全结束后才写入 flag,确保异常中断时可重触
|
||||
worldState?.SetFlag($"cutscene_played_{cutsceneId}");
|
||||
});
|
||||
|
||||
// 区域触发后禁用自身,防止重入
|
||||
if (_mode == TriggerMode.OnEnter) enabled = false;
|
||||
|
||||
Reference in New Issue
Block a user