NetworkServer.sendInterval calculated separately so it's easier to change sendRate later

This commit is contained in:
vis2k 2022-10-13 10:49:07 +02:00
parent 1433bb7993
commit 90028b43ea

View File

@ -22,14 +22,13 @@ public static partial class NetworkServer
// send interval is 1 / sendRate.
// but for tests we need a way to set it to exactly 0.
// 1 / int.max would not be exactly 0, so handel that manually.
public static float tickInterval =>
tickRate < int.MaxValue ? 1f / tickRate : 0; // for 30 Hz, that's 33ms
public static float tickInterval => tickRate < int.MaxValue ? 1f / tickRate : 0; // for 30 Hz, that's 33ms
// broadcast() runs every tick.
// -> components are only synced when dirty though
// -> Timesnapshots are sent every sendRate
public static int sendRate => tickRate;
public static float sendInterval => tickInterval;
public static float sendInterval => sendRate < int.MaxValue ? 1f / sendRate : 0; // for 30 Hz, that's 33ms
static double lastSendTime;
/// <summary>Connection to host mode client (if any)</summary>