2026-05-22 16:36:39 +08:00

39 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 文件位置: TH1_Presentation/Sequencer/Task/ActionSequencerTask.cs
using System;
using Logic.CrashSight;
namespace TH1_Presentation.Sequencer.Task
{
// 轻量任务:执行一段 Action 后立刻完成。用于把"逻辑层产生的视觉刷新"按 PresentationManager 队列时序串行播放。
// 队列空闲时PresentationManager.TryProcessNext 会立即同步 Execute行为等价于直接调用 lambda
// 队列有内容时(如 Explorer/Attack 动画正在播),会等队列消化完才执行,避免视觉"提前刷新"。
public class ActionSequencerTask : ISequencerTask
{
private readonly Action _action;
private readonly string _desc;
private Action _onCompleteCallback;
public ActionSequencerTask(Action action, string desc = "ActionSequencerTask")
{
_action = action;
_desc = string.IsNullOrEmpty(desc) ? "ActionSequencerTask" : desc;
}
public string GetDescString() => _desc;
public void Execute(Action onComplete)
{
_onCompleteCallback = onComplete;
try
{
_action?.Invoke();
}
catch (Exception e)
{
LogSystem.LogError($"ActionSequencerTask[{_desc}] Exception: {e}");
}
_onCompleteCallback?.Invoke();
}
}
}