public void Serialize(NetBitReader reader)
        {
            byte sourceNum = reader.ReadByte();

            bool    bHasAdditiveSources          = reader.ReadBit();
            bool    bHasOverrideSources          = reader.ReadBit();
            FVector lastPreAdditiveVelocity      = reader.SerializePropertyVector10();
            bool    bIsAdditiveVelocityApplied   = reader.ReadBit();
            byte    lastAccumulatedSettingsFlags = reader.ReadByte();

            //Off by about 130 bits
            for (int i = 0; i < sourceNum; i++)
            {
                uint guid = reader.SerializePropertyObject();

                ushort priority = reader.ReadUInt16();
                ushort localId  = reader.ReadUInt16();
                byte   accumulatedModeSerialize = reader.ReadByte();
                string instanceName             = reader.SerializePropertyName();
                float  currentTime   = reader.SerializePropertyFloat();
                float  duration      = reader.SerializePropertyFloat();
                byte   statusFlags   = reader.ReadByte();
                bool   bInLocalSpace = reader.ReadBit();
            }
        }
 public void Serialize(NetBitReader reader)
 {
     if (reader.EngineNetworkVersion >= EngineNetworkVersionHistory.HISTORY_FAST_ARRAY_DELTA_STRUCT)
     {
         reader.ReadBit();
     }
     reader.ReadBit();
     Id = reader.ReadIntPacked();
     reader.SkipBits(31);
 }
Пример #3
0
        public void Serialize(NetBitReader reader)
        {
            bool validKeyForConnection = reader.ReadBit();
            bool hasBaseKey            = validKeyForConnection ? reader.ReadBit() : false;

            IsServerInitiated = reader.ReadBit();

            if (validKeyForConnection)
            {
                Current = reader.ReadUInt16();
                BaseVal = hasBaseKey ? reader.ReadUInt16() : (ushort)0;
            }
        }
Пример #4
0
        /// <summary>
        /// see https://github.com/EpicGames/UnrealEngine/blob/6c20d9831a968ad3cb156442bebb41a883e62152/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Private/GameplayPrediction.cpp#L7
        /// </summary>
        /// <param name="reader"></param>
        public void Serialize(NetBitReader reader)
        {
            var hasBaseKey            = false;
            var validKeyForConnection = reader.ReadBit();

            if (validKeyForConnection)
            {
                hasBaseKey = reader.ReadBit();
            }
            bIsServerInitiated = reader.ReadBit();
            if (validKeyForConnection)
            {
                CurrentKey = reader.ReadInt16();
                if (hasBaseKey)
                {
                    BaseKey = reader.ReadInt16();
                }
            }
        }
        /// <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;
                }
            }
        }
        public void Serialize(NetBitReader reader)
        {
            bool validData = reader.ReadBit();

            if (!validData)
            {
                return;
            }

            //???
            reader.Seek(reader.GetBitsLeft(), System.IO.SeekOrigin.Current);
        }
Пример #7
0
        /// <summary>
        /// see https://github.com/EpicGames/UnrealEngine/blob/c10022aa46e208b1593dd537c2607784aac158f1/Engine/Source/Runtime/Engine/Private/Collision/Collision.cpp#L42
        /// </summary>
        /// <param name="reader"></param>
        public void Serialize(NetBitReader reader)
        {
            // pack bitfield with flags
            // Most of the time the vectors are the same values, use that as an optimization
            BlockingHit      = reader.ReadBit();
            StartPenetrating = reader.ReadBit();
            var bImpactPointEqualsLocation = reader.ReadBit();
            var bImpactNormalEqualsNormal  = reader.ReadBit();

            // Often times the indexes are invalid, use that as an optimization
            var bInvalidItem         = reader.ReadBit();
            var bInvalidFaceIndex    = reader.ReadBit();
            var bNoPenetrationDepth  = reader.ReadBit();
            var bInvalidElementIndex = reader.EngineNetworkVersion >= EngineNetworkVersionHistory.HISTORY_ENUM_SERIALIZATION_COMPAT && reader.ReadBit();

            Time = reader.ReadSingle();

            Location = reader.ReadPackedVector(1, 20);
            Normal   = reader.SerializePropertyVectorNormal();

            ImpactPoint = !bImpactPointEqualsLocation?reader.ReadPackedVector(1, 20) : Location;

            ImpactNormal = !bImpactNormalEqualsNormal?reader.SerializePropertyVectorNormal() : Normal;

            TraceStart = reader.ReadPackedVector(1, 20);
            TraceEnd   = reader.ReadPackedVector(1, 20);

            PenetrationDepth = !bNoPenetrationDepth?reader.SerializePropertyFloat() : 0.0f;

            Distance = (ImpactPoint - TraceStart).Size();
            Item     = !bInvalidItem?reader.ReadInt32() : 0;

            PhysMaterial = reader.SerializePropertyObject();

            if (reader.EngineNetworkVersion < EngineNetworkVersionHistory.HISTORY_HITRESULT_INSTANCEHANDLE)
            {
                Actor = reader.SerializePropertyObject();
            }
            else
            {
                Actor = reader.SerializePropertyObject();

                // see https://github.com/EpicGames/UnrealEngine/blob/4564529ed77196caada6971f5de1be829900b9e1/Engine/Source/Runtime/Engine/Private/EngineTypes.cpp#L558
                //Ar << Handle.Actor;
                //Ar << Handle.Manager;
                //Ar << Handle.InstanceIndex;
            }

            Component = reader.SerializePropertyObject();
            BoneName  = reader.SerializePropertyName();
            FaceIndex = !bInvalidFaceIndex?reader.ReadInt32() : 0;

            ElementIndex = !bInvalidElementIndex && reader.EngineNetworkVersion >= EngineNetworkVersionHistory.HISTORY_ENUM_SERIALIZATION_COMPAT ? reader.ReadByte() : new byte();
        }
        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);
        }
        /// <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);
            }
        }
        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;
            }
        }
Пример #11
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);
            }
        }