修复联机bug
This commit is contained in:
parent
9f97284f77
commit
fbfa1ddf7c
@ -2,6 +2,7 @@ using Logic.Action;
|
||||
using Logic.CrashSight;
|
||||
using TH1_Core.Managers;
|
||||
using TH1_Presentation.Sequencer.Task;
|
||||
using TH1_UI.Controller.Interaction;
|
||||
using TH1_UI.Core;
|
||||
using UnityEngine;
|
||||
|
||||
@ -42,6 +43,8 @@ namespace TH1_Core.Events
|
||||
|
||||
EventManager.Subscribe<ShowUIOutsideMultiplay>(HandleShowUIOutsideMultiplay);
|
||||
EventManager.Subscribe<HideUIOutsideMultiplay>(HandleHideUIOutsideMultiplay);
|
||||
EventManager.Subscribe<UpdateUIOutsideMultiplayRoomSetting>(HandleUpdateUIOutsideMultiplayRoomSetting);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -67,6 +70,7 @@ namespace TH1_Core.Events
|
||||
|
||||
EventManager.Unsubscribe<ShowUIOutsideMultiplay>(HandleShowUIOutsideMultiplay);
|
||||
EventManager.Unsubscribe<HideUIOutsideMultiplay>(HandleHideUIOutsideMultiplay);
|
||||
EventManager.Unsubscribe<UpdateUIOutsideMultiplayRoomSetting>(HandleUpdateUIOutsideMultiplayRoomSetting);
|
||||
|
||||
|
||||
}
|
||||
@ -154,8 +158,19 @@ namespace TH1_Core.Events
|
||||
if (UIManager.Instance.UIOutsideManager == null) return;
|
||||
UIManager.Instance.UIOutsideManager.HideCurTask();
|
||||
|
||||
//if (UIManager.Instance.UIOutsideManager == null) return;
|
||||
//UIManager.Instance.UIOutsideManager.StartNewTask(new UIOutsideTask(ViewControllerManager.UIOutsideMultiplayController, evt));
|
||||
}
|
||||
|
||||
private void HandleUpdateUIOutsideMultiplayRoomSetting(UpdateUIOutsideMultiplayRoomSetting evt)
|
||||
{
|
||||
if (UIManager.Instance.UIOutsideManager == null) return;
|
||||
UIManager.Instance.UIOutsideManager.StartNewTask(new UIOutsideTask(ViewControllerManager.UIOutsideMultiplayController, evt));
|
||||
//如果当前正在处理Multiplay的界面,那么可以调用对应的UpdateView
|
||||
if (UIManager.Instance.UIOutsideManager.GetCurTaskUIControllerType() ==
|
||||
typeof(UIOutsideMultiplayController))
|
||||
{
|
||||
UIManager.Instance.UIOutsideManager.UpdateViewCurTask();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -123,4 +123,10 @@ namespace TH1_Core.Events
|
||||
{
|
||||
public uint non;
|
||||
}
|
||||
|
||||
public struct UpdateUIOutsideMultiplayRoomSetting
|
||||
{
|
||||
public uint non;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -224,6 +224,7 @@ namespace TH1_Logic.Steam
|
||||
newMemberCiv.ForceId = memberCiv.ForceId;
|
||||
}
|
||||
Main.Instance.MapConfig.CheckMapConfigChanged();
|
||||
EventManager.Publish(new UpdateUIOutsideMultiplayRoomSetting());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using Logic.CrashSight;
|
||||
using Steamworks;
|
||||
using TH1_Core.Managers;
|
||||
using TH1_Logic.Core;
|
||||
using TH1_Logic.Net;
|
||||
using UnityEngine;
|
||||
@ -50,7 +51,7 @@ namespace TH1_Logic.Steam
|
||||
// 事件委托
|
||||
public event System.Action<CSteamID> OnLobbyCreatedEvent; // 房间创建成功
|
||||
public event System.Action<CSteamID> OnLobbyEnteredEvent; // 进入房间
|
||||
public event System.Action OnLobbyLeftEvent; // 离开房间
|
||||
public event System.Action<List<CSteamID>> OnLobbyLeftEvent; // 离开房间
|
||||
public event System.Action<CSteamID, CSteamID> OnHostChangedEvent; // 房主变更 (oldHost, newHost)
|
||||
public event System.Action<List<CSteamID>> OnMembersChangedEvent; // 成员变化
|
||||
public event System.Action<string> OnLobbyErrorEvent; // 房间错误
|
||||
@ -315,8 +316,8 @@ namespace TH1_Logic.Steam
|
||||
{
|
||||
if (CurrentState != LobbyState.None)
|
||||
{
|
||||
LogSystem.LogInfo($"Cannot join lobby in state: {CurrentState}");
|
||||
return;
|
||||
//LogSystem.LogInfo($"Cannot join lobby in state: {CurrentState}");
|
||||
//return;
|
||||
}
|
||||
|
||||
LogSystem.LogInfo($"Joining lobby: {lobbyId}");
|
||||
@ -336,6 +337,7 @@ namespace TH1_Logic.Steam
|
||||
SimpleP2P.Instance.DisconnectAll();
|
||||
SteamMatchmaking.LeaveLobby(CurrentLobby);
|
||||
ResetLobbyState();
|
||||
OnLobbyLeftEvent?.Invoke(null);
|
||||
}
|
||||
|
||||
// 解散房间(仅房主可用)
|
||||
|
||||
@ -25,6 +25,7 @@ namespace TH1_UI.Controller.Base
|
||||
Action OnClosedCallback { get; set; }
|
||||
void Start(string subFolderPath, string resourceName, ViewDestroyDomain domain,UIRootType rootType);
|
||||
bool Open();
|
||||
void UpdateView();
|
||||
bool IsShow();
|
||||
bool OpenWithParam(object param);
|
||||
bool Close();
|
||||
@ -263,31 +264,7 @@ namespace TH1_UI.Controller.Base
|
||||
OnOpenSub();
|
||||
}
|
||||
|
||||
public virtual bool Close()
|
||||
{
|
||||
_loadViewCallback.End();
|
||||
_atlasPreloadingValue.Clear();
|
||||
if (IsShow())
|
||||
{
|
||||
_ReleasePreLoad();
|
||||
_TrueClose();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_atlasLoadList.Clear();
|
||||
if (LoadProperty.LoadState == LoadWindowState.LOADING)
|
||||
{
|
||||
_loadViewCallback.End();
|
||||
LoadProperty.LoadState = LoadWindowState.NONE;
|
||||
}
|
||||
else if (LoadProperty.LoadState == LoadWindowState.LOADED)
|
||||
{
|
||||
_loadViewCallback.End();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void _TrueClose()
|
||||
{
|
||||
@ -329,6 +306,32 @@ namespace TH1_UI.Controller.Base
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public virtual bool Close()
|
||||
{
|
||||
_loadViewCallback.End();
|
||||
_atlasPreloadingValue.Clear();
|
||||
if (IsShow())
|
||||
{
|
||||
_ReleasePreLoad();
|
||||
_TrueClose();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_atlasLoadList.Clear();
|
||||
if (LoadProperty.LoadState == LoadWindowState.LOADING)
|
||||
{
|
||||
_loadViewCallback.End();
|
||||
LoadProperty.LoadState = LoadWindowState.NONE;
|
||||
}
|
||||
else if (LoadProperty.LoadState == LoadWindowState.LOADED)
|
||||
{
|
||||
_loadViewCallback.End();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
protected bool _ReleasePreLoad()
|
||||
{
|
||||
for (int iter = 0; iter < _atlasLoadList.Count; ++iter)
|
||||
@ -370,6 +373,7 @@ namespace TH1_UI.Controller.Base
|
||||
}
|
||||
return _script.IsShow();
|
||||
}
|
||||
public virtual void UpdateView() { }
|
||||
|
||||
// ... (这里往后的代码,包括子界面管理等,都保持原样,无需改动) ...
|
||||
protected virtual void OnLoaded() { }
|
||||
@ -378,7 +382,7 @@ namespace TH1_UI.Controller.Base
|
||||
protected virtual void RegisterEventCallback() { }
|
||||
protected virtual void UnregisterEventCallback() { }
|
||||
protected virtual void OnClose() { }
|
||||
protected virtual void UpdateView() { }
|
||||
|
||||
|
||||
T _script;
|
||||
ViewDestroyDomain _domain;
|
||||
|
||||
@ -36,7 +36,16 @@ namespace TH1_UI.Controller.Interaction
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void UpdateView()
|
||||
{
|
||||
if (WindowScript != null)
|
||||
{
|
||||
WindowScript.RefreshAll();
|
||||
}
|
||||
|
||||
base.UpdateView();
|
||||
}
|
||||
protected override void UnregisterEventCallback()
|
||||
{
|
||||
if (WindowScript != null)
|
||||
@ -61,17 +70,6 @@ namespace TH1_UI.Controller.Interaction
|
||||
}
|
||||
}
|
||||
else
|
||||
if (_openParameter is HideUIOutsideMultiplay evt2)
|
||||
{
|
||||
_evt2 = evt2;
|
||||
// 使用接收到的数据设置UI内容
|
||||
if (WindowScript != null)
|
||||
{
|
||||
//Param1 = cid Param2 = cityLv
|
||||
//WindowScript.OnBtnCloseClick();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
{
|
||||
// 如果没有参数或参数类型不符,可以提供默认内容或打印警告
|
||||
Debug.LogWarning("[UIAnnounceMajorEventController] Opened without valid parameters.");
|
||||
|
||||
@ -72,6 +72,15 @@ namespace TH1_UI.Core
|
||||
}
|
||||
|
||||
public void Close() { _viewController.Close(); }
|
||||
|
||||
public void UpdateView()
|
||||
{
|
||||
_viewController.UpdateView();}
|
||||
|
||||
public Type GetUIControllerType()
|
||||
{
|
||||
return _viewController.GetType();
|
||||
}
|
||||
}
|
||||
|
||||
public class UIOutsideManager
|
||||
@ -97,6 +106,17 @@ namespace TH1_UI.Core
|
||||
if (_task == null) return;
|
||||
_task.Close();
|
||||
}
|
||||
|
||||
public void UpdateViewCurTask()
|
||||
{
|
||||
if (_task == null) return;
|
||||
_task.UpdateView();
|
||||
}
|
||||
|
||||
public Type GetCurTaskUIControllerType()
|
||||
{
|
||||
return _task.GetUIControllerType();
|
||||
}
|
||||
|
||||
private void OnTaskCompleted()
|
||||
{
|
||||
|
||||
@ -82,9 +82,11 @@ public class MultiplayMemberRowMono : MonoBehaviour
|
||||
|
||||
//修改mapConfig
|
||||
var t = Main.Instance.MapConfig.GetMemberCiv(_lobby.GetSelfMemberId());
|
||||
t.CivId = Table.Instance.TransCivEnumToCivId(civ);
|
||||
t.ForceId = Table.Instance.TransForceEnumToForceId(force);
|
||||
Main.Instance.MapConfig.UpdateMemberCiv(t);
|
||||
if(t != null){
|
||||
t.CivId = Table.Instance.TransCivEnumToCivId(civ);
|
||||
t.ForceId = Table.Instance.TransForceEnumToForceId(force);
|
||||
Main.Instance.MapConfig.UpdateMemberCiv(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -105,7 +105,8 @@ namespace TH1_UI.View.Outside
|
||||
|
||||
//Step #3 绑定房间数据更新的委托,在网络数据变化的时候,刷新房间数据
|
||||
_lobby.OnMembersChangedEvent += RefreshAll;
|
||||
|
||||
_lobby.OnLobbyLeftEvent += RefreshAll;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -447,6 +448,7 @@ namespace TH1_UI.View.Outside
|
||||
private void OnCloseView()
|
||||
{
|
||||
_lobby.OnMembersChangedEvent -= RefreshAll;
|
||||
_lobby.OnLobbyLeftEvent -= RefreshAll;
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user