280 lines
6.1 KiB
C#
280 lines
6.1 KiB
C#
/*
|
|
* @Author: 白哉
|
|
* @Description:
|
|
* @Date: 2025年09月16日 星期二 16:09:43
|
|
* @Modify:
|
|
*/
|
|
|
|
|
|
using System.Collections.Generic;
|
|
using TH1_Logic.Steam;
|
|
using UnityEngine;
|
|
|
|
namespace TH1_Logic.Net
|
|
{
|
|
// 房间状态
|
|
public enum LobbyState
|
|
{
|
|
None, // 未在房间中
|
|
Creating, // 正在创建房间
|
|
Joining, // 正在加入房间
|
|
InLobby, // 在房间中
|
|
Leaving // 正在离开房间
|
|
}
|
|
|
|
|
|
public interface ILobby
|
|
{
|
|
public void Init();
|
|
public void Update();
|
|
|
|
public void Cleanup();
|
|
|
|
public void SetGameState(int state);
|
|
|
|
// 获取在线好友列表
|
|
public Dictionary<ulong, MemberInfo> GetOnlineFriendsDict();
|
|
|
|
// 是否初始化完毕
|
|
public bool IsInitialized();
|
|
|
|
// 邀请好友
|
|
public void InviteFriend(ulong memberId);
|
|
|
|
// 举报房间
|
|
public bool ReportLobby(LobbyListInfo lobbyInfo);
|
|
|
|
// 踢出成员
|
|
public void KickMember(ulong memberId);
|
|
|
|
// 创建房间
|
|
public void CreateLobby(int maxMembers = 4,bool isPublic = true, string password = "", string roomName = "");
|
|
|
|
// 加入房间
|
|
public void JoinLobbyById(ulong lobbyId, string password = "");
|
|
|
|
// 通过邀请加入房间
|
|
public void JoinLobbyByInvite(ulong lobbyId);
|
|
|
|
// 离开当前房间
|
|
public void LeaveLobby();
|
|
|
|
// 获取房间所有成员
|
|
public List<ulong> GetAllMemberIds();
|
|
|
|
// 获取房间所有成员信息
|
|
public Dictionary<ulong, MemberInfo> GetAllMemberInfo();
|
|
|
|
// 获取房间所有成员信息
|
|
public MemberInfo GetMemberInfo(ulong steamID);
|
|
|
|
// 获取成员数量
|
|
public int GetMemberCount();
|
|
|
|
// 获取最大成员数
|
|
public int GetMemberLimit();
|
|
|
|
// 设置最大成员数
|
|
public bool SetMemberLimit(int maxMembers);
|
|
|
|
// 判断成员是否在房间中
|
|
public bool IsMemberInLobby(ulong memberId);
|
|
|
|
// 获取自己的 memberId
|
|
public ulong GetSelfMemberId();
|
|
|
|
// 获取房主的 memberId
|
|
public ulong GetLobbyOwnerId();
|
|
|
|
// 获取自己的房间状态
|
|
public LobbyState GetCurState();
|
|
|
|
// 获取自己是不是房主
|
|
public bool IsLobbyOwner();
|
|
|
|
// 获取自己在不在房间中
|
|
public bool IsInLobby();
|
|
|
|
// 检查和房主的连接状态, 断开需要重连
|
|
public void CheckConnectionStatus();
|
|
|
|
// 发送P2P消息
|
|
public bool SendMessageToPeer(ulong member, byte[] data, bool reliable = true);
|
|
|
|
// 广播P2P消息
|
|
public bool BroadcastMessage(byte[] data, bool reliable = true);
|
|
|
|
// 获取当前房间ID用于分享
|
|
public ulong GetShareableLobbyId();
|
|
|
|
// 获取自己是否为隐私状态
|
|
public bool IsSelfStatusInvisibleOrOffline();
|
|
}
|
|
|
|
|
|
public class LobbyBase : ILobby
|
|
{
|
|
public void JoinLobbyById(ulong lobbyId, string password = "")
|
|
{
|
|
|
|
}
|
|
|
|
public void JoinLobbyByInvite(ulong lobbyId)
|
|
{
|
|
|
|
}
|
|
|
|
public void LeaveLobby()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
// 获取房间所有成员
|
|
public List<ulong> GetAllMemberIds()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public Dictionary<ulong, MemberInfo> GetAllMemberInfo()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public MemberInfo GetMemberInfo(ulong steamID)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public void Init()
|
|
{
|
|
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public void Cleanup()
|
|
{
|
|
|
|
}
|
|
|
|
public void SetGameState(int state)
|
|
{
|
|
|
|
}
|
|
|
|
public Texture2D GetMemberAvatar(ulong memberId)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public bool IsInitialized()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public void InviteFriend(ulong memberId)
|
|
{
|
|
|
|
}
|
|
|
|
public bool ReportLobby(LobbyListInfo lobbyInfo)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public void KickMember(ulong memberId)
|
|
{
|
|
|
|
}
|
|
|
|
public Dictionary<ulong, MemberInfo> GetOnlineFriendsDict()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public void CreateLobby(int maxMembers = 4,bool isPublic = true, string password = "", string roomName = "")
|
|
{
|
|
|
|
}
|
|
|
|
// 获取成员数量
|
|
public int GetMemberCount()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
// 获取最大成员数
|
|
public int GetMemberLimit()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public bool SetMemberLimit(int maxMembers)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// 判断成员是否在房间中
|
|
public bool IsMemberInLobby(ulong memberId)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// 获取自己的 memberId
|
|
public ulong GetSelfMemberId()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
// 获取房主的 memberId
|
|
public ulong GetLobbyOwnerId()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public LobbyState GetCurState()
|
|
{
|
|
return LobbyState.None;
|
|
}
|
|
|
|
public bool IsLobbyOwner()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public bool IsInLobby()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public void CheckConnectionStatus()
|
|
{
|
|
|
|
}
|
|
|
|
public bool SendMessageToPeer(ulong member, byte[] data, bool reliable = true)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public bool BroadcastMessage(byte[] data, bool reliable = true)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public ulong GetShareableLobbyId()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public bool IsSelfStatusInvisibleOrOffline()
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|