Example #1
0
 protected override void Deserialize(NetworkBinaryReader reader)
 {
     GameplayMode = reader.ReadCanonicalString();
     ArenaID = reader.ReadByte();
     ArenaToPlay = reader.ReadString();
     ArenaTimeLeft = reader.ReadTimeSpan();
     WallCount = reader.ReadInt32();
 }
Example #2
0
 public void Deserialize(NetworkBinaryReader reader, SerializationModeFlags mode, int framesAgo)
 {
     if ((mode & SerializationModeFlags.ConstantDataFromServer) != 0)
     {
         weight = reader.ReadSingle();
         spawnTypeName = reader.ReadCanonicalString();
     }
 }
Example #3
0
 public override void Deserialize(NetworkBinaryReader reader, SerializationModeFlags mode, int framesAgo)
 {
     base.Deserialize(reader, mode, framesAgo);
     if (mode.HasFlag(SerializationModeFlags.ConstantDataFromServer))
     {
         _propModelName = reader.ReadCanonicalString();
         ModelName = _propModelName;
     }
 }
Example #4
0
 public override void Deserialize(NetworkBinaryReader reader, SerializationModeFlags mode, int framesAgo)
 {
     base.Deserialize(reader, mode, framesAgo);
     if ((mode & SerializationModeFlags.ConstantDataFromServer) != 0)
     {
         _wallModelName = reader.ReadCanonicalString();
         var model = Game.Content.Load<Model>(_wallModelName);
         Effect = GetEffect(model);
         Texture = GetTexture(model);
     }
 }
 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);
 }
Example #6
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 #7
0
 public override void Deserialize(NetworkBinaryReader reader, SerializationModeFlags mode, int framesAgo)
 {
     base.Deserialize(reader, mode, framesAgo);
     if (mode.HasFlag(SerializationModeFlags.ConstantDataFromServer) ||
         mode.HasFlag(SerializationModeFlags.ConstantDataFromClient))
     {
         var newShipName = reader.ReadCanonicalString();
         var newWeapon2Name = reader.ReadCanonicalString();
         var newExtraDeviceName = reader.ReadCanonicalString();
         if (Game.DataEngine.GetTypeTemplate(newShipName) is Ship) ShipName = newShipName;
         if (Game.DataEngine.GetTypeTemplate(newWeapon2Name) is Weapon) Weapon2Name = newWeapon2Name;
         if (Game.DataEngine.GetTypeTemplate(newExtraDeviceName) is ShipDevice) ExtraDeviceName = newExtraDeviceName;
     }
 }
Example #8
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)
 {
     ArenaToPlay = reader.ReadString();
     GameplayMode = reader.ReadCanonicalString();
 }
Example #10
0
 public override void Deserialize(NetworkBinaryReader reader, SerializationModeFlags mode, int framesAgo)
 {
     base.Deserialize(reader, mode, framesAgo);
     if ((mode & SerializationModeFlags.ConstantDataFromServer) != 0)
     {
         IconName = reader.ReadCanonicalString();
         DrawColor = reader.ReadColor();
         Message = reader.ReadString();
     }
 }