namespace Sandbox; /// /// A User Command that will be sent to the current host every tick. /// internal struct UserCommand( uint commandNumber ) { private static uint s_nextAvailableCommandNumber = 1; /// /// The command number of this . /// public uint CommandNumber { get; private set; } = commandNumber; /// /// Which actions are currently being held down. /// public ulong Actions; /// /// Serialize this to the specified . /// internal void Serialize( ref ByteStream bs ) { bs.Write( CommandNumber ); bs.Write( Actions ); } /// /// Deserialize this from specified . /// internal void Deserialize( ref ByteStream bs ) { CommandNumber = bs.Read(); Actions = bs.Read(); } /// /// Reset the next available command number back to zero. /// internal static void Reset() { s_nextAvailableCommandNumber = 1; } /// /// Create a new with the next available command number. /// /// public static UserCommand Create() { return new UserCommand( s_nextAvailableCommandNumber++ ); } }