mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 19:10:32 +00:00
fix(LatencySimulation): implement PortTransport since almost all underlying Transports are PortTransports (#3830)
* fix(LatencySimulation): implement PortTransport since almost all underlying Transports are PortTransports * Update Assets/Mirror/Transports/Latency/LatencySimulation.cs Co-authored-by: MrGadget <9826063+MrGadget1024@users.noreply.github.com> * Update Assets/Mirror/Transports/Latency/LatencySimulation.cs Co-authored-by: MrGadget <9826063+MrGadget1024@users.noreply.github.com> --------- Co-authored-by: mischa <16416509+vis2k@users.noreply.github.com> Co-authored-by: MrGadget <9826063+MrGadget1024@users.noreply.github.com>
This commit is contained in:
parent
2d97adeaf5
commit
f51b7878f6
@ -22,10 +22,34 @@ struct QueuedMessage
|
||||
|
||||
[HelpURL("https://mirror-networking.gitbook.io/docs/transports/latency-simulaton-transport")]
|
||||
[DisallowMultipleComponent]
|
||||
public class LatencySimulation : Transport
|
||||
public class LatencySimulation : Transport, PortTransport
|
||||
{
|
||||
public Transport wrap;
|
||||
|
||||
// implement PortTransport in case the underlying Tranpsport is a PortTransport too.
|
||||
// otherwise gameplay code like 'if Transport is PortTransport' would completely break with Latency Simulation.
|
||||
public ushort Port
|
||||
{
|
||||
get
|
||||
{
|
||||
if (wrap is PortTransport port)
|
||||
return port.Port;
|
||||
|
||||
Debug.LogWarning($"LatencySimulation: attempted to get Port but {wrap} is not a PortTransport.");
|
||||
return 0;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (wrap is PortTransport port)
|
||||
{
|
||||
port.Port = value;
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.LogWarning($"LatencySimulation: attempted to set Port but {wrap} is not a PortTransport.");
|
||||
}
|
||||
}
|
||||
|
||||
[Header("Common")]
|
||||
// latency always needs to be applied to both channels!
|
||||
// fixes a bug in prediction where predictedTime would have no latency, but [Command]s would have 100ms latency resulting in heavy, hard to debug jittering!
|
||||
|
Loading…
Reference in New Issue
Block a user