Esempio n. 1
0
        public void TestDoubles(double weird)
        {
            writer.WriteDouble(weird);
            reader.Reset(writer.ToArraySegment());
            double readDouble = reader.ReadDouble();

            Assert.That(readDouble, Is.EqualTo(weird));
        }
Esempio n. 2
0
 public static EntityEquipableAbilityResourcesInfluences ReadEntityEquipableAbilityResourcesInfluences(this NetworkReader reader)
 {
     return(new EntityEquipableAbilityResourcesInfluences(
                reader.ReadAbilitiesResourcesInfluenceData(),
                reader.ReadBoolean(),
                (float)reader.ReadDouble(),
                reader.ReadBoolean(),
                (float)reader.ReadDouble()));
 }
Esempio n. 3
0
 public static AbilityTriggerData ReadAbilityTriggerData(this NetworkReader reader)
 {
     return(new AbilityTriggerData(
                (AbilityTriggerMethod)reader.ReadInt32(),
                (float)reader.ReadDouble(),
                reader.ReadInt32(),
                (float)reader.ReadDouble(),
                reader.ReadInt32()));
 }
Esempio n. 4
0
        public static StatsInfluenceData.StatsInfluence ReadStatsInfluence(this NetworkReader reader)
        {
            StatsInfluenceData.StatsInfluence stat = new StatsInfluenceData.StatsInfluence(
                null,
                (float)reader.ReadDouble(),
                (float)reader.ReadDouble()
                );

            return(stat);
        }
 public override void Deserialize(int _senderID, byte[] _data, int _receivedBytes)
 {
     base.Deserialize(_senderID, _data, _receivedBytes);
     using (MemoryStream ms = new MemoryStream(_data, 0, _receivedBytes))
     {
         using (NetworkReader nr = new NetworkReader(ms))
         {
             nr.ReadInt16();
             GameObject = nr.ReadGameObject();
             Speed      = (float)nr.ReadDouble();
             Accel      = (float)nr.ReadDouble();
             Item       = (float)nr.ReadDouble();
         }
     }
 }
Esempio n. 6
0
        private static void HandleTimeScale(NetworkMessage netMsg)
        {
            NetworkReader reader = netMsg.reader;

            Time.timeScale = (float)reader.ReadDouble();
            Log.Message("Network request for timescale.");
        }
Esempio n. 7
0
        public static EntityEquipableAbility ReadEntityEquipableAbility(this NetworkReader reader)
        {
            AbilityData        ability         = (AbilityData)PinouApp.Resources.Data.Databases.GetItem(DatabaseType.Ability, reader.ReadInt32());
            bool               overrideTrigger = reader.ReadBoolean();
            AbilityTriggerData triggerData     = null;

            if (overrideTrigger)
            {
                triggerData = reader.ReadAbilityTriggerData();
            }
            bool  overrideCooldown = reader.ReadBoolean();
            float cooldown         = 0f;

            if (overrideCooldown)
            {
                cooldown = (float)reader.ReadDouble();
            }

            int abilitiesResourcesInfluencesLength = reader.ReadInt32();

            EntityEquipableAbilityResourcesInfluences[] abilitiesResourcesInfluences = new EntityEquipableAbilityResourcesInfluences[abilitiesResourcesInfluencesLength];
            for (int i = 0; i < abilitiesResourcesInfluencesLength; i++)
            {
                abilitiesResourcesInfluences[i] = reader.ReadEntityEquipableAbilityResourcesInfluences();
            }

            return(new EntityEquipableAbility(
                       ability,
                       overrideTrigger,
                       triggerData,
                       overrideCooldown,
                       cooldown,
                       abilitiesResourcesInfluences));
        }
        public void TestWritingAndReading()
        {
            // write all simple types once
            NetworkWriter writer = new NetworkWriter();

            writer.Write((char)1);
            writer.Write((byte)2);
            writer.Write((sbyte)3);
            writer.Write((bool)true);
            writer.Write((short)4);
            writer.Write((ushort)5);
            writer.Write((int)6);
            writer.Write((uint)7);
            writer.Write((long)8L);
            writer.Write((ulong)9L);
            writer.Write((float)10);
            writer.Write((double)11);
            writer.Write((decimal)12);
            writer.Write((string)null);
            writer.Write((string)"");
            writer.Write((string)"13");
            writer.Write(new byte[] { 14, 15 }, 0, 2);                 // just the byte array, no size info etc.
            writer.WriteBytesAndSize((byte[])null);                    // [SyncVar] struct values can have uninitialized byte arrays, null needs to be supported
            writer.WriteBytesAndSize(new byte[] { 17, 18 }, 0, 2);     // buffer, no-offset, count
            writer.WriteBytesAndSize(new byte[] { 19, 20, 21 }, 1, 2); // buffer, offset, count
            writer.WriteBytesAndSize(new byte[] { 22, 23 }, 0, 2);     // size, buffer

            byte[] data = writer.ToArray();


            // read them
            NetworkReader reader = new NetworkReader(writer.ToArray());

            Assert.That(reader.ReadChar(), Is.EqualTo(1));
            Assert.That(reader.ReadByte(), Is.EqualTo(2));
            Assert.That(reader.ReadSByte(), Is.EqualTo(3));
            Assert.That(reader.ReadBoolean(), Is.True);
            Assert.That(reader.ReadInt16(), Is.EqualTo(4));
            Assert.That(reader.ReadUInt16(), Is.EqualTo(5));
            Assert.That(reader.ReadInt32(), Is.EqualTo(6));
            Assert.That(reader.ReadUInt32(), Is.EqualTo(7));
            Assert.That(reader.ReadInt64(), Is.EqualTo(8));
            Assert.That(reader.ReadUInt64(), Is.EqualTo(9));
            Assert.That(reader.ReadSingle(), Is.EqualTo(10));
            Assert.That(reader.ReadDouble(), Is.EqualTo(11));
            Assert.That(reader.ReadDecimal(), Is.EqualTo(12));
            Assert.That(reader.ReadString(), Is.Null); // writing null string should write null in HLAPI Pro ("" in original HLAPI)
            Assert.That(reader.ReadString(), Is.EqualTo(""));
            Assert.That(reader.ReadString(), Is.EqualTo("13"));

            Assert.That(reader.ReadBytes(2), Is.EqualTo(new byte[] { 14, 15 }));

            Assert.That(reader.ReadBytesAndSize(), Is.Null);

            Assert.That(reader.ReadBytesAndSize(), Is.EqualTo(new byte[] { 17, 18 }));

            Assert.That(reader.ReadBytesAndSize(), Is.EqualTo(new byte[] { 20, 21 }));

            Assert.That(reader.ReadBytesAndSize(), Is.EqualTo(new byte[] { 22, 23 }));
        }
    public void WriteAndReadDouble(double testValue)
    {
        writer.Write(testValue);
        var reader = new NetworkReader(writer);

        Assert.AreEqual(testValue, reader.ReadDouble(), "Writer and Reader have different values for 'double' type");
    }
Esempio n. 10
0
        public void TestDoubles(double weird)
        {
            writer.WriteDouble(weird);
            var    reader     = new NetworkReader(writer.ToArray());
            double readDouble = reader.ReadDouble();

            Assert.That(readDouble, Is.EqualTo(weird));
        }
Esempio n. 11
0
 public override void Deserialize(NetworkReader reader)
 {
     this.trueHeading     = reader.ReadSingle();
     this.timestamp       = reader.ReadDouble();
     this.magneticHeading = reader.ReadSingle();
     this.headingAccuracy = reader.ReadSingle();
     this.rawVector       = reader.ReadVector3();
 }
        public static AbilityResourceImpactData ReadAbilityResourceImpactData(this NetworkReader reader)
        {
            AbilityResourceImpactData impactData = new AbilityResourceImpactData(
                (EntityBeingResourceType)reader.ReadInt32(),
                (float)reader.ReadDouble());

            return(impactData);
        }
        public static UserInput ReadDateTime(this NetworkReader reader)
        {
            UserInput ui = new UserInput(
                reader.ReadDouble(),  //NetworkTime.
                reader.ReadVector3(), //Position.
                reader.ReadVector3(), //Rotation.
                reader.ReadVector2(), //MoveDirection.
                reader.ReadSingle()
                );

            return(ui);
        }
Esempio n. 14
0
        public void TestWriteDouble()
        {
            double somenumber       = Math.PI;
            var    outNetworkBuffer = new NetworkBuffer();
            var    outNetworkWriter = new NetworkWriter(outNetworkBuffer);

            outNetworkWriter.WriteDouble(somenumber);
            var outBuffer = outNetworkBuffer.GetBuffer();

            var inNetworkBuffer = new NetworkBuffer(outBuffer);
            var inNetworkReader = new NetworkReader(inNetworkBuffer);

            Assert.That(inNetworkReader.ReadDouble(), Is.EqualTo(somenumber));
        }
Esempio n. 15
0
 public static PBS.Battle.View.Events.PokemonMoveHitTarget ReadBattleViewEventPokemonMoveHitTarget(this NetworkReader reader)
 {
     return(new PBS.Battle.View.Events.PokemonMoveHitTarget
     {
         pokemonUniqueID = reader.ReadString(),
         affectedByMove = reader.ReadBoolean(),
         missed = reader.ReadBoolean(),
         criticalHit = reader.ReadBoolean(),
         preHP = reader.ReadInt32(),
         postHP = reader.ReadInt32(),
         maxHP = reader.ReadInt32(),
         damageDealt = reader.ReadInt32(),
         effectiveness = (float)reader.ReadDouble()
     });
 }
Esempio n. 16
0
 public static PBS.Battle.View.Events.CommandAgent.Moveslot ReadBattleViewEventCommandAgentMoveslot(this NetworkReader reader)
 {
     return(new PBS.Battle.View.Events.CommandAgent.Moveslot
     {
         moveID = reader.ReadString(),
         PP = reader.ReadInt32(),
         maxPP = reader.ReadInt32(),
         basePower = reader.ReadInt32(),
         accuracy = (float)reader.ReadDouble(),
         hide = reader.ReadBoolean(),
         useable = reader.ReadBoolean(),
         failMessageCode = reader.ReadString(),
         possibleTargets = reader.ReadList <List <BattlePosition> >()
     });
 }
Esempio n. 17
0
        // Token: 0x06001CE2 RID: 7394 RVA: 0x00086950 File Offset: 0x00084B50
        public void Read(NetworkReader reader)
        {
            StatDataType dataType = this.dataType;

            if (dataType == StatDataType.ULong)
            {
                this.ulongValue = reader.ReadPackedUInt64();
                return;
            }
            if (dataType != StatDataType.Double)
            {
                throw new ArgumentOutOfRangeException();
            }
            this.doubleValue = reader.ReadDouble();
        }
Esempio n. 18
0
 // This method would be generated
 public override void Deserialize(NetworkReader reader)
 {
     keySend = reader.ReadBoolean();
     if (keySend)
     {
         down = reader.ReadBoolean();
         key  = reader.ReadInt32();
     }
     else
     {
         axisY = (float)reader.ReadDouble();
     }
     index    = reader.ReadInt32();
     login    = reader.ReadString();
     password = reader.ReadString();
 }
 // Token: 0x06001E77 RID: 7799 RVA: 0x0008FD40 File Offset: 0x0008DF40
 public override void Deserialize(NetworkReader reader)
 {
     this.sendTime         = reader.ReadDouble();
     this.prefabIndex      = (byte)reader.ReadPackedUInt32();
     this.position         = reader.ReadVector3();
     this.rotation         = reader.ReadQuaternion();
     this.owner            = reader.ReadGameObject();
     this.target           = GeneratedNetworkCode._ReadHurtBoxReference_None(reader);
     this.damage           = reader.ReadSingle();
     this.force            = reader.ReadSingle();
     this.crit             = reader.ReadBoolean();
     this.predictionId     = (ushort)reader.ReadPackedUInt32();
     this.damageColorIndex = (DamageColorIndex)reader.ReadInt32();
     this.speedOverride    = reader.ReadSingle();
     this.fuseOverride     = reader.ReadSingle();
 }
        public override void OnDeserialize(NetworkReader reader, bool initialState)
        {
            base.OnDeserialize(reader, initialState);

            if (initialState)
            {
                this.SetTime((float)reader.ReadDouble());

                if (reader.ReadBoolean())
                {
                    this.StartTimer();
                }
                else
                {
                    this.StopTimer();
                }
            }
        }
    public override void Deserialize(NetworkReader reader)
    {
        //Get the no of inputs received
        int count = reader.ReadInt32();

        //Prepaare list
        if (inputsList != null)
        {
            inputsList.Clear();           //Detatch prev elements
        }
        inputsList = new List <Inputs>(); //Detatch prev mem

        //Build all inputs
        for (int i = 0; i < count; i++)
        {
            //Create
            Inputs input = new Inputs();

            //Deserialize individually
            input.crouch    = reader.ReadBoolean();
            input.jump      = reader.ReadBoolean();
            input.move      = reader.ReadBoolean();
            input.pitch     = reader.ReadSingle();
            input.rotate    = reader.ReadBoolean();
            input.timeStamp = reader.ReadDouble();
            input.walk      = reader.ReadBoolean();
            bool[] wasd = new bool[4];
            wasd[0]    = reader.ReadBoolean();
            wasd[1]    = reader.ReadBoolean();
            wasd[2]    = reader.ReadBoolean();
            wasd[3]    = reader.ReadBoolean();
            input.wasd = wasd;
            input.yaw  = reader.ReadSingle();

            //Add to the message list
            inputsList.Add(input);

            //Check if is the last input and register stamp
            if (i == count - 1)
            {
                stamp = input.timeStamp;
            }
        }
    }
        public static AbilityCastIdentifier ReadAbilityCastIdentifier(this NetworkReader reader)
        {
            Entity     ent;
            GameObject go = reader.ReadGameObject();

            if (go == null)
            {
                ent = null;
            }
            else
            {
                ent = go.GetComponent <Entity>();
            }
            return(new AbilityCastIdentifier(
                       ent,
                       (float)reader.ReadDouble(),
                       reader.ReadInt32(),
                       reader.ReadInt32()));
        }
    public override void Deserialize(NetworkReader reader) {
        //Get the no of inputs received
        int count = reader.ReadInt32();

        //Prepaare list
        if (inputsList != null) {
            inputsList.Clear(); //Detatch prev elements
        }
        inputsList = new List<Inputs>(); //Detatch prev mem

        //Build all inputs
        for (int i = 0; i < count; i++){
            //Create
            Inputs input = new Inputs();

            //Deserialize individually
            input.crouch = reader.ReadBoolean();
            input.jump = reader.ReadBoolean();
            input.move = reader.ReadBoolean();
            input.pitch = reader.ReadSingle();
            input.rotate = reader.ReadBoolean();
            input.timeStamp = reader.ReadDouble();
            input.walk = reader.ReadBoolean();
            bool[] wasd = new bool[4];
            wasd[0] = reader.ReadBoolean();
            wasd[1] = reader.ReadBoolean();
            wasd[2] = reader.ReadBoolean();
            wasd[3] = reader.ReadBoolean();
            input.wasd = wasd;
            input.yaw = reader.ReadSingle();

            //Add to the message list
            inputsList.Add(input);

            //Check if is the last input and register stamp
            if(i == count - 1) {
                stamp = input.timeStamp;
            }
        }
    }
Esempio n. 24
0
 public void Deserialize(NetworkReader reader)
 {
     IntValue    = reader.ReadInt32();
     StringValue = reader.ReadString();
     DoubleValue = reader.ReadDouble();
 }
Esempio n. 25
0
 public void Deserialize(NetworkReader reader)
 {
     name     = reader.ReadString();
     op       = (Operation)reader.ReadByte();
     modifier = reader.ReadDouble();
 }
Esempio n. 26
0
        private static void HandleTimeScale(NetworkMessage netMsg)
        {
            NetworkReader reader = netMsg.reader;

            Time.timeScale = (float)reader.ReadDouble();
        }
Esempio n. 27
0
 public override void Deserialize(NetworkReader reader)
 {
     serverTime = reader.ReadDouble();
     clientTime = reader.ReadDouble();
 }
Esempio n. 28
0
 public override void Deserialize(NetworkReader reader)
 {
     base.Deserialize(reader);
     Target = reader.ReadVector3();
     Force  = (float)reader.ReadDouble();
 }
Esempio n. 29
0
    // Read
    public static object Read(NetworkReader reader, Type type)
    {
        if (type == typeof(byte))
        {
            return(reader.ReadByte());
        }

        if (type == typeof(short))
        {
            return(reader.ReadInt16());
        }

        if (type == typeof(int))
        {
            return(reader.ReadInt32());
        }

        if (type == typeof(long))
        {
            return(reader.ReadInt64());
        }

        if (type == typeof(string))
        {
            return(reader.ReadString());
        }

        if (type == typeof(float))
        {
            return(reader.ReadSingle());
        }

        if (type == typeof(double))
        {
            return(reader.ReadDouble());
        }

        if (type == typeof(Vector2))
        {
            return(reader.ReadVector2());
        }

        if (type == typeof(Vector3))
        {
            return(reader.ReadVector3());
        }

        if (type == typeof(Vector4))
        {
            return(reader.ReadVector4());
        }

        if (type == typeof(Color))
        {
            return(reader.ReadColor());
        }

        if (type == typeof(Color32))
        {
            return(reader.ReadColor32());
        }

        if (type == typeof(Quaternion))
        {
            return(reader.ReadQuaternion());
        }

        if (type.IsValueType)
        {
            return(Activator.CreateInstance(type));
        }

        return(null);
    }
 private void SyncHealth(SyncableVariable var, NetworkReader reader)
 {
     currentHealth = (float)reader.ReadDouble();
 }
Esempio n. 31
0
 public override void Deserialize(NetworkReader reader)
 {
     base.Deserialize(reader);
     Pos  = reader.ReadVector3();
     RotY = (float)reader.ReadDouble();
 }