/// <summary>
        /// see https://github.com/EpicGames/UnrealEngine/blob/6c20d9831a968ad3cb156442bebb41a883e62152/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Private/GameplayEffectTypes.cpp#L311
        /// see https://github.com/EpicGames/UnrealEngine/blob/6c20d9831a968ad3cb156442bebb41a883e62152/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Private/GameplayEffectTypes.cpp#L177
        /// </summary>
        /// <param name="reader"></param>
        public void Serialize(NetBitReader reader)
        {
            var validData = reader.ReadBit();

            if (validData)
            {
                var RepBits = reader.ReadBitsToInt(7);

                if ((RepBits & (1 << 0)) > 0)
                {
                    Instigator = reader.ReadIntPacked();
                }
                if ((RepBits & (1 << 1)) > 0)
                {
                    EffectCauser = reader.ReadIntPacked();
                }
                if ((RepBits & (1 << 2)) > 0)
                {
                    AbilityCDO = reader.ReadIntPacked();
                }
                if ((RepBits & (1 << 3)) > 0)
                {
                    SourceObject = reader.ReadIntPacked();
                }
                if ((RepBits & (1 << 4)) > 0)
                {
                    // SafeNetSerializeTArray_HeaderOnly
                    var bitCount = (int)Math.Ceiling(Math.Log2(31));
                    var arrayNum = reader.ReadBitsToInt(bitCount);

                    // SafeNetSerializeTArray_Default
                    Actors = new ActorGuid[arrayNum];
                    for (var i = 0; i < arrayNum; i++)
                    {
                        Actors[i] = new ActorGuid()
                        {
                            Value = reader.ReadIntPacked()
                        };
                    }
                }
                if ((RepBits & (1 << 5)) > 0)
                {
                    HitResult = new FHitResult(reader);
                }
                if ((RepBits & (1 << 6)) > 0)
                {
                    WorldOrigin     = reader.SerializePropertyVector100();
                    bHasWorldOrigin = true;
                }
                else
                {
                    bHasWorldOrigin = false;
                }
            }
        }
        /// <summary>
        /// see https://github.com/EpicGames/UnrealEngine/blob/6c20d9831a968ad3cb156442bebb41a883e62152/Engine/Source/Runtime/GameplayTags/Private/GameplayTagContainer.cpp#L970
        /// </summary>
        /// <param name="reader"></param>
        public void Serialize(NetBitReader reader)
        {
            // 1st bit to indicate empty tag container or not (empty tag containers are frequently replicated). Early out if empty.
            if (reader.ReadBit())
            {
                return;
            }

            var numTags = reader.ReadBitsToInt(7);

            Tags = new FGameplayTag[numTags];
            for (var i = 0; i < numTags; i++)
            {
                Tags[i] = new FGameplayTag(reader);
            }
        }
Example #3
0
        public void Serialize(NetBitReader reader)
        {
            int numElements = reader.ReadBitsToInt(5);

            if (numElements == 0)
            {
                return;
            }

            Tags = new FGameplayTag[numElements];

            for (int i = 0; i < numElements; i++)
            {
                FGameplayTag tag = new FGameplayTag();
                tag.Serialize(reader);

                Tags[i] = tag;
            }
        }
        public void Serialize(NetBitReader reader)
        {
            bool isEmpty = reader.ReadBit();

            if (isEmpty)
            {
                return;
            }

            int numTags = reader.ReadBitsToInt(7);

            Tags = new FGameplayTag[numTags];

            for (int i = 0; i < numTags; i++)
            {
                FGameplayTag tag = new FGameplayTag();
                tag.Serialize(reader);

                Tags[i] = tag;
            }
        }
        public void Serialize(NetBitReader reader)
        {
            bool repPosition = reader.ReadBoolean();

            if (repPosition)
            {
                bRepPosition           = true;
                SectionIdToPlay        = 0;
                SkipPositionCorrection = false;

                uint packedPosition = reader.ReadIntPacked();

                Position = packedPosition / 100;
            }
            else
            {
                bRepPosition = false;

                SkipPositionCorrection = true;
                Position        = 0;
                SectionIdToPlay = reader.ReadBitsToInt(7);
            }

            IsStopped              = reader.ReadBit();
            ForcePlayBit           = reader.ReadBit();
            SkipPositionCorrection = reader.ReadBit();
            bSkipPlayRate          = reader.ReadBit();

            AnimMontage = new UObjectGUID {
                Value = reader.ReadIntPacked()
            };
            PlayRate      = reader.SerializePropertyFloat();
            BlendTime     = reader.SerializePropertyFloat();
            NextSectionID = reader.ReadByte();

            PredictionKey = new FPredictionKey();
            PredictionKey.Serialize(reader);
        }
Example #6
0
        /// <summary>
        /// see https://github.com/EpicGames/UnrealEngine/blob/6c20d9831a968ad3cb156442bebb41a883e62152/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Private/GameplayEffectTypes.cpp#L789
        /// </summary>
        /// <param name="reader"></param>
        public void Serialize(NetBitReader reader)
        {
            const byte NUM_LEVEL_BITS = 5; // need to bump this up to support 20 levels for AbilityLevel
            // const byte MAX_LEVEL = (1 << NUM_LEVEL_BITS) - 1;

            var RepBits = reader.ReadBitsToInt((int)RepFlag.REP_MAX);

            // Tag containers serialize empty containers with 1 bit, so no need to serialize this in the RepBits field.
            AggregatedSourceTags.Serialize(reader);
            AggregatedTargetTags.Serialize(reader);

            if ((RepBits & (1 << (int)RepFlag.REP_NormalizedMagnitude)) > 0)
            {
                NormalizedMagnitude = reader.ReadSingle();
            }
            if ((RepBits & (1 << (int)RepFlag.REP_RawMagnitude)) > 0)
            {
                RawMagnitude = reader.ReadSingle();
            }
            if ((RepBits & (1 << (int)RepFlag.REP_EffectContext)) > 0)
            {
                // FGameplayEffectContextHandle
                if (reader.ReadBit())
                {
                    var handle = new FGameplayEffectContextHandle();
                    handle.Serialize(reader);
                }
            }
            if ((RepBits & (1 << (int)RepFlag.REP_Location)) > 0)
            {
                Location = reader.SerializePropertyVector10();
            }
            if ((RepBits & (1 << (int)RepFlag.REP_Normal)) > 0)
            {
                Normal = reader.SerializePropertyVectorNormal();
            }
            if ((RepBits & (1 << (int)RepFlag.REP_Instigator)) > 0)
            {
                Instigator = reader.ReadIntPacked();
            }
            if ((RepBits & (1 << (int)RepFlag.REP_EffectCauser)) > 0)
            {
                EffectCauser = reader.ReadIntPacked();
            }
            if ((RepBits & (1 << (int)RepFlag.REP_SourceObject)) > 0)
            {
                SourceObject = reader.ReadIntPacked();
            }
            if ((RepBits & (1 << (int)RepFlag.REP_TargetAttachComponent)) > 0)
            {
                TargetAttachComponent = reader.ReadIntPacked();
            }
            if ((RepBits & (1 << (int)RepFlag.REP_PhysMaterial)) > 0)
            {
                PhysicalMaterial = reader.ReadIntPacked();
            }
            if ((RepBits & (1 << (int)RepFlag.REP_GELevel)) > 0)
            {
                GameplayEffectLevel = reader.ReadBitsToInt(NUM_LEVEL_BITS);
            }
            if ((RepBits & (1 << (int)RepFlag.REP_AbilityLevel)) > 0)
            {
                AbilityLevel = reader.ReadBitsToInt(NUM_LEVEL_BITS);
            }
        }
        public void Serialize(NetBitReader reader)
        {
            return;

            bool[] flags = reader.ReadBits(7);

            BlockingHit      = flags[6];
            StartPenetrating = flags[5];
            bool impactPointEqualsLocation = flags[4];
            bool impactNormalEqualsNormal  = flags[3];
            bool invalidItem        = flags[2];
            bool invalidFaceIndex   = flags[1];
            bool noPenetrationDepth = flags[0];

            Time     = reader.ReadSingle();
            Location = reader.SerializePropertyQuantizeVector();
            Normal   = reader.SerializePropertyVectorNormal();

            if (!impactPointEqualsLocation)
            {
                ImpactPoint = reader.SerializePropertyQuantizeVector();
            }
            else
            {
                ImpactPoint = Location;
            }

            if (!impactNormalEqualsNormal)
            {
                ImpactNormal = reader.SerializePropertyVectorNormal();
            }
            else
            {
                ImpactNormal = Normal;
            }

            TraceStart = reader.SerializePropertyQuantizeVector();
            TraceEnd   = reader.SerializePropertyQuantizeVector();

            if (!noPenetrationDepth)
            {
                PenetrationDepth = reader.SerializePropertyFloat();
            }
            else
            {
                PenetrationDepth = 0;
            }

            Distance = (ImpactPoint - TraceStart).Size();

            if (!invalidItem)
            {
                Item = reader.ReadBitsToInt(32);
            }
            else
            {
                Item = -1;
            }

            PhysMaterial = reader.SerializePropertyUInt16();
            Actor        = reader.SerializePropertyUInt16();
            Component    = reader.SerializePropertyUInt16();
            BoneName     = reader.ReadFString();

            if (!invalidFaceIndex)
            {
                FaceIndex = reader.ReadBitsToInt(32);
            }
            else
            {
                FaceIndex = -1;
            }
        }