增加房主创建房间成功后,将本地的手柄连接设置同步到服务器的机制

This commit is contained in:
ALIENJACK\alien 2024-12-25 19:56:11 +08:00
parent ecdfd507d9
commit 13cadd90a0
2 changed files with 31 additions and 28 deletions

View File

@ -65,37 +65,27 @@ namespace AxibugEmuOnline.Client.Manager
m_controllerSetuper = Supporter.GetControllerSetuper();
SetupController();
//自动分配0号手柄到0号手柄位
m_controllerSetuper.SetConnect(con0ToSlot: 0);
Eventer.Instance.PostEvent(EEvent.OnControllerConnectChanged);
Eventer.Instance.RegisterEvent(EEvent.OnRoomSlotDataChanged, OnSlotDataChanged);
}
private void OnSlotDataChanged()
{
SetupController();
}
long selfUID = App.user.userdata.UID;
uint? con0Slot;
uint? con1Slot;
uint? con2Slot;
uint? con3Slot;
private void SetupController()
{
if (!App.roomMgr.InRoom) //不在房间中,自动分配0号手柄到0号手柄位
{
m_controllerSetuper.SetConnect(con0ToSlot: 0);
}
else //在房间中则使用服务器下发的手柄槽位信息分配本地手柄
{
long selfUID = App.user.userdata.UID;
uint? con0Slot;
uint? con1Slot;
uint? con2Slot;
uint? con3Slot;
App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 0, out con0Slot);
App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 1, out con1Slot);
App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 2, out con2Slot);
App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 3, out con3Slot);
App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 0, out con0Slot);
App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 1, out con1Slot);
App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 2, out con2Slot);
App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 3, out con3Slot);
m_controllerSetuper.SetConnect(con0Slot, con1Slot, con2Slot, con3Slot);
}
m_controllerSetuper.SetConnect(con0Slot, con1Slot, con2Slot, con3Slot);
Eventer.Instance.PostEvent(EEvent.OnControllerConnectChanged);
}

View File

@ -2,6 +2,7 @@
using AxibugEmuOnline.Client.ClientCore;
using AxibugEmuOnline.Client.Event;
using AxibugProtobuf;
using VirtualNes.Core;
namespace AxibugEmuOnline.Client
{
@ -111,7 +112,19 @@ namespace AxibugEmuOnline.Client
private void OnRoomCreated()
{
m_delayCreateRoom = false;
if (m_delayCreateRoom)
{
m_delayCreateRoom = false;
//延迟创建房间成功后,同步本地手柄连接状态
Dictionary<uint, uint> temp = new Dictionary<uint, uint>();
var setuper = Supporter.GetControllerSetuper();
for (int i = 0; i < 4; i++)
{
var joyIndex = setuper.GetSlotConnectingController(i);
if (joyIndex != null) temp[(uint)i] = (uint)joyIndex.Value;
}
App.roomMgr.SendChangePlaySlotIdxWithJoyIdx(temp);
}
}
private void OnLoggedIn()