mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-03-10 16:14:45 +00:00
add latency simulation
This commit is contained in:
parent
52f698ea5c
commit
2d25316637
@ -68,6 +68,7 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart
|
|||||||
|
|
||||||
private (TransportError error, string reason) _lastTransportError = (TransportError.Unexpected, "transport did not give an error. uh oh");
|
private (TransportError error, string reason) _lastTransportError = (TransportError.Unexpected, "transport did not give an error. uh oh");
|
||||||
|
|
||||||
|
private static LatencySimulation _latencyTransport;
|
||||||
private static kcp2k.KcpTransport _kcpTransport;
|
private static kcp2k.KcpTransport _kcpTransport;
|
||||||
private static EosTransport _eosTransport;
|
private static EosTransport _eosTransport;
|
||||||
|
|
||||||
@ -78,6 +79,7 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart
|
|||||||
{
|
{
|
||||||
_kcpTransport = gameObject.AddComponent<kcp2k.KcpTransport>();
|
_kcpTransport = gameObject.AddComponent<kcp2k.KcpTransport>();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// https://dev.epicgames.com/portal/en-US/qsb/sdk/credentials/qsb
|
// https://dev.epicgames.com/portal/en-US/qsb/sdk/credentials/qsb
|
||||||
var eosApiKey = ScriptableObject.CreateInstance<EosApiKey>();
|
var eosApiKey = ScriptableObject.CreateInstance<EosApiKey>();
|
||||||
@ -95,7 +97,16 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart
|
|||||||
|
|
||||||
_eosTransport = gameObject.AddComponent<EosTransport>();
|
_eosTransport = gameObject.AddComponent<EosTransport>();
|
||||||
}
|
}
|
||||||
transport = QSBCore.UseKcpTransport ? _kcpTransport : _eosTransport;
|
|
||||||
|
{
|
||||||
|
_latencyTransport = gameObject.AddComponent<LatencySimulation>();
|
||||||
|
_latencyTransport.reliableLatency = QSBCore.DebugSettings.LatencySimulation;
|
||||||
|
_latencyTransport.wrap = QSBCore.UseKcpTransport ? _kcpTransport : _eosTransport;
|
||||||
|
}
|
||||||
|
|
||||||
|
transport = QSBCore.DebugSettings.LatencySimulation > 0
|
||||||
|
? _latencyTransport
|
||||||
|
: QSBCore.UseKcpTransport ? _kcpTransport : _eosTransport;
|
||||||
|
|
||||||
gameObject.SetActive(true);
|
gameObject.SetActive(true);
|
||||||
|
|
||||||
@ -164,10 +175,20 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (singleton != null)
|
if (singleton != null)
|
||||||
{
|
{
|
||||||
singleton.transport = Transport.active = QSBCore.UseKcpTransport ? _kcpTransport : _eosTransport;
|
if (QSBCore.DebugSettings.LatencySimulation > 0)
|
||||||
|
{
|
||||||
|
_latencyTransport.wrap = QSBCore.UseKcpTransport ? _kcpTransport : _eosTransport;
|
||||||
|
singleton.transport = Transport.active = _latencyTransport;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
singleton.transport = Transport.active = QSBCore.UseKcpTransport ? _kcpTransport : _eosTransport;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MenuManager.Instance != null)
|
if (MenuManager.Instance != null)
|
||||||
{
|
{
|
||||||
MenuManager.Instance.OnLanguageChanged(); // hack to update text
|
MenuManager.Instance.OnLanguageChanged(); // hack to update text
|
||||||
|
@ -26,6 +26,9 @@ public class DebugSettings
|
|||||||
[JsonProperty("disableLoopDeath")]
|
[JsonProperty("disableLoopDeath")]
|
||||||
public bool DisableLoopDeath;
|
public bool DisableLoopDeath;
|
||||||
|
|
||||||
|
[JsonProperty("latencySimulation")]
|
||||||
|
public int LatencySimulation;
|
||||||
|
|
||||||
[JsonProperty("debugMode")]
|
[JsonProperty("debugMode")]
|
||||||
public bool DebugMode;
|
public bool DebugMode;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user