Example #1
0
        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);
            }
        }
Example #2
0
 public bool TestButton(ClientButtons button)
 {
     return((Buttons & button) == button);
 }