AxibugEmuOnline/AxibugEmuOnline.Client/Assets/Script/UI/InGameUI/StepPerformer.cs

63 lines
1.7 KiB
C#
Raw Normal View History

2024-09-14 17:22:01 +08:00
using AxibugEmuOnline.Client.ClientCore;
2024-11-08 16:23:26 +08:00
using AxibugEmuOnline.Client.Common;
using UnityEngine;
2024-09-14 17:22:01 +08:00
namespace AxibugEmuOnline.Client
{
public class StepPerformer
{
private InGameUI m_inGameUI;
private int m_step = -1;
public StepPerformer(InGameUI inGameUI)
{
m_inGameUI = inGameUI;
}
public void Perform(int step)
{
m_step = step;
switch (m_step)
{
//等待主机上报快照
case 0:
PauseCore();
if (App.roomMgr.IsHost)
{
2024-09-23 18:15:34 +08:00
var stateRaw = m_inGameUI.Core.GetStateBytes();
2024-11-08 16:23:26 +08:00
Debug.Log($"快照上报:{Helper.FileMD5Hash(stateRaw)}");
2024-09-23 18:15:34 +08:00
App.roomMgr.SendHostRaw(stateRaw);
2024-09-14 17:22:01 +08:00
}
break;
//加载存档并发送Ready通知
case 1:
PauseCore();
2024-11-08 16:23:26 +08:00
Debug.Log($"快照加载:{Helper.FileMD5Hash(App.roomMgr.RawData)}");
2024-09-23 18:15:34 +08:00
m_inGameUI.Core.LoadStateFromBytes(App.roomMgr.RawData);
2024-09-14 17:22:01 +08:00
App.roomMgr.SendRoomPlayerReady();
break;
case 2:
m_step = -1;
ResumeCore();
break;
}
}
private void PauseCore()
{
2024-09-23 18:15:34 +08:00
m_inGameUI.Core.Pause();
2024-09-14 17:22:01 +08:00
}
private void ResumeCore()
{
2024-09-23 18:15:34 +08:00
m_inGameUI.Core.Resume();
2024-09-14 17:22:01 +08:00
}
internal void Reset()
{
m_step = -1;
}
}
}