예제 #1
0
        /// <summary>
        /// Reads out an FBlueprintText from a BinaryReader.
        /// </summary>
        /// <param name="reader">The BinaryReader to read from.</param>
        public virtual void Read(AssetBinaryReader reader)
        {
            TextLiteralType = (EBlueprintTextLiteralType)reader.ReadByte();
            switch (TextLiteralType)
            {
            case EBlueprintTextLiteralType.Empty:
                break;

            case EBlueprintTextLiteralType.LocalizedText:
                LocalizedSource    = ExpressionSerializer.ReadExpression(reader);
                LocalizedKey       = ExpressionSerializer.ReadExpression(reader);
                LocalizedNamespace = ExpressionSerializer.ReadExpression(reader);
                break;

            case EBlueprintTextLiteralType.InvariantText:     // IsCultureInvariant
                InvariantLiteralString = ExpressionSerializer.ReadExpression(reader);
                break;

            case EBlueprintTextLiteralType.LiteralString:
                LiteralString = ExpressionSerializer.ReadExpression(reader);
                break;

            case EBlueprintTextLiteralType.StringTableEntry:
                StringTableAsset = reader.XFER_OBJECT_POINTER();
                StringTableId    = ExpressionSerializer.ReadExpression(reader);
                StringTableKey   = ExpressionSerializer.ReadExpression(reader);
                break;

            default:
                throw new NotImplementedException("Unimplemented blueprint text literal type " + TextLiteralType);
            }
        }
예제 #2
0
        public void TestCustomSerializationStructsInMap()
        {
            var tester = new UAsset(Path.Combine("TestCustomSerializationStructsInMap", "wtf.uasset"), UE4Version.VER_UE4_25);

            Assert.IsTrue(tester.VerifyBinaryEquality());

            // Get the map property in export 2
            Export exportTwo = FPackageIndex.FromRawIndex(2).ToExport(tester);

            Assert.IsTrue(exportTwo is NormalExport);

            NormalExport exportTwoNormal = (NormalExport)exportTwo;

            var             mapPropertyName = FName.FromString("KekWait");
            MapPropertyData testMap         = exportTwoNormal[mapPropertyName] as MapPropertyData;

            Assert.IsNotNull(testMap);
            Assert.IsTrue(testMap == exportTwoNormal[mapPropertyName.Value.Value]);

            // Get the first entry of the map
            StructPropertyData entryKey   = testMap?.Value?.Keys?.ElementAt(0) as StructPropertyData;
            StructPropertyData entryValue = testMap?.Value?[0] as StructPropertyData;

            Assert.IsNotNull(entryKey?.Value?[0]);
            Assert.IsNotNull(entryValue?.Value?[0]);

            // Check that the properties are correct
            Assert.IsTrue(entryKey.Value[0] is VectorPropertyData);
            Assert.IsTrue(entryValue.Value[0] is LinearColorPropertyData);
        }
예제 #3
0
        /// <summary>
        /// Reads out the expression from a BinaryReader.
        /// </summary>
        /// <param name="reader">The BinaryReader to read from.</param>
        public override void Read(AssetBinaryReader reader)
        {
            InnerProperty = reader.XFERPTR();
            int numEntries = reader.ReadInt32(); // Number of elements

            Elements = reader.ReadExpressionArray(EExprToken.EX_EndArrayConst);
        }
예제 #4
0
 public FObjectImport(FAssetArchive Ar)
 {
     ClassPackage = Ar.ReadFName();
     ClassName    = Ar.ReadFName();
     OuterIndex   = new FPackageIndex(Ar);
     ObjectName   = Ar.ReadFName();
 }
예제 #5
0
        public FPackageIndex AreaClass; // UNavArea

        public override void Deserialize(FAssetArchive Ar, long validPos)
        {
            base.Deserialize(Ar, validPos);

            var startPos = Ar.Position;
            int version;
            var myMagic = Ar.Read <uint>();

            if (myMagic != Consts.Magic)
            {
                version     = Consts.Initial;
                Ar.Position = startPos;
            }
            else
            {
                version = Ar.Read <int>();
            }

            var _       = Ar.Read <FGuid>(); // Zeroed GUID, unused
            var bCooked = Ar.ReadBoolean();

            if (bCooked)
            {
                CookedFormatData = new FFormatContainer(Ar);
            }

            if (version >= Consts.AreaClass)
            {
                AreaClass = new FPackageIndex(Ar);
            }
        }
예제 #6
0
 public override void Deserialize(FAssetArchive Ar, long validPos)
 {
     base.Deserialize(Ar, validPos);
     PersistentLevel        = new FPackageIndex(Ar);
     ExtraReferencedObjects = Ar.ReadArray(() => new FPackageIndex(Ar));
     StreamingLevels        = Ar.ReadArray(() => new FPackageIndex(Ar));
 }
예제 #7
0
        public override void Read(AssetBinaryReader reader)
        {
            base.Read(reader);

            Enum           = new FPackageIndex(reader.ReadInt32());
            UnderlyingProp = new FPackageIndex(reader.ReadInt32());
        }
예제 #8
0
 public FTextureParameterValue(FStructFallback fallback)
 {
     ParameterName  = fallback.GetOrDefault <FName>(nameof(ParameterName));
     ParameterInfo  = fallback.GetOrDefault <FMaterialParameterInfo>(nameof(ParameterInfo));
     ParameterValue = fallback.GetOrDefault <FPackageIndex>(nameof(ParameterValue));
     ExpressionGUID = fallback.GetOrDefault <FGuid>(nameof(ExpressionGUID));
 }
예제 #9
0
 public virtual void Read(AssetBinaryReader reader)
 {
     if (reader.Asset.GetCustomVersion <FFrameworkObjectVersion>() < FFrameworkObjectVersion.RemoveUField_Next)
     {
         Next = new FPackageIndex(reader.ReadInt32());
     }
 }
예제 #10
0
        //public bool bImportPackageHandled { get; } unused for serialization
        //public bool bImportSearchedFor { get; }
        //public bool bImportFailed { get; }

        internal FObjectImport(PackageReader reader)
        {
            ClassPackage = reader.ReadFName();
            ClassName = reader.ReadFName();
            OuterIndex = new FPackageIndex(reader);
            ObjectName = reader.ReadFName();
        }
예제 #11
0
 public FZoneProperties(FAssetArchive Ar)
 {
     ZoneActor      = new FPackageIndex(Ar);
     Connectivity   = Ar.Read <FZoneSet>();
     Visibility     = Ar.Read <FZoneSet>();
     LastRenderTime = Ar.Read <float>();
 }
예제 #12
0
        public void TestCDOModification()
        {
            var tester = new UAsset(Path.Combine("TestManyAssets", "Astroneer", "Augment_BroadBrush.uasset"), UE4Version.VER_UE4_23);

            Assert.IsTrue(tester.VerifyBinaryEquality());

            NormalExport cdoExport = null;

            foreach (Export testExport in tester.Exports)
            {
                if (testExport.ObjectFlags.HasFlag(EObjectFlags.RF_ClassDefaultObject))
                {
                    cdoExport = (NormalExport)testExport;
                    break;
                }
            }
            Assert.IsNotNull(cdoExport);

            cdoExport["PickupActor"] = new ObjectPropertyData()
            {
                Value = FPackageIndex.FromRawIndex(0)
            };

            Assert.IsTrue(cdoExport["PickupActor"] is ObjectPropertyData);
            Assert.IsTrue(((ObjectPropertyData)cdoExport["PickupActor"]).Value.Index == 0);
        }
예제 #13
0
        public FPackageIndex ScriptStruct; // UScriptStruct

        public FRigVMParameter(FAssetArchive Ar)
        {
            Type          = Ar.Read <ERigVMParameterType>();
            Name          = Ar.ReadFName();
            RegisterIndex = Ar.Read <int>();
            CPPType       = Ar.ReadFString();
            ScriptStruct  = new FPackageIndex(Ar);
        }
예제 #14
0
 private ExportLoader?ResolveLoader(FPackageIndex index)
 {
     if (index.IsExport)
     {
         return(_package._exportLoaders[index.Index - 1]);
     }
     return(null);
 }
예제 #15
0
        }                                                        // UMaterialInterface[]

        public override void Deserialize(FAssetArchive Ar, long validPos)
        {
            base.Deserialize(Ar, validPos);

            var stripDataFlags = Ar.Read <FStripDataFlags>();

            bCooked   = Ar.ReadBoolean();
            BodySetup = new FPackageIndex(Ar);
            if (Ar.Ver >= EUnrealEngineObjectUE4Version.STATIC_MESH_STORE_NAV_COLLISION)
            {
                NavCollision = new FPackageIndex(Ar);
            }

            if (!stripDataFlags.IsEditorDataStripped())
            {
                Log.Warning("Static Mesh with Editor Data not implemented yet");
                Ar.Position = validPos;
                return;
                // if (Ar.Ver < UE4Version.VER_UE4_DEPRECATED_STATIC_MESH_THUMBNAIL_PROPERTIES_REMOVED)
                // {
                //     var dummyThumbnailAngle = Ar.Read<FRotator>();
                //     var dummyThumbnailDistance = Ar.Read<float>();
                // }
                // var highResSourceMeshName = Ar.ReadFString();
                // var highResSourceMeshCRC = Ar.Read<uint>();
            }

            LightingGuid = Ar.Read <FGuid>(); // LocalLightingGuid
            Sockets      = Ar.ReadArray(() => new FPackageIndex(Ar));
            RenderData   = new FStaticMeshRenderData(Ar, bCooked);

            if (bCooked && Ar.Game is >= EGame.GAME_UE4_20 and < EGame.GAME_UE5_0)
            {
                var bHasOccluderData = Ar.ReadBoolean();
                if (bHasOccluderData)
                {
                    Ar.ReadArray <FVector>(); // Vertices
                    Ar.ReadArray <ushort>();  // Indices
                }
            }

            if (Ar.Game >= EGame.GAME_UE4_14)
            {
                var bHasSpeedTreeWind = Ar.ReadBoolean();
                if (bHasSpeedTreeWind)
                {
                    Ar.Position = validPos;
                    return;
                }

                if (FEditorObjectVersion.Get(Ar) >= FEditorObjectVersion.Type.RefactorMeshEditorMaterials)
                {
                    // UE4.14+ - "Materials" are deprecated, added StaticMaterials
                    StaticMaterials = Ar.ReadArray(() => new FStaticMaterial(Ar));
                }
            }

            if (StaticMaterials is { Length : > 0 })
예제 #16
0
        public override void Deserialize(FAssetArchive Ar, long validPos)
        {
            base.Deserialize(Ar, validPos);

            const int StripVertexBufferFlag = 1;
            var       stripData             = new FStripDataFlags(Ar);

            Bounds = Ar.Read <FBoxSphereBounds>();

            Vectors = Ar.ReadBulkArray <FVector>();
            Points  = Ar.ReadBulkArray <FVector>();
            Nodes   = Ar.ReadBulkArray <FBspNode>();

            if (Ar.Ver < EUnrealEngineObjectUE4Version.BSP_UNDO_FIX)
            {
                var surfsOwner = new FPackageIndex(Ar);
                Surfs = Ar.ReadArray(() => new FBspSurf(Ar));
            }
            else
            {
                Surfs = Ar.ReadArray(() => new FBspSurf(Ar));
            }
            Verts = Ar.ReadBulkArray <FVert>();

            NumSharedSides = Ar.Read <int>();
            if (Ar.Ver < EUnrealEngineObjectUE4Version.REMOVE_ZONES_FROM_MODEL)
            {
                var dummyZones = Ar.ReadArray <FZoneProperties>();
            }

            var bHasEditorOnlyData = !Ar.IsFilterEditorOnly || Ar.Ver < EUnrealEngineObjectUE4Version.REMOVE_UNUSED_UPOLYS_FROM_UMODEL;

            if (bHasEditorOnlyData)
            {
                var dummyPolys = new FPackageIndex(Ar);
                Ar.SkipBulkArrayData(); // DummyLeafHulls
                Ar.SkipBulkArrayData(); // DummyLeaves
            }

            RootOutside = Ar.ReadBoolean();
            Linked      = Ar.ReadBoolean();

            if (Ar.Ver < EUnrealEngineObjectUE4Version.REMOVE_ZONES_FROM_MODEL)
            {
                var dummyPortalNodes = Ar.ReadBulkArray <int>();
            }

            NumUniqueVertices = Ar.Read <uint>();

            if (!stripData.IsEditorDataStripped() || !stripData.IsClassDataStripped(StripVertexBufferFlag))
            {
                VertexBuffer = new FModelVertexBuffer(Ar);
            }

            LightingGuid      = Ar.Read <FGuid>();
            LightmassSettings = Ar.ReadArray(() => new FLightmassPrimitiveSettings(Ar));
        }
예제 #17
0
 public FRigVMRegisterOffset(FAssetArchive Ar)
 {
     Segments           = Ar.ReadArray <int>();
     Type               = Ar.Read <ERigVMRegisterType>();
     CPPType            = Ar.ReadFName();
     ScriptStruct       = new FPackageIndex(Ar);
     ElementSize        = Ar.Read <ushort>();
     ParentScriptStruct = new FPackageIndex(Ar);
     CachedSegmentPath  = Ar.ReadFString();
     ArrayIndex         = Ar.Read <int>();
 }
예제 #18
0
        public override void Deserialize(FAssetArchive Ar, long validPos)
        {
            base.Deserialize(Ar, validPos);

            Skeleton = GetOrDefault <FPackageIndex>(nameof(Skeleton));

            if (Ar.Ver >= EUnrealEngineObjectUE4Version.SKELETON_GUID_SERIALIZATION)
            {
                SkeletonGuid = Ar.Read <FGuid>();
            }
        }
예제 #19
0
        /// <summary>
        /// Reads out the expression from a BinaryReader.
        /// </summary>
        /// <param name="reader">The BinaryReader to read from.</param>
        public override void Read(AssetBinaryReader reader)
        {
            if (reader.Asset.EngineVersion >= UE4Version.VER_UE4_CHANGE_SETARRAY_BYTECODE)
            {
                AssigningProperty = ExpressionSerializer.ReadExpression(reader);
            }
            else
            {
                ArrayInnerProp = reader.XFERPTR();
            }

            Elements = reader.ReadExpressionArray(EExprToken.EX_EndArray);
        }
예제 #20
0
 public override void Deserialize(FAssetArchive Ar, long validPos)
 {
     base.Deserialize(Ar, validPos);
     Actors                         = Ar.ReadArray(() => new FPackageIndex(Ar));
     URL                            = new FURL(Ar);
     Model                          = new FPackageIndex(Ar);
     ModelComponents                = Ar.ReadArray(() => new FPackageIndex(Ar));
     LevelScriptActor               = new FPackageIndex(Ar);
     NavListStart                   = new FPackageIndex(Ar);
     NavListEnd                     = new FPackageIndex(Ar);
     PrecomputedVisibilityHandler   = new FPrecomputedVisibilityHandler(Ar);
     PrecomputedVolumeDistanceField = new FPrecomputedVolumeDistanceField(Ar);
 }
예제 #21
0
        private void ApplyEnum(FProperty prop, FPackageIndex enumIndex)
        {
            var enumObj = enumIndex.ResolvedObject;

            Enum      = enumObj?.Object?.Value as UEnum;
            EnumName  = enumObj?.Name.Text;
            InnerType = prop.ElementSize switch
            {
                4 => new PropertyType("IntProperty"),
                _ => null
            };
        }
    }
예제 #22
0
        public readonly int           iLightmassIndex; // Index to the lightmass settings

        public FBspSurf(FAssetArchive Ar)
        {
            Material        = new FPackageIndex(Ar);
            PolyFlags       = Ar.Read <uint>();
            pBase           = Ar.Read <int>();
            vNormal         = Ar.Read <int>();
            vTextureU       = Ar.Read <int>();
            vTextureV       = Ar.Read <int>();
            iBrushPoly      = Ar.Read <int>();
            Actor           = new FPackageIndex(Ar);
            Plane           = Ar.Read <FPlane>();
            LightMapScale   = Ar.Read <float>();
            iLightmassIndex = Ar.Read <int>();
        }
예제 #23
0
        public FObjectExport(FAssetArchive Ar)
        {
            ClassIndex    = new FPackageIndex(Ar);
            SuperIndex    = new FPackageIndex(Ar);
            TemplateIndex = Ar.Ver >= EUnrealEngineObjectUE4Version.TemplateIndex_IN_COOKED_EXPORTS ? new FPackageIndex(Ar) : new FPackageIndex();
            OuterIndex    = new FPackageIndex(Ar);
            ObjectName    = Ar.ReadFName();
            ObjectFlags   = Ar.Read <uint>();

            if (Ar.Ver < EUnrealEngineObjectUE4Version.e64BIT_EXPORTMAP_SERIALSIZES)
            {
                SerialSize   = Ar.Read <int>();
                SerialOffset = Ar.Read <int>();
            }
            else
            {
                SerialSize   = Ar.Read <long>();
                SerialOffset = Ar.Read <long>();
            }

            ForcedExport = Ar.ReadBoolean();
            NotForClient = Ar.ReadBoolean();
            NotForServer = Ar.ReadBoolean();
            PackageGuid  = Ar.Read <FGuid>();
            PackageFlags = Ar.Read <uint>();
            NotAlwaysLoadedForEditorGame = Ar.Ver < EUnrealEngineObjectUE4Version.LOAD_FOR_EDITOR_GAME || Ar.ReadBoolean();
            IsAsset = Ar.Ver >= EUnrealEngineObjectUE4Version.COOKED_ASSETS_IN_EDITOR_SUPPORT && Ar.ReadBoolean();

            if (Ar.Ver >= EUnrealEngineObjectUE4Version.PRELOAD_DEPENDENCIES_IN_COOKED_EXPORTS)
            {
                FirstExportDependency = Ar.Read <int>();
                SerializationBeforeSerializationDependencies = Ar.Read <int>();
                CreateBeforeSerializationDependencies        = Ar.Read <int>();
                SerializationBeforeCreateDependencies        = Ar.Read <int>();
                CreateBeforeCreateDependencies = Ar.Read <int>();
            }
            else
            {
                FirstExportDependency = -1;
                SerializationBeforeSerializationDependencies = 0;
                CreateBeforeSerializationDependencies        = 0;
                SerializationBeforeCreateDependencies        = 0;
                CreateBeforeCreateDependencies = 0;
            }

            ClassName = ClassIndex.Name;
        }
예제 #24
0
        // TODO not really optimal, there should be TryReadObject functions etc
        public Lazy <T?> ReadObject <T>() where T : UObject
        {
            var index    = new FPackageIndex(this);
            var resolved = index.ResolvedObject;

            return(new Lazy <T?>(() =>
            {
                if (resolved == null)
                {
                    if (index.IsNull)
                    {
                        // Silent this as it is expected to not have an object
                        return null;
                    }
                    Log.Warning("Failed to resolve index {Index}", index);
                    return null;
                }

                if (Owner.Provider == null)
                {
                    Log.Warning("Can't load object {Resolved} without a file provider", resolved.Name);
                    return null;
                }

                if (!resolved.TryLoad(out var obj))
                {
                    Log.Warning("Failed to load object {Obj}", resolved.Name);
                    return null;
                }

                if (obj is T cast)
                {
                    return cast;
                }
                Log.Warning("Object has unexpected type {ObjType}, expected type {Type}", obj.GetType().Name, typeof(T).Name);

                return null;
            }));
        }
예제 #25
0
        internal FObjectExport(PackageReader reader)
        {
            ClassIndex = new FPackageIndex(reader);
            SuperIndex = new FPackageIndex(reader);

            // only serialize when file version is past VER_UE4_TemplateIndex_IN_COOKED_EXPORTS
            TemplateIndex = new FPackageIndex(reader);

            OuterIndex = new FPackageIndex(reader);
            ObjectName = reader.ReadFName();

            ObjectFlags = (EObjectFlags)reader.ReadUInt32() & EObjectFlags.RF_Load;

            // only serialize when file version is past VER_UE4_64BIT_EXPORTMAP_SERIALSIZES
            SerialSize   = reader.ReadInt64();
            SerialOffset = reader.ReadInt64();

            bForcedExport = reader.ReadInt32() != 0;
            bNotForClient = reader.ReadInt32() != 0;
            bNotForServer = reader.ReadInt32() != 0;

            PackageGuid  = new FGuid(reader);
            PackageFlags = reader.ReadUInt32();

            // only serialize when file version is past VER_UE4_LOAD_FOR_EDITOR_GAME
            bNotAlwaysLoadedForEditorGame = reader.ReadInt32() != 0;

            // only serialize when file version is past VER_UE4_COOKED_ASSETS_IN_EDITOR_SUPPORT
            bIsAsset = reader.ReadInt32() != 0;

            // only serialize when file version is past VER_UE4_PRELOAD_DEPENDENCIES_IN_COOKED_EXPORTS
            FirstExportDependency = reader.ReadInt32();
            SerializationBeforeSerializationDependencies = reader.ReadInt32();
            CreateBeforeSerializationDependencies        = reader.ReadInt32();
            SerializationBeforeCreateDependencies        = reader.ReadInt32();
            CreateBeforeCreateDependencies = reader.ReadInt32();
        }
예제 #26
0
 public FObjectResource(FName objectName, FPackageIndex outerIndex)
 {
     ObjectName = objectName;
     OuterIndex = outerIndex;
 }
예제 #27
0
 /// <summary>
 /// Reads out the expression from a BinaryReader.
 /// </summary>
 /// <param name="reader">The BinaryReader to read from.</param>
 public override void Read(AssetBinaryReader reader)
 {
     Struct     = reader.XFERPTR();
     StructSize = reader.ReadInt32();
     Value      = reader.ReadExpressionArray(EExprToken.EX_EndStructConst);
 }
예제 #28
0
 public override void Read(AssetBinaryReader reader)
 {
     base.Read(reader);
     Struct = new FPackageIndex(reader.ReadInt32());
 }
예제 #29
0
 public override void Read(AssetBinaryReader reader)
 {
     base.Read(reader);
     KeyProp   = new FPackageIndex(reader.ReadInt32());
     ValueProp = new FPackageIndex(reader.ReadInt32());
 }
예제 #30
0
 public override void Read(AssetBinaryReader reader)
 {
     base.Read(reader);
     InterfaceClass = new FPackageIndex(reader.ReadInt32());
 }