using RuntimeData; using TH1_Core.Events; using TH1_Logic.Chat; using TH1_Logic.Core; using TH1_Logic.Net; using TH1_UI.Controller.Base; using TH1_UI.View.Bottom; using UnityEngine; namespace TH1_UI.Controller.Bottom { public class UIBottomNetController : ViewController { /// /// 一个空的构造函数,以满足 ViewControllerManager._CreateView 的 new() 泛型约束。 /// public UIBottomNetController() { } protected override void RegisterEventCallback() { base.RegisterEventCallback(); if (WindowScript != null) { WindowScript.OnBtnCloseClick += _OnBtnCloseClick; WindowScript.OnChatMessageSend += _OnChatMessageSend; } } protected override void UnregisterEventCallback() { if (WindowScript != null) { WindowScript.OnBtnCloseClick = null; WindowScript.OnChatMessageSend = null; } base.UnregisterEventCallback(); } public override void OnMatchStart() { if(Main.MapData.Net.Mode == NetMode.Multi) OpenWithParam(new ShowUIBottomNet()); } protected override void OnOpen() { base.OnOpen(); // 检查暂存的参数是否存在且类型正确 if (_openParameter is ShowUIBottomNet evt) { // 使用接收到的数据设置UI内容 if (WindowScript != null) { WindowScript.SetContent(); } } else { // 如果没有参数或参数类型不符,可以提供默认内容或打印警告 Debug.LogWarning("[UIBottomNet] Opened without valid parameters."); if (WindowScript != null) { //WindowScript.SetContent(); } } } public override bool Close() { WindowScript?.CloseView(); return base.Close(); } void _OnBtnCloseClick() { Close(); } /// /// 处理聊天消息发送(SendChatItem 内部会触发 OnChatUpdated → ChatArea 自动刷新) /// void _OnChatMessageSend(string message) { ChatManager.Instance.SendChatItem(message); } public new void UpdateView() { if (WindowScript != null) { WindowScript.UpdateView(); } } } }