daixiawu 46e64be903 修复了bug
[版本 V0.7.2c]
发布日期:26.5.31

---------[bug修复与优化]-------------
1.修复了东风谷早苗掷签范围伤害击杀单位后图像残留的bug
2.修复了铃仙触发幻影齐射并击杀单位时可能产生图像残留的bug
3.修复了隐脉地块可能不显示的bug
4.优化了隐脉生成逻辑,且隐脉将不再会生成于水域或者山脉中
6.修复了探索者发现结界塔时城市经验动画播放错误的bug
8.优化了拖动地图时可能镜头强制移会起始点的bug
2026-05-31 19:07:11 +08:00

109 lines
3.8 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/UISequencerTask.cs
using System;
using TH1_UI.Controller.Announce;
using TH1_UI.Controller.Base;
using TH1_UI.Core;
using UnityEngine;
namespace TH1_Presentation.Sequencer.Task
{
/// <summary>
/// 一个专门用于按顺序显示 UI (ViewController) 的任务。
/// </summary>
public class UISequencerTask : ISequencerTask
{
private readonly IViewControllerInterface _viewController;
private readonly object _data; // 用于传递给UI的数据可以是任何类型
private Action _onCompleteCallback; // 保存来自 PresentationManager 的完成回调
private bool _callbackRegistered = false;
/// <summary>
/// 创建一个UI显示任务。
/// </summary>
/// <param name="viewController">要显示的UI的控制器实例。</param>
/// <param name="data">可选需要传递给UI的数据例如包含标题和内容的自定义类或元组。</param>
public UISequencerTask(IViewControllerInterface viewController, object data = null)
{
if (viewController == null)
{
throw new ArgumentNullException(nameof(viewController), "UISequencerTask cannot be created with a null ViewController.");
}
_viewController = viewController;
_data = data;
}
public object GetData()
{
return _data;
}
public Type GetControllerType()
{
return _viewController.GetType();
}
public string GetDescString()
{
return "UISequencerTask : " + _viewController.GetType().ToString();
}
/// <summary>
/// 执行任务打开UI并等待其关闭。
/// </summary>
public void Execute(Action onComplete)
{
// 1. 保存 PresentationManager 的完成回调
_onCompleteCallback = onComplete;
// 添加调试日志
//Debug.Log($"[TASK] Execute: {_viewController.Name}. Subscribing 'OnViewClosed'. Callback is currently '{(object)_viewController.OnClosedCallback ?? "null"}'.");
// 2. 注册自己的回调到 ViewController 的关闭事件上
_viewController.OnClosedCallback += OnViewClosed;
_callbackRegistered = true;
// 添加调试日志
//Debug.Log($"[TASK] After Subscribe: {_viewController.Name}. Callback is now '{(object)_viewController.OnClosedCallback ?? "null"}'.");
// 3. 打开界面
if (_data != null)
_viewController.OpenWithParam(_data);
else
_viewController.Open();
}
private void OnViewClosed()
{
// step #1 在通知前,立刻注销自己的回调
if (_callbackRegistered)
{
_viewController.OnClosedCallback -= OnViewClosed;
_callbackRegistered = false;
}
//_viewController.OnClosedCallback -= OnViewClosed;
// step #2. 通知 PresentationManager 任务已完成
_onCompleteCallback?.Invoke();
}
public IViewControllerInterface GetController()
{
return _viewController;
}
/// <summary>
/// 检查是否可以通过Esc/右键关闭
/// </summary>
public bool CanCloseByEsc()
{
if (_viewController is IEscClosable closable)
return closable.CanCloseByEsc();
return false; // 默认可关闭
}
public void CancelMapHighlights()
{
if (_viewController is IEscClosable closable)
closable.CancelMapHighlightsOrDoNothing();
}
}
}