AppRoom部分接口变化

This commit is contained in:
ALIENJACK\alien 2024-12-25 18:18:42 +08:00
parent bac3e514b6
commit a0c5da7a07

View File

@ -14,7 +14,7 @@ namespace AxibugEmuOnline.Client.Manager
public class AppRoom public class AppRoom
{ {
public Protobuf_Room_MiniInfo mineRoomMiniInfo { get; private set; } = null; public Protobuf_Room_MiniInfo mineRoomMiniInfo { get; private set; } = null;
public bool InRoom => mineRoomMiniInfo != null; public bool InRoom => App.user.IsLoggedIn && mineRoomMiniInfo != null;
public bool IsHost => mineRoomMiniInfo?.HostPlayerUID == App.user.userdata.UID; public bool IsHost => mineRoomMiniInfo?.HostPlayerUID == App.user.userdata.UID;
public bool IsScreenProviderUID => mineRoomMiniInfo?.ScreenProviderUID == App.user.userdata.UID; public bool IsScreenProviderUID => mineRoomMiniInfo?.ScreenProviderUID == App.user.userdata.UID;
public RoomGameState RoomState => mineRoomMiniInfo.GameState; public RoomGameState RoomState => mineRoomMiniInfo.GameState;
@ -512,16 +512,15 @@ namespace AxibugEmuOnline.Client.Manager
/// <param name="roomMiniInfo"></param> /// <param name="roomMiniInfo"></param>
/// <param name="freeSlots"></param> /// <param name="freeSlots"></param>
/// <returns></returns> /// <returns></returns>
public static bool GetFreeSlot(this Protobuf_Room_MiniInfo roomMiniInfo, out int[] freeSlots) public static bool GetFreeSlot(this Protobuf_Room_MiniInfo roomMiniInfo, ref List<int> freeSlots)
{ {
List<int> temp = new List<int>(); freeSlots.Clear();
for (int i = 0; i < roomMiniInfo.GamePlaySlotList.Count; i++) for (int i = 0; i < roomMiniInfo.GamePlaySlotList.Count; i++)
{ {
if (roomMiniInfo.GamePlaySlotList[i].PlayerUID <= 0) if (roomMiniInfo.GamePlaySlotList[i].PlayerUID <= 0)
temp.Add(i); freeSlots.Add(i);
} }
freeSlots = temp.ToArray(); return freeSlots.Count > 0;
return freeSlots.Length > 0;
} }
/// <summary> /// <summary>
@ -530,15 +529,10 @@ namespace AxibugEmuOnline.Client.Manager
public static bool GetPlayerSlotIdxByUid(this Protobuf_Room_MiniInfo roomMiniInfo, long uid, int joyIdx, out uint? slotIdx) public static bool GetPlayerSlotIdxByUid(this Protobuf_Room_MiniInfo roomMiniInfo, long uid, int joyIdx, out uint? slotIdx)
{ {
slotIdx = null; slotIdx = null;
//joyIdx取值返回[0,3],这个序号代表玩家本地的手柄编号
//todo : 根据uid和controllerIndex 返回占用的位置
//目前未实现,所有非0号位置的手柄,都返回false
for (int i = 0; i < roomMiniInfo.GamePlaySlotList.Count; i++) for (int i = 0; i < roomMiniInfo.GamePlaySlotList.Count; i++)
{ {
if (roomMiniInfo.GamePlaySlotList[i].PlayerUID == uid) if (roomMiniInfo.GamePlaySlotList[i].PlayerUID == uid && roomMiniInfo.GamePlaySlotList[i].PlayerLocalJoyIdx == joyIdx)
{ {
slotIdx = (uint)i; slotIdx = (uint)i;
return true; return true;