146 lines
4.9 KiB
C#
146 lines
4.9 KiB
C#
#if !(STEAM_CHANNEL || STEAMWORKS_NET)
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using Steamworks;
|
|
using TH1_Logic.Chat;
|
|
using TH1_Logic.Net;
|
|
|
|
namespace TH1_Logic.Steam
|
|
{
|
|
public class SteamLobbyManager : LobbyBase
|
|
{
|
|
public const string LobbyPasswordWrongError = "LobbyPasswordWrong";
|
|
|
|
public bool IsSteamInitialized => false;
|
|
public bool IsloggedIn => false;
|
|
public bool IsLobbyInitialized => false;
|
|
public string SelfName => GetSelfDisplayName();
|
|
public CSteamID SelfID => CSteamID.Nil;
|
|
public List<LobbyListInfo> LobbyListInfos => GetLobbyListInfos();
|
|
|
|
public event Action<CSteamID> OnLobbyCreatedEvent;
|
|
public event Action<CSteamID> OnLobbyEnteredEvent;
|
|
public event Action<List<CSteamID>> OnLobbyLeftEvent;
|
|
public event Action<CSteamID, CSteamID> OnHostChangedEvent;
|
|
public event Action<List<CSteamID>> OnMembersChangedEvent;
|
|
public event Action<string> OnLobbyErrorEvent;
|
|
public event Action<CSteamID> OnMemberJoinedEvent;
|
|
public event Action<CSteamID> OnMemberLeftEvent;
|
|
|
|
public new static string GetDefaultRoomName(string selfName)
|
|
{
|
|
return string.IsNullOrWhiteSpace(selfName) ? "Default" : $"{selfName} Room";
|
|
}
|
|
|
|
public static string FilterRoomName(string input, int maxLength = 20)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(input)) return "Default";
|
|
var result = input.Trim();
|
|
if (result.Length > maxLength) result = result.Substring(0, maxLength);
|
|
return BannedWordFilter.Filter(result, BannedTextContext.Name);
|
|
}
|
|
|
|
public string GetRoomName()
|
|
{
|
|
return "Default";
|
|
}
|
|
|
|
public bool SetRoomName(string roomName)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public bool CanCreateLobbyNow(out string reason)
|
|
{
|
|
reason = "Steam is unavailable on this platform.";
|
|
return false;
|
|
}
|
|
|
|
public void SearchPublicLobbies()
|
|
{
|
|
}
|
|
|
|
public List<(CSteamID id, string name)> GetOnlineFriends()
|
|
{
|
|
return new List<(CSteamID, string)>();
|
|
}
|
|
|
|
public CSteamID GetCSteamID(ulong memberId)
|
|
{
|
|
return CSteamID.Nil;
|
|
}
|
|
|
|
public EPersonaState GetSelfPersonaState()
|
|
{
|
|
return EPersonaState.k_EPersonaStateOffline;
|
|
}
|
|
|
|
public void RaiseNoSteamError()
|
|
{
|
|
OnLobbyErrorEvent?.Invoke("Steam is unavailable on this platform.");
|
|
}
|
|
|
|
public void SuppressEventWarnings()
|
|
{
|
|
_ = OnLobbyCreatedEvent;
|
|
_ = OnLobbyEnteredEvent;
|
|
_ = OnLobbyLeftEvent;
|
|
_ = OnHostChangedEvent;
|
|
_ = OnMembersChangedEvent;
|
|
_ = OnMemberJoinedEvent;
|
|
_ = OnMemberLeftEvent;
|
|
}
|
|
}
|
|
|
|
public class SimpleP2P
|
|
{
|
|
public static SimpleP2P Instance { get; } = new SimpleP2P();
|
|
|
|
public bool IsInitialized => false;
|
|
public event Action<CSteamID> OnPeerConnectedEvent;
|
|
public event Action<CSteamID> OnPeerDisconnectedEvent;
|
|
public event Action<CSteamID, byte[]> OnMessageReceivedEvent;
|
|
public event Action<CSteamID, string> OnMessageSendFailedEvent;
|
|
public event Action<string> OnConnectionErrorEvent;
|
|
|
|
public void Initialize() { }
|
|
public void Update() { }
|
|
public void PollMessages() { }
|
|
public void Cleanup() { }
|
|
public void DisconnectAll() { }
|
|
public void DisconnectFromPeer(CSteamID steamID) { }
|
|
public void MarkExpectedDisconnect(CSteamID steamID) { }
|
|
public int GetConnectionCount() => 0;
|
|
public bool ConnectToPeer(CSteamID steamID) => false;
|
|
public bool IsConnectedTo(CSteamID steamID) => false;
|
|
public IEnumerable<CSteamID> GetConnectedPeers() => Array.Empty<CSteamID>();
|
|
public bool HasRecentConnectionFailure(float seconds, out string reason)
|
|
{
|
|
reason = string.Empty;
|
|
return false;
|
|
}
|
|
|
|
public bool SendTo(CSteamID target, byte[] data, bool reliable = true, bool ordered = true) => false;
|
|
public bool SendToWithOutConnect(CSteamID target, byte[] data, bool reliable = true, bool ordered = true) => false;
|
|
|
|
public bool CanQueueMessages(IReadOnlyList<CSteamID> targets, int dataLength, out CSteamID failedTarget, out string reason)
|
|
{
|
|
failedTarget = CSteamID.Nil;
|
|
reason = string.Empty;
|
|
return targets == null || targets.Count == 0;
|
|
}
|
|
|
|
public void LogDetailedConnectionInfo(CSteamID steamID) { }
|
|
|
|
public void SuppressEventWarnings()
|
|
{
|
|
_ = OnPeerConnectedEvent;
|
|
_ = OnPeerDisconnectedEvent;
|
|
_ = OnMessageReceivedEvent;
|
|
_ = OnMessageSendFailedEvent;
|
|
_ = OnConnectionErrorEvent;
|
|
}
|
|
}
|
|
}
|
|
#endif
|