multiplayer stuff
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using RebootKit.Engine.Foundation;
|
using RebootKit.Engine.Foundation;
|
||||||
|
using RebootKit.Engine.Input;
|
||||||
using RebootKit.Engine.Services.Console;
|
using RebootKit.Engine.Services.Console;
|
||||||
using RebootKit.Engine.Services.Input;
|
using RebootKit.Engine.Services.Input;
|
||||||
using RebootKit.Engine.Services.Simulation;
|
using RebootKit.Engine.Services.Simulation;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using UnityEngine.AddressableAssets;
|
|||||||
using UnityEngine.InputSystem;
|
using UnityEngine.InputSystem;
|
||||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||||
|
|
||||||
namespace RebootKit.Engine.Services.Input {
|
namespace RebootKit.Engine.Input {
|
||||||
public class InputService : IService {
|
public class InputService : IService {
|
||||||
readonly Config m_Config;
|
readonly Config m_Config;
|
||||||
|
|
||||||
@@ -15,14 +15,14 @@ namespace RebootKit.Engine.Services.Input {
|
|||||||
public InputService(Config config) {
|
public InputService(Config config) {
|
||||||
m_Config = config;
|
m_Config = config;
|
||||||
|
|
||||||
m_Handle = Addressables.LoadAssetAsync<InputActionAsset>(m_Config.inputAssetReference);
|
// m_Handle = Addressables.LoadAssetAsync<InputActionAsset>(m_Config.inputAssetReference);
|
||||||
m_InputActionAsset = m_Handle.WaitForCompletion();
|
m_InputActionAsset = config.inputActionAsset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
m_InputActionAsset = null;
|
m_InputActionAsset = null;
|
||||||
|
|
||||||
Addressables.Release(m_Handle);
|
// Addressables.Release(m_Handle);
|
||||||
m_Handle = default;
|
m_Handle = default;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,6 +55,7 @@ namespace RebootKit.Engine.Services.Input {
|
|||||||
[Serializable]
|
[Serializable]
|
||||||
public class Config {
|
public class Config {
|
||||||
public AssetReferenceT<InputActionAsset> inputAssetReference;
|
public AssetReferenceT<InputActionAsset> inputAssetReference;
|
||||||
|
public InputActionAsset inputActionAsset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using RebootKit.Engine.Foundation;
|
using RebootKit.Engine.Foundation;
|
||||||
|
using RebootKit.Engine.Input;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace RebootKit.Engine.Services.Input {
|
namespace RebootKit.Engine.Services.Input {
|
||||||
|
|||||||
6
Runtime/Engine/Code/Main/NetworkWorldController.cs
Normal file
6
Runtime/Engine/Code/Main/NetworkWorldController.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
using Unity.Netcode;
|
||||||
|
|
||||||
|
namespace RebootKit.Engine.Main {
|
||||||
|
public abstract class NetworkWorldController : NetworkBehaviour {
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Runtime/Engine/Code/Main/NetworkWorldController.cs.meta
Normal file
3
Runtime/Engine/Code/Main/NetworkWorldController.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: edd521a69a6f4e43b97ec258adf499a6
|
||||||
|
timeCreated: 1751377120
|
||||||
@@ -4,10 +4,12 @@ using System.Threading;
|
|||||||
using Cysharp.Threading.Tasks;
|
using Cysharp.Threading.Tasks;
|
||||||
using R3;
|
using R3;
|
||||||
using RebootKit.Engine.Foundation;
|
using RebootKit.Engine.Foundation;
|
||||||
|
using RebootKit.Engine.Input;
|
||||||
using RebootKit.Engine.Services.Console;
|
using RebootKit.Engine.Services.Console;
|
||||||
using RebootKit.Engine.Services.Input;
|
using RebootKit.Engine.Services.Input;
|
||||||
using RebootKit.Engine.Services.Simulation;
|
using RebootKit.Engine.Services.Simulation;
|
||||||
using RebootKit.Engine.Simulation;
|
using RebootKit.Engine.Simulation;
|
||||||
|
using RebootKit.Engine.Steam;
|
||||||
using Unity.Netcode;
|
using Unity.Netcode;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.AddressableAssets;
|
using UnityEngine.AddressableAssets;
|
||||||
@@ -41,7 +43,7 @@ namespace RebootKit.Engine.Main {
|
|||||||
|
|
||||||
public static Camera MainCamera { get; internal set; }
|
public static Camera MainCamera { get; internal set; }
|
||||||
|
|
||||||
internal static Game GameInstance;
|
public static Game GameInstance { get; internal set; }
|
||||||
|
|
||||||
public static ulong TickCount { get; private set; }
|
public static ulong TickCount { get; private set; }
|
||||||
public static event Action<ulong> ServerTick = delegate { };
|
public static event Action<ulong> ServerTick = delegate { };
|
||||||
@@ -66,11 +68,7 @@ namespace RebootKit.Engine.Main {
|
|||||||
|
|
||||||
await InitializeAssetsAsync(cancellationToken);
|
await InitializeAssetsAsync(cancellationToken);
|
||||||
|
|
||||||
// await SteamManager.InitializeAsync(cancellationToken);
|
await SteamManager.InitializeAsync(cancellationToken);
|
||||||
|
|
||||||
// if (SteamManager.IsInitialized) {
|
|
||||||
// s_networkTransport = SteamManager.NetworkTransport;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @NOTE: This method is called after the main scene is loaded.
|
// @NOTE: This method is called after the main scene is loaded.
|
||||||
@@ -107,14 +105,13 @@ namespace RebootKit.Engine.Main {
|
|||||||
GameInstance = null;
|
GameInstance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (NetworkManager.Singleton is not null) {
|
if (NetworkManager.Singleton is not null) {
|
||||||
NetworkManager.Singleton.OnConnectionEvent -= OnConnectionEvent;
|
NetworkManager.Singleton.OnConnectionEvent -= OnConnectionEvent;
|
||||||
NetworkManager.Singleton.OnServerStarted -= OnServerStarted;
|
NetworkManager.Singleton.OnServerStarted -= OnServerStarted;
|
||||||
NetworkManager.Singleton.OnServerStopped -= OnServerStopped;
|
NetworkManager.Singleton.OnServerStopped -= OnServerStopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SteamManager.Shutdown();
|
SteamManager.Shutdown();
|
||||||
|
|
||||||
s_servicesBag.Dispose();
|
s_servicesBag.Dispose();
|
||||||
s_disposableBag.Dispose();
|
s_disposableBag.Dispose();
|
||||||
@@ -283,8 +280,7 @@ namespace RebootKit.Engine.Main {
|
|||||||
NetworkManager.Singleton.StartHost();
|
NetworkManager.Singleton.StartHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void StopServer() {
|
public static void StopServer() { }
|
||||||
}
|
|
||||||
|
|
||||||
public static void Connect() {
|
public static void Connect() {
|
||||||
if (NetworkManager.Singleton.IsClient) {
|
if (NetworkManager.Singleton.IsClient) {
|
||||||
@@ -296,9 +292,23 @@ namespace RebootKit.Engine.Main {
|
|||||||
NetworkManager.Singleton.StartClient();
|
NetworkManager.Singleton.StartClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Disconnect() {
|
public static void ConnectWithSteamID(ulong steamId) {
|
||||||
|
if (NetworkManager.Singleton.IsClient) {
|
||||||
|
s_Logger.Error("Already connected to a server");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_Logger.Info($"Connecting to server with Steam ID: {steamId}");
|
||||||
|
if (NetworkManager.Singleton.NetworkConfig.NetworkTransport is FacepunchTransport facepunchTransport) {
|
||||||
|
facepunchTransport.targetSteamId = steamId;
|
||||||
|
NetworkManager.Singleton.StartClient();
|
||||||
|
} else {
|
||||||
|
s_Logger.Error("Network transport is not FacepunchTransport. Cannot connect with Steam ID.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Disconnect() { }
|
||||||
|
|
||||||
public static void SendChatMessage(string message) {
|
public static void SendChatMessage(string message) {
|
||||||
if (!IsClient()) {
|
if (!IsClient()) {
|
||||||
s_Logger.Error("Cannot send chat message. Not connected to a server.");
|
s_Logger.Error("Cannot send chat message. Not connected to a server.");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace RebootKit.Engine.Services.Simulation.Sensors {
|
namespace RebootKit.Engine.Simulation.Sensors {
|
||||||
public interface ISensor {
|
public interface ISensor {
|
||||||
GameObject Sense();
|
GameObject Sense();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using UnityEngine;
|
using RebootKit.Engine.Simulation.Sensors;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace RebootKit.Engine.Services.Simulation.Sensors {
|
namespace RebootKit.Engine.Services.Simulation.Sensors {
|
||||||
public class RaycastSensor : ISensor {
|
public class RaycastSensor : ISensor {
|
||||||
|
|||||||
277
Runtime/Engine/Code/Steam/FacepunchTransport.cs
Normal file
277
Runtime/Engine/Code/Steam/FacepunchTransport.cs
Normal file
@@ -0,0 +1,277 @@
|
|||||||
|
// Source: https://github.com/Unity-Technologies/multiplayer-community-contributions/blob/main/Transports/com.community.netcode.transport.facepunch/Runtime/FacepunchTransport.cs
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Steamworks;
|
||||||
|
using Steamworks.Data;
|
||||||
|
using Unity.Collections;
|
||||||
|
using Unity.Collections.LowLevel.Unsafe;
|
||||||
|
using Unity.Netcode;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace RebootKit.Engine.Steam {
|
||||||
|
using SocketConnection = Connection;
|
||||||
|
|
||||||
|
public class FacepunchTransport : NetworkTransport, IConnectionManager, ISocketManager {
|
||||||
|
private ConnectionManager connectionManager;
|
||||||
|
private SocketManager socketManager;
|
||||||
|
private Dictionary<ulong, Client> connectedClients;
|
||||||
|
|
||||||
|
[Space]
|
||||||
|
[Tooltip("The Steam App ID of your game. Technically you're not allowed to use 480, but Valve doesn't do anything about it so it's fine for testing purposes.")]
|
||||||
|
[SerializeField] private uint steamAppId = 480;
|
||||||
|
|
||||||
|
[Tooltip("The Steam ID of the user targeted when joining as a client.")]
|
||||||
|
[SerializeField] public ulong targetSteamId;
|
||||||
|
|
||||||
|
[Header("Info")]
|
||||||
|
[ReadOnly]
|
||||||
|
[Tooltip("When in play mode, this will display your Steam ID.")]
|
||||||
|
[SerializeField] private ulong userSteamId;
|
||||||
|
|
||||||
|
private LogLevel LogLevel => NetworkManager.Singleton.LogLevel;
|
||||||
|
|
||||||
|
private class Client {
|
||||||
|
public SteamId steamId;
|
||||||
|
public SocketConnection connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
// #region MonoBehaviour Messages
|
||||||
|
//
|
||||||
|
// private void Awake() {
|
||||||
|
// try {
|
||||||
|
// SteamClient.Init(steamAppId, false);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// if (LogLevel <= LogLevel.Error)
|
||||||
|
// Debug.LogError($"[{nameof(FacepunchTransport)}] - Caught an exeption during initialization of Steam client: {e}");
|
||||||
|
// } finally {
|
||||||
|
// StartCoroutine(InitSteamworks());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private void Update() {
|
||||||
|
// SteamClient.RunCallbacks();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private void OnDestroy() {
|
||||||
|
// SteamClient.Shutdown();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
#region NetworkTransport Overrides
|
||||||
|
|
||||||
|
public override ulong ServerClientId => 0;
|
||||||
|
|
||||||
|
public override void DisconnectLocalClient() {
|
||||||
|
connectionManager?.Connection.Close();
|
||||||
|
|
||||||
|
if (LogLevel <= LogLevel.Developer)
|
||||||
|
Debug.Log($"[{nameof(FacepunchTransport)}] - Disconnecting local client.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DisconnectRemoteClient(ulong clientId) {
|
||||||
|
if (connectedClients.TryGetValue(clientId, out Client user)) {
|
||||||
|
// Flush any pending messages before closing the connection
|
||||||
|
user.connection.Flush();
|
||||||
|
user.connection.Close();
|
||||||
|
connectedClients.Remove(clientId);
|
||||||
|
|
||||||
|
if (LogLevel <= LogLevel.Developer)
|
||||||
|
Debug.Log($"[{nameof(FacepunchTransport)}] - Disconnecting remote client with ID {clientId}.");
|
||||||
|
} else if (LogLevel <= LogLevel.Normal)
|
||||||
|
Debug.LogWarning($"[{nameof(FacepunchTransport)}] - Failed to disconnect remote client with ID {clientId}, client not connected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override unsafe ulong GetCurrentRtt(ulong clientId) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Initialize(NetworkManager networkManager = null) {
|
||||||
|
connectedClients = new Dictionary<ulong, Client>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private SendType NetworkDeliveryToSendType(NetworkDelivery delivery) {
|
||||||
|
return delivery switch {
|
||||||
|
NetworkDelivery.Reliable => SendType.Reliable,
|
||||||
|
NetworkDelivery.ReliableFragmentedSequenced => SendType.Reliable,
|
||||||
|
NetworkDelivery.ReliableSequenced => SendType.Reliable,
|
||||||
|
NetworkDelivery.Unreliable => SendType.Unreliable,
|
||||||
|
NetworkDelivery.UnreliableSequenced => SendType.Unreliable,
|
||||||
|
_ => SendType.Reliable
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Shutdown() {
|
||||||
|
try {
|
||||||
|
if (LogLevel <= LogLevel.Developer)
|
||||||
|
Debug.Log($"[{nameof(FacepunchTransport)}] - Shutting down.");
|
||||||
|
|
||||||
|
connectionManager?.Close();
|
||||||
|
socketManager?.Close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (LogLevel <= LogLevel.Error)
|
||||||
|
Debug.LogError($"[{nameof(FacepunchTransport)}] - Caught an exception while shutting down: {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Send(ulong clientId, ArraySegment<byte> data, NetworkDelivery delivery) {
|
||||||
|
var sendType = NetworkDeliveryToSendType(delivery);
|
||||||
|
|
||||||
|
if (clientId == ServerClientId)
|
||||||
|
connectionManager.Connection.SendMessage(data.Array, data.Offset, data.Count, sendType);
|
||||||
|
else if (connectedClients.TryGetValue(clientId, out Client user))
|
||||||
|
user.connection.SendMessage(data.Array, data.Offset, data.Count, sendType);
|
||||||
|
else if (LogLevel <= LogLevel.Normal)
|
||||||
|
Debug.LogWarning($"[{nameof(FacepunchTransport)}] - Failed to send packet to remote client with ID {clientId}, client not connected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override NetworkEvent PollEvent(out ulong clientId,
|
||||||
|
out ArraySegment<byte> payload,
|
||||||
|
out float receiveTime) {
|
||||||
|
connectionManager?.Receive();
|
||||||
|
socketManager?.Receive();
|
||||||
|
|
||||||
|
clientId = 0;
|
||||||
|
receiveTime = Time.realtimeSinceStartup;
|
||||||
|
payload = default;
|
||||||
|
return NetworkEvent.Nothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool StartClient() {
|
||||||
|
if (LogLevel <= LogLevel.Developer)
|
||||||
|
Debug.Log($"[{nameof(FacepunchTransport)}] - Starting as client.");
|
||||||
|
|
||||||
|
connectionManager = SteamNetworkingSockets.ConnectRelay<ConnectionManager>(targetSteamId);
|
||||||
|
connectionManager.Interface = this;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool StartServer() {
|
||||||
|
if (LogLevel <= LogLevel.Developer)
|
||||||
|
Debug.Log($"[{nameof(FacepunchTransport)}] - Starting as server.");
|
||||||
|
|
||||||
|
socketManager = SteamNetworkingSockets.CreateRelaySocket<SocketManager>();
|
||||||
|
socketManager.Interface = this;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ConnectionManager Implementation
|
||||||
|
|
||||||
|
private byte[] payloadCache = new byte[4096];
|
||||||
|
|
||||||
|
private void EnsurePayloadCapacity(int size) {
|
||||||
|
if (payloadCache.Length >= size)
|
||||||
|
return;
|
||||||
|
|
||||||
|
payloadCache = new byte[Math.Max(payloadCache.Length * 2, size)];
|
||||||
|
}
|
||||||
|
|
||||||
|
void IConnectionManager.OnConnecting(ConnectionInfo info) {
|
||||||
|
if (LogLevel <= LogLevel.Developer)
|
||||||
|
Debug.Log($"[{nameof(FacepunchTransport)}] - Connecting with Steam user {info.Identity.SteamId}.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void IConnectionManager.OnConnected(ConnectionInfo info) {
|
||||||
|
InvokeOnTransportEvent(NetworkEvent.Connect, ServerClientId, default, Time.realtimeSinceStartup);
|
||||||
|
|
||||||
|
if (LogLevel <= LogLevel.Developer)
|
||||||
|
Debug.Log($"[{nameof(FacepunchTransport)}] - Connected with Steam user {info.Identity.SteamId}.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void IConnectionManager.OnDisconnected(ConnectionInfo info) {
|
||||||
|
InvokeOnTransportEvent(NetworkEvent.Disconnect, ServerClientId, default, Time.realtimeSinceStartup);
|
||||||
|
|
||||||
|
if (LogLevel <= LogLevel.Developer)
|
||||||
|
Debug.Log($"[{nameof(FacepunchTransport)}] - Disconnected Steam user {info.Identity.SteamId}.");
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe void IConnectionManager.OnMessage(IntPtr data, int size, long messageNum, long recvTime, int channel) {
|
||||||
|
EnsurePayloadCapacity(size);
|
||||||
|
|
||||||
|
fixed (byte* payload = payloadCache) {
|
||||||
|
UnsafeUtility.MemCpy(payload, (byte*) data, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
InvokeOnTransportEvent(NetworkEvent.Data, ServerClientId, new ArraySegment<byte>(payloadCache, 0, size),
|
||||||
|
Time.realtimeSinceStartup);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SocketManager Implementation
|
||||||
|
|
||||||
|
void ISocketManager.OnConnecting(SocketConnection connection, ConnectionInfo info) {
|
||||||
|
if (LogLevel <= LogLevel.Developer)
|
||||||
|
Debug.Log($"[{nameof(FacepunchTransport)}] - Accepting connection from Steam user {info.Identity.SteamId}.");
|
||||||
|
|
||||||
|
connection.Accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ISocketManager.OnConnected(SocketConnection connection, ConnectionInfo info) {
|
||||||
|
if (!connectedClients.ContainsKey(connection.Id)) {
|
||||||
|
connectedClients.Add(connection.Id, new Client() {
|
||||||
|
connection = connection,
|
||||||
|
steamId = info.Identity.SteamId
|
||||||
|
});
|
||||||
|
|
||||||
|
InvokeOnTransportEvent(NetworkEvent.Connect, connection.Id, default, Time.realtimeSinceStartup);
|
||||||
|
|
||||||
|
if (LogLevel <= LogLevel.Developer)
|
||||||
|
Debug.Log($"[{nameof(FacepunchTransport)}] - Connected with Steam user {info.Identity.SteamId}.");
|
||||||
|
} else if (LogLevel <= LogLevel.Normal)
|
||||||
|
Debug.LogWarning($"[{nameof(FacepunchTransport)}] - Failed to connect client with ID {connection.Id}, client already connected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ISocketManager.OnDisconnected(SocketConnection connection, ConnectionInfo info) {
|
||||||
|
if (connectedClients.Remove(connection.Id)) {
|
||||||
|
InvokeOnTransportEvent(NetworkEvent.Disconnect, connection.Id, default, Time.realtimeSinceStartup);
|
||||||
|
|
||||||
|
if (LogLevel <= LogLevel.Developer)
|
||||||
|
Debug.Log($"[{nameof(FacepunchTransport)}] - Disconnected Steam user {info.Identity.SteamId}");
|
||||||
|
} else if (LogLevel <= LogLevel.Normal)
|
||||||
|
Debug.LogWarning($"[{nameof(FacepunchTransport)}] - Failed to diconnect client with ID {connection.Id}, client not connected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe void ISocketManager.OnMessage(SocketConnection connection,
|
||||||
|
NetIdentity identity,
|
||||||
|
IntPtr data,
|
||||||
|
int size,
|
||||||
|
long messageNum,
|
||||||
|
long recvTime,
|
||||||
|
int channel) {
|
||||||
|
EnsurePayloadCapacity(size);
|
||||||
|
|
||||||
|
fixed (byte* payload = payloadCache) {
|
||||||
|
UnsafeUtility.MemCpy(payload, (byte*) data, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
InvokeOnTransportEvent(NetworkEvent.Data, connection.Id, new ArraySegment<byte>(payloadCache, 0, size),
|
||||||
|
Time.realtimeSinceStartup);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Utility Methods
|
||||||
|
|
||||||
|
private IEnumerator InitSteamworks() {
|
||||||
|
yield return new WaitUntil(() => SteamClient.IsValid);
|
||||||
|
|
||||||
|
SteamNetworkingUtils.InitRelayNetworkAccess();
|
||||||
|
|
||||||
|
if (LogLevel <= LogLevel.Developer)
|
||||||
|
Debug.Log($"[{nameof(FacepunchTransport)}] - Initialized access to Steam Relay Network.");
|
||||||
|
|
||||||
|
userSteamId = SteamClient.SteamId;
|
||||||
|
|
||||||
|
if (LogLevel <= LogLevel.Developer)
|
||||||
|
Debug.Log($"[{nameof(FacepunchTransport)}] - Fetched user Steam ID.");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Runtime/Engine/Code/Steam/FacepunchTransport.cs.meta
Normal file
3
Runtime/Engine/Code/Steam/FacepunchTransport.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 516179f3a4a7476ea24875d52fae3042
|
||||||
|
timeCreated: 1751378412
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
],
|
],
|
||||||
"includePlatforms": [],
|
"includePlatforms": [],
|
||||||
"excludePlatforms": [],
|
"excludePlatforms": [],
|
||||||
"allowUnsafeCode": false,
|
"allowUnsafeCode": true,
|
||||||
"overrideReferences": false,
|
"overrideReferences": false,
|
||||||
"precompiledReferences": [],
|
"precompiledReferences": [],
|
||||||
"autoReferenced": true,
|
"autoReferenced": true,
|
||||||
|
|||||||
@@ -369,6 +369,7 @@ GameObject:
|
|||||||
- component: {fileID: 1456272200}
|
- component: {fileID: 1456272200}
|
||||||
- component: {fileID: 1456272199}
|
- component: {fileID: 1456272199}
|
||||||
- component: {fileID: 1456272198}
|
- component: {fileID: 1456272198}
|
||||||
|
- component: {fileID: 1456272201}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: network
|
m_Name: network
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -420,7 +421,7 @@ MonoBehaviour:
|
|||||||
NetworkManagerExpanded: 0
|
NetworkManagerExpanded: 0
|
||||||
NetworkConfig:
|
NetworkConfig:
|
||||||
ProtocolVersion: 0
|
ProtocolVersion: 0
|
||||||
NetworkTransport: {fileID: 1456272198}
|
NetworkTransport: {fileID: 1456272201}
|
||||||
PlayerPrefab: {fileID: 0}
|
PlayerPrefab: {fileID: 0}
|
||||||
Prefabs:
|
Prefabs:
|
||||||
NetworkPrefabsLists:
|
NetworkPrefabsLists:
|
||||||
@@ -462,6 +463,21 @@ Transform:
|
|||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &1456272201
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1456272197}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 516179f3a4a7476ea24875d52fae3042, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
steamAppId: 480
|
||||||
|
targetSteamId: 0
|
||||||
|
userSteamId: 0
|
||||||
--- !u!1 &1509941943
|
--- !u!1 &1509941943
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -19,3 +19,4 @@ MonoBehaviour:
|
|||||||
m_SubObjectGUID:
|
m_SubObjectGUID:
|
||||||
m_SubObjectType:
|
m_SubObjectType:
|
||||||
m_EditorAssetChanged: 0
|
m_EditorAssetChanged: 0
|
||||||
|
inputActionAsset: {fileID: -944628639613478452, guid: f991e9abd9a53ee4b94b329a5ce96cb2, type: 3}
|
||||||
|
|||||||
Reference in New Issue
Block a user