Example #1
0
            protected override void Deserialize(NetworkReader reader, ref LightningOrb orb)
            {
                base.Deserialize(reader, ref orb);
                orb.speed            = reader.ReadSingle();
                orb.damageValue      = reader.ReadSingle();
                orb.attacker         = reader.ReadGameObject();
                orb.inflictor        = reader.ReadGameObject();
                orb.bouncesRemaining = reader.ReadInt32();

                //Needs null checks
                var c = reader.ReadInt32();

                orb.bouncedObjects = new(c);
                for (Int32 i = 0; i < c; i++)
                {
                    orb.bouncedObjects.Add(reader.ReadNetworkIdentity().GetComponent <CharacterBody>().healthComponent);
                }

                orb.teamIndex                  = reader.ReadTeamIndex();
                orb.isCrit                     = reader.ReadBoolean();
                orb.procChainMask              = reader.ReadProcChainMask();
                orb.procCoefficient            = reader.ReadSingle();
                orb.damageColorIndex           = reader.ReadDamageColorIndex();
                orb.range                      = reader.ReadSingle();
                orb.damageCoefficientPerBounce = reader.ReadSingle();
                orb.targetsToFindPerBounce     = reader.ReadInt32();
                orb.damageType                 = reader.ReadDamageType();
                orb.lightningType              = reader.ReadBits <LightningOrb.LightningType>();
            }
Example #2
0
        public unsafe static T ReadBits <T>(this NetworkReader reader)
            where T : unmanaged
        {
            var temp = new T();

            reader.ReadBits(ref temp);
            return(temp);
        }
Example #3
0
        public void TestBits()
        {
            ulong somevalue = 0b1100101010011;

            var outNetworkBuffer = new NetworkBuffer();
            var outNetworkWriter = new NetworkWriter(outNetworkBuffer);

            outNetworkWriter.WriteBits(somevalue, 5);

            var outBuffer = outNetworkBuffer.GetBuffer();

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

            Assert.That(inNetworkReader.ReadBits(5), Is.EqualTo(0b10011));
        }
 public void Deserialize(NetworkReader reader)
 {
     this.serializer = OrbSerializerCatalog.GetDef(reader.ReadBits <OrbSerializerCatalog.Index>()) !;
     this.orb        = this.serializer.CreateInstance();
     reader.Read(ref this.orb, this.serializer);
 }