Reactors, sonars, nav terminals, pumps and batteries use similar delayed correction logic as doors and inventories.

I.e. the clients delay correcting the state of the item until the local player stops manipulating the state (atm the delay is 1 sec). Prevents pumping speeds, steering directions and whatnot from switching to an old state and back - now the corrections should not be visible to the players unless the client predicts the state wrong.
This commit is contained in:
Regalis
2017-04-11 00:41:12 +03:00
parent fac31b4892
commit 347f549ac1
8 changed files with 114 additions and 25 deletions
+16 -1
View File
@@ -1,4 +1,5 @@
using Microsoft.Xna.Framework;
using Lidgren.Network;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Globalization;
@@ -593,5 +594,19 @@ namespace Barotrauma
return "";
}
}
/// <summary>
/// Reads a number of bits from the buffer and inserts them to a new NetBuffer instance
/// </summary>
public static NetBuffer ExtractBits(this NetBuffer originalBuffer, int numberOfBits)
{
var buffer = new NetBuffer();
byte[] data = new byte[(int)Math.Ceiling(numberOfBits / (double)8)];
originalBuffer.ReadBits(data, 0, numberOfBits);
buffer.Write(data);
return buffer;
}
}
}