protected override void Deserialize(NetworkBinaryReader reader)
 {
     int count = reader.ReadByte();
     int totalByteCount = reader.ReadUInt16();
     _ids.Clear();
     for (int i = 0; i < count; i++) _ids.Add(reader.ReadByte());
     StreamedData = reader.ReadBytes(totalByteCount);
 }
 protected override void Deserialize(NetworkBinaryReader reader)
 {
     base.Deserialize(reader);
     ArenaID = reader.ReadByte();
     int gobCount = reader.ReadInt16();
     _layerIndices = new List<int>(gobCount);
     _gobTypeNames = new List<CanonicalString>(gobCount);
     for (int i = 0; i < gobCount; ++i) _layerIndices.Add(reader.ReadByte());
     for (int i = 0; i < gobCount; ++i) _gobTypeNames.Add(reader.ReadCanonicalString());
     int byteCount = reader.ReadUInt16();
     StreamedData = reader.ReadBytes(byteCount);
 }
 protected override void Deserialize(NetworkBinaryReader reader)
 {
     base.Deserialize(reader);
     PlayerID = reader.ReadByte();
     for (int i = 0; i < PlayerControls.CONTROL_COUNT; ++i)
     {
         var value = reader.ReadByte();
         var force = (value & 0x7f) / 127f;
         var pulse = (value & 0x80) != 0;
         ControlStates[i] = new ControlState(force, pulse);
     }
 }
Example #4
0
 protected override void Deserialize(NetworkBinaryReader reader)
 {
     GameplayMode = reader.ReadCanonicalString();
     ArenaID = reader.ReadByte();
     ArenaToPlay = reader.ReadString();
     ArenaTimeLeft = reader.ReadTimeSpan();
     WallCount = reader.ReadInt32();
 }
 protected override void Deserialize(NetworkBinaryReader reader)
 {
     base.Deserialize(reader);
     var idCount = reader.ReadByte();
     GobIDs.Clear();
     GobIDs.Capacity = idCount;
     for (int i = 0; i < idCount; i++) GobIDs.Add(reader.ReadInt16());
 }
 protected override void Deserialize(NetworkBinaryReader reader)
 {
     SpectatorLocalID = reader.ReadByte();
     SpectatorID = reader.ReadByte();
     FailMessage = reader.ReadString();
 }
Example #7
0
 protected override void Deserialize(NetworkBinaryReader reader)
 {
     base.Deserialize(reader);
     var gobCount = reader.ReadByte();
     _collisionEventCount = reader.ReadByte();
     var totalByteCount = reader.ReadUInt16();
     _gobIds.Clear();
     for (int i = 0; i < gobCount; i++) _gobIds.Add(reader.ReadInt16());
     StreamedData = reader.ReadBytes(totalByteCount);
 }
Example #8
0
        public override void Deserialize(NetworkBinaryReader reader, SerializationModeFlags mode, int framesAgo)
        {
            var oldRotation = Rotation;
            base.Deserialize(reader, mode, framesAgo);
            if (Owner != null) Owner.SeizeShip(this);

            // Client alone decides on the rotation of his own ship.
            if (LocationPredicter == null)
            {
                if (!float.IsNaN(oldRotation)) Rotation = oldRotation;
                DrawRotationOffset = 0;
            }

            // HACK to avoid null references:
            //   - ForwardShot using Ship.Model before LoadContent() is called
            //   - Thrust() using _thrusterSound before Activate() is called
            var shipMode = mode.HasFlag(SerializationModeFlags.ConstantDataFromServer)
                ? mode & ~SerializationModeFlags.VaryingDataFromServer
                : mode;

            if (shipMode.HasFlag(SerializationModeFlags.VaryingDataFromServer))
            {
                var visualThrustForceAndFlags = reader.ReadByte();
                _visualThrustForce = (visualThrustForceAndFlags & 0x7f) / 127f;
                var updateDeviceTypes = (visualThrustForceAndFlags & 0x80) != 0;
                Action<ShipDevice> deserializeDevice = device =>
                {
                    var data = reader.ReadByte();
                    if (device == null) return;
                    device.Charge = data * device.ChargeMax / byte.MaxValue;
                    if (!updateDeviceTypes) return;
                    var deviceTypeName = reader.ReadCanonicalString();
                    if (deviceTypeName != device.TypeName) SetDeviceType(device.OwnerHandle, deviceTypeName);
                };
                deserializeDevice(Weapon1);
                deserializeDevice(Weapon2);
                deserializeDevice(ExtraDevice);
                DeviceUsagesToClients.Deserialize(reader, mode, framesAgo);
                ApplyDeviceUsages(DeviceUsagesToClients);
                DeviceUsagesToClients.Clear();
            }
            if (shipMode.HasFlag(SerializationModeFlags.VaryingDataFromClient))
            {
                var rotationByte = reader.ReadByte();
                Rotation = rotationByte * MathHelper.TwoPi / (byte.MaxValue + 1);
            }
        }
Example #9
0
 public override void Deserialize(NetworkBinaryReader reader, SerializationModeFlags mode, int framesAgo)
 {
     var reducedMode = mode.HasFlag(SerializationModeFlags.ConstantDataFromServer)
         ? SerializationModeFlags.AllFromServer
         : SerializationModeFlags.None;
     base.Deserialize(reader, reducedMode, framesAgo);
     if (mode.HasFlag(SerializationModeFlags.VaryingDataFromServer))
     {
         var repairingCount = reader.ReadByte();
         _repairingGobsOnClient.Clear();
         for (int i = 0; i < repairingCount; i++)
         {
             var proxy = new LazyProxy<int, Gob>(FindGob);
             proxy.SetData(reader.ReadInt16());
             _repairingGobsOnClient.Add(proxy);
         }
     }
 }
Example #10
0
 public override void Deserialize(NetworkBinaryReader reader, SerializationModeFlags mode, int framesAgo)
 {
     base.Deserialize(reader, mode, framesAgo);
     if ((mode & SerializationModeFlags.ConstantDataFromServer) != 0)
     {
         _spawnInterval = reader.ReadSingle();
         int spawnTypesCount = reader.ReadByte();
         _spawnTypes = new SpawnType[spawnTypesCount];
         for (int i = 0; i < spawnTypesCount; ++i)
             _spawnTypes[i].Deserialize(reader, SerializationModeFlags.ConstantDataFromServer, framesAgo);
     }
 }
Example #11
0
 public override void Deserialize(NetworkBinaryReader reader, SerializationModeFlags mode, int framesAgo)
 {
     base.Deserialize(reader, mode, framesAgo);
     if ((mode & SerializationModeFlags.ConstantDataFromServer) != 0)
     {
         ModelName = wallModelName = reader.ReadCanonicalString();
         int collisionAreaCount = reader.ReadByte();
         _collisionAreas = wallCollisionAreas = new CollisionArea[collisionAreaCount];
         for (int i = 0; i < collisionAreaCount; ++i)
         {
             wallCollisionAreas[i] = new CollisionArea();
             wallCollisionAreas[i].Deserialize(reader, SerializationModeFlags.AllFromServer, framesAgo);
         }
         foreach (var area in wallCollisionAreas) area.Owner = this;
     }
 }
 protected override void Deserialize(NetworkBinaryReader reader)
 {
     IsRegisteredToServer = reader.ReadBoolean();
     IsRequestingSpawnForArenaID = reader.ReadNullableByte();
     IsGameClientReadyToStartArena = reader.ReadBoolean();
     SpectatorID = reader.ReadByte();
     Subclass = (SubclassType)reader.ReadByte();
     if (!Enum.IsDefined(typeof(SubclassType), Subclass)) throw new NetworkException("Invalid value for Subclass, " + Subclass);
     int byteCount = reader.ReadUInt16();
     StreamedData = reader.ReadBytes(byteCount);
 }
Example #13
0
 public void Deserialize(NetworkBinaryReader reader, SerializationModeFlags mode, int framesAgo)
 {
     if ((mode & SerializationModeFlags.ConstantDataFromServer) != 0)
     {
         _type = (CollisionAreaType)reader.ReadInt32();
         _name = reader.ReadString();
         _collisionMaterial = (CollisionMaterialType)reader.ReadByte();
         _area.Deserialize(reader, SerializationModeFlags.AllFromServer, framesAgo);
     }
 }
Example #14
0
 public override void Deserialize(NetworkBinaryReader reader, SerializationModeFlags mode, int framesAgo)
 {
     // Note: Gob.{Pos,Rotation,Move,RotationSpeed} are computed from Host
     // and don't need to be serialized except at birth.
     var baseSerializationMode = mode.HasFlag(SerializationModeFlags.ConstantDataFromServer)
         ? mode
         : mode & ~SerializationModeFlags.VaryingDataFromServer;
     base.Deserialize(reader, baseSerializationMode, framesAgo);
     if (mode.HasFlag(SerializationModeFlags.ConstantDataFromServer))
     {
         int hostID = reader.ReadInt16();
         _hostProxy = new LazyProxy<int, Gob>(FindGob);
         _hostProxy.SetData(hostID);
         HostBoneIndex = reader.ReadByte();
     }
     if (mode.HasFlag(SerializationModeFlags.VaryingDataFromServer))
     {
         int wallPunchCount = reader.ReadByte();
         var punchedPoses = new List<Vector2>(wallPunchCount);
         for (int i = 0; i < wallPunchCount; i++) punchedPoses.Add(reader.ReadHalfVector2());
         foreach (var pos in punchedPoses) GobHelper.CreateGobs(_wallPunchEffects, Arena, pos);
         PlayWallHitSound(punchedPoses);
     }
 }
Example #15
0
 public void Deserialize(NetworkBinaryReader reader, SerializationModeFlags serializationMode, int framesAgo)
 {
     // Note: Deserialize all regardless of serializationMode.
     Gob1ID = reader.ReadInt16();
     Gob2ID = reader.ReadInt16();
     var mixedData = reader.ReadByte();
     Area1ID = mixedData & 0x03;
     Area2ID = (mixedData >> 2) & 0x03;
     CollisionSound = (CollisionSoundType)((mixedData >> 4) & 0x03);
 }
Example #16
0
 public override void Deserialize(NetworkBinaryReader reader, SerializationModeFlags mode, int framesAgo)
 {
     base.Deserialize(reader, mode, framesAgo);
     if (mode.HasFlag(SerializationModeFlags.ConstantDataFromServer))
     {
         Shooter = new LazyProxy<int, Gob>(FindGob);
         Target = new LazyProxy<int, Gob>(FindGob);
         Shooter.SetData(reader.ReadInt16());
         ShooterBoneIndex = reader.ReadByte();
         int targetID = reader.ReadInt16();
         if (targetID != 0) Target.SetData(targetID);
         ChainIndex = reader.ReadByte();
     }
 }