public static FullStatePlayer Read(NetIncomingMessage msg) { var fs = new FullStatePlayer(); fs.GameSpectatorFlagSet = msg.ReadBoolean(); fs.PlayerWantsToBeSpectator = msg.ReadBoolean(); fs.IsAdmin = msg.ReadBoolean(); fs.IsPremium = msg.ReadBoolean(); fs.IsReady = msg.ReadBoolean(); fs.TankHasCustomStyle = msg.ReadBoolean(); fs.HasTank = msg.ReadBoolean(); fs.HasSelectedTank = msg.ReadBoolean(); if (fs.HasTank) { fs.TankObjectId = msg.ReadUInt16(); } fs.Username = msg.ReadString(); fs.Id = (ushort)msg.ReadUInt32(GameCore.PlayerIdNumberOfBits); fs.UniqueId = new Guid(msg.ReadBytes(16)); fs.TeamId = msg.ReadInt16(); fs.SpawnPoint = new Vector2(msg.ReadFloat(), msg.ReadFloat()); if (fs.HasSelectedTank) { fs.TankReflectionName = msg.ReadString(); } var allowedTankTypes = new string[msg.ReadInt32()]; for (var i = 0; i < allowedTankTypes.Length; i++) { allowedTankTypes[i] = msg.ReadString(); } var input = new InputState(); input.FirePressed = msg.ReadBoolean(); input.LookDirection = msg.ReadFloat(); input.MovementSpeed = msg.ReadFloat(); input.RotationSpeed = msg.ReadFloat(); input.WeaponNumber = msg.ReadByte(); fs.Input = input; return(fs); }
public static FullGameState Read(NetIncomingMessage message) { var state = new FullGameState(); state.MapInfo = ModAssetInfo.Decode(message.ReadBytes(message.ReadUInt16())); state.GamemodeReflectionName = message.ReadString(); state.FriendlyFireEnabled = message.ReadBoolean(); state.HasStarted = message.ReadBoolean(); message.ReadPadBits(); state.GamemodeState = message.ReadBytes(message.ReadInt32()); state.Status = (GameCore.CurrentGameStatus)message.ReadByte(); state.TimescaleString = message.ReadString(); state.TimescaleValue = message.ReadDouble(); state.CurrentGameTimeMilliseconds = message.ReadDouble(); state.NextObjectId = message.ReadUInt16(); state.GameEndedTime = message.ReadDouble(); var objCount = message.ReadInt32(); for (var i = 0; i < objCount; i++) { state.ObjectStates.Add(new FullObjectState(message.ReadBytes(message.ReadInt32()))); } var playersCount = message.ReadInt32(); for (var i = 0; i < playersCount; i++) { state.Players.Add(FullStatePlayer.Read(message)); } var loadedModCount = message.ReadInt32(); for (var i = 0; i < loadedModCount; i++) { state.GameLoadedMods.Add(ModInfo.Decode(message.ReadBytes(message.ReadUInt16()))); } return(state); }