public void Deserialize(BitStream message, UserCommand?old) { if (old == null) { ServerTime = message.ReadUInt32(); Buttons = (ClientButtons)message.ReadInt16(); } else { var oldCommand = old.Value; // read server time if (message.ReadBool()) { // is delta time ServerTime = oldCommand.ServerTime + message.ReadByte(); } else { // is absolute time ServerTime = message.ReadUInt32(); } // read buttons Buttons = (ClientButtons)message.ReadDeltaInt16((short)oldCommand.Buttons); } }
public bool TestButton(ClientButtons button) { return((Buttons & button) == button); }