예제 #1
0
 internal virtual void GetLifetimeReplicatedPropsInternal(IntPtr arrayAddress)
 {
     using (TArrayUnsafeRef <FLifetimeProperty> lifetimePropsUnsafe = new TArrayUnsafeRef <FLifetimeProperty>(arrayAddress))
     {
         FLifetimePropertyCollection lifetimeProps = new FLifetimePropertyCollection(Address, lifetimePropsUnsafe);
         GetLifetimeReplicatedProps(lifetimeProps);
     }
 }
예제 #2
0
        internal FLifetimePropertyCollection(IntPtr obj, TArrayUnsafeRef <FLifetimeProperty> dest)
        {
            this.dest        = dest;
            this.nativeClass = Native_UObjectBase.GetClass(obj);

            if (nativeClass == IntPtr.Zero && !(FBuild.BuildShipping || FBuild.BuildTest))
            {
                FMessage.Log(FMessage.LogNet, ELogVerbosity.Fatal, $"FLifetimePropertyCollection created for an unknown UClass");
            }
        }
예제 #3
0
        private static void OnGetLifetimeReplicatedProps(IntPtr address, IntPtr arrayAddress)
        {
            UObject obj = GCHelper.Find(address);

            IntPtr original = repProps.GetOriginal(obj);

            Native_VTableHacks.CallOriginal_GetLifetimeReplicatedProps(original, address, arrayAddress);

            using (TArrayUnsafeRef <FLifetimeProperty> lifetimePropsUnsafe = new TArrayUnsafeRef <FLifetimeProperty>(arrayAddress))
            {
                FLifetimePropertyCollection lifetimeProps = new FLifetimePropertyCollection(address, lifetimePropsUnsafe);
                obj.GetLifetimeReplicatedProps(lifetimeProps);
            }
        }
예제 #4
0
            private void ConsoleCommandWithWorldAndArgsDelegate(IntPtr argsPtr, IntPtr world)
            {
                var command = Command as FConsoleCommandWithWorldAndArgsDelegate;

                if (command != null)
                {
                    string[] args = null;
                    if (argsPtr == IntPtr.Zero)
                    {
                        args = new string[0];
                    }
                    else
                    {
                        args = new TArrayUnsafeRef <string>(argsPtr).ToArray();
                    }
                    command(args, GCHelper.Find(world));
                }
            }
예제 #5
0
            private void ConsoleCommandWithArgsDelegate(IntPtr argsPtr)
            {
                var command = Command as FConsoleCommandWithArgsDelegate;

                if (command != null)
                {
                    string[] args = null;
                    if (argsPtr == IntPtr.Zero)
                    {
                        args = new string[0];
                    }
                    else
                    {
                        args = new TArrayUnsafeRef <string>(argsPtr).ToArray();
                    }
                    command(args);
                }
            }
예제 #6
0
        private static void OnGetLifetimeReplicatedProps(IntPtr address, IntPtr arrayAddress)
        {
            try
            {
                UObject obj = GCHelper.Find(address);

                GetLifetimeReplicatedPropsDel_ThisCall original = repProps.GetOriginal <GetLifetimeReplicatedPropsDel_ThisCall>(obj);
                original(address, arrayAddress);
                //Native_VTableHacks.CallOriginal_GetLifetimeReplicatedProps(original, address, arrayAddress);

                using (TArrayUnsafeRef <FLifetimeProperty> lifetimePropsUnsafe = new TArrayUnsafeRef <FLifetimeProperty>(arrayAddress))
                {
                    FLifetimePropertyCollection lifetimeProps = new FLifetimePropertyCollection(address, lifetimePropsUnsafe);
                    obj.GetLifetimeReplicatedProps(lifetimeProps);
                }
            }
            catch (Exception e)
            {
                LogCallbackException(nameof(OnGetLifetimeReplicatedProps), e);
            }
        }
예제 #7
0
        public void GenerateCodeForBlueprints(AssetLoadMode loadMode, bool clearAssetCache, bool skipLevels)
        {
            BeginGenerateModules();

            string           projectPath = FPaths.ProjectFilePath;
            string           projectName = FPaths.GetBaseFilename(projectPath);
            UnrealModuleInfo module      = new UnrealModuleInfo(null, projectName, projectPath);

            BeginGenerateModule(module);

            UClass worldClass = GCHelper.Find <UClass>(Classes.UWorld);

            AssetCache assetCache = new AssetCache(this);

            if (!clearAssetCache)
            {
                assetCache.Load();
            }

            List <string> assetBlacklist = LoadAssetBlacklist();

            AssetLogClear();
            AssetLogLine("Load assets {0}", DateTime.Now);

            bool registeredCrashHandler = false;

            if (Settings.CatchCrashOnAssetLoading)
            {
                FCoreDelegates.OnHandleSystemError.Bind(OnAssetLoadingCrash);
                registeredCrashHandler = true;
            }

            using (FARFilter filter = new FARFilter())
            {
                filter.RecursiveClasses = true;
                filter.ClassNames.Add(UClass.GetClass <UBlueprint>().GetFName());
                filter.ClassNames.Add(UClass.GetClass <UBlueprintGeneratedClass>().GetFName());
                filter.ClassNames.Add(UClass.GetClass <UUserDefinedStruct>().GetFName());
                filter.ClassNames.Add(UClass.GetClass <UUserDefinedEnum>().GetFName());
                if (!skipLevels && worldClass != null)
                {
                    filter.ClassNames.Add(worldClass.GetFName());
                }

                List <FAssetData> assets = FAssetData.Load(filter);

                SlowTaskSetModuleCount(1);
                SlowTaskBeginModule("Blueprints", assets.Count);

                foreach (FAssetData asset in assets)
                {
                    SlowTaskStep(null);

                    string assetFileName, assetFileNameError;
                    if (!asset.TryGetFilename(out assetFileName, out assetFileNameError))
                    {
                        FMessage.Log(string.Format("FAssetData.TryGetFilename failed. ObjectPath:'{0}' reason:'{1}'",
                                                   asset.ObjectPath.ToString(), assetFileNameError));
                        continue;
                    }

                    bool isEngineAsset = FPaths.IsSameOrSubDirectory(FPaths.EngineContentDir, FPaths.GetPath(assetFileName));
                    if (loadMode != AssetLoadMode.All)
                    {
                        if ((isEngineAsset && loadMode != AssetLoadMode.Engine) ||
                            (!isEngineAsset && loadMode != AssetLoadMode.Game))
                        {
                            continue;
                        }
                    }

                    if (!assetCache.HasAssetChanged(asset, assetFileName))
                    {
                        if (Settings.LogAssetLoadingVerbose)
                        {
                            AssetLogLine("'{0}' unchanged", assetFileName);
                        }
                        continue;
                    }

                    // Log that we are loading this asset so we know which assets crash on load
                    AssetLog("'{0}' - ", asset.ObjectPath.ToString());

                    if (assetBlacklist.Contains(asset.ObjectPath.ToString()))
                    {
                        AssetLogLine("blacklisted");
                        continue;
                    }

                    loadingAsset = asset.ObjectPath.ToString();
                    UObject obj = asset.GetAsset();
                    loadingAsset = null;

                    UClass unrealClass = asset.GetClass();

                    if (obj == null || unrealClass == null)
                    {
                        AssetLogLine("null");
                        continue;
                    }

                    AssetLogLine("done");

                    if (unrealClass.IsChildOf <UBlueprint>())
                    {
                        UBlueprint blueprint = obj as UBlueprint;
                        if (blueprint != null)
                        {
                            UBlueprintGeneratedClass blueprintGeneratedClass = blueprint.GeneratedClass as UBlueprintGeneratedClass;
                            if (blueprintGeneratedClass != null)
                            {
                                GenerateCodeForStruct(module, blueprintGeneratedClass);
                            }
                        }
                    }
                    else if (unrealClass.IsChildOf <UBlueprintGeneratedClass>())
                    {
                        UBlueprintGeneratedClass blueprintGeneratedClass = obj as UBlueprintGeneratedClass;
                        if (blueprintGeneratedClass != null)
                        {
                            GenerateCodeForStruct(module, blueprintGeneratedClass);
                        }
                    }
                    else if (unrealClass.IsChildOf <UUserDefinedStruct>())
                    {
                        UUserDefinedStruct unrealStruct = obj as UUserDefinedStruct;
                        if (unrealStruct != null)
                        {
                            GenerateCodeForStruct(module, unrealStruct);
                        }
                    }
                    else if (unrealClass.IsChildOf <UUserDefinedEnum>())
                    {
                        UUserDefinedEnum unrealEnum = obj as UUserDefinedEnum;
                        if (unrealEnum != null)
                        {
                            GenerateCodeForEnum(module, unrealEnum);
                        }
                    }
                    else if (unrealClass.IsChildOf(worldClass))
                    {
                        TArrayUnsafeRef <UObject> levels = new TArrayUnsafeRef <UObject>(Native.Native_UWorld.GetLevels(obj.Address));
                        foreach (UObject level in levels)
                        {
                            using (TArrayUnsafe <UBlueprint> levelBlueprints = new TArrayUnsafe <UBlueprint>())
                            {
                                Native.Native_ULevel.GetLevelBlueprints(level.Address, levelBlueprints.Address);
                                foreach (UBlueprint blueprint in levelBlueprints)
                                {
                                    UBlueprintGeneratedClass blueprintGeneratedClass = blueprint.GeneratedClass as UBlueprintGeneratedClass;
                                    if (blueprintGeneratedClass != null)
                                    {
                                        //GenerateCodeForStruct(blueprintGeneratedClass);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (registeredCrashHandler)
            {
                FCoreDelegates.OnHandleSystemError.Unbind(OnAssetLoadingCrash);
            }

            assetCache.Save();

            EndGenerateModule(module);
            EndGenerateModules();
        }
예제 #8
0
        public static List <FAssetData> Load(FARFilter filter)
        {
            List <FAssetData> assets = new List <FAssetData>();

            IntPtr assetsArrayPtr = Native_FAssetRegistryModule.GetAssets(filter.GetAddress());
            TArrayUnsafeRef <FAssetDataNative> nativeAssets = new TArrayUnsafeRef <FAssetDataNative>(assetsArrayPtr);

            for (int i = 0; i < nativeAssets.Count; i++)
            {
                FAssetDataNative nativeAsset = nativeAssets[i];

                FAssetData asset = new FAssetData();
                asset.ObjectPath   = nativeAsset.ObjectPath;
                asset.PackageName  = nativeAsset.PackageName;
                asset.PackagePath  = nativeAsset.PackagePath;
                asset.AssetName    = nativeAsset.AssetName;
                asset.AssetClass   = nativeAsset.AssetClass;
                asset.IsValid      = Native_FAssetData.IsValid(ref nativeAsset);
                asset.IsUAsset     = Native_FAssetData.IsUAsset(ref nativeAsset);
                asset.IsRedirector = Native_FAssetData.IsRedirector(ref nativeAsset);
                using (FStringUnsafe fullNameUnsafe = new FStringUnsafe())
                {
                    Native_FAssetData.GetFullName(ref nativeAsset, ref fullNameUnsafe.Array);
                    asset.FullName = fullNameUnsafe.Value;
                }
                using (FStringUnsafe exportTextNameUnsafe = new FStringUnsafe())
                {
                    Native_FAssetData.GetExportTextName(ref nativeAsset, ref exportTextNameUnsafe.Array);
                    asset.ExportTextName = exportTextNameUnsafe.Value;
                }

                FName[]  tags   = null;
                string[] values = null;

                using (TArrayUnsafe <FName> tagsUnsafe = new TArrayUnsafe <FName>())
                    using (TArrayUnsafe <string> valuesUnsafe = new TArrayUnsafe <string>())
                    {
                        Native_FAssetData.Get_TagsAndValues(ref nativeAsset, tagsUnsafe.Address, valuesUnsafe.Address);
                        tags   = tagsUnsafe.ToArray();
                        values = valuesUnsafe.ToArray();
                    }

                if (tags != null && values != null && tags.Length == values.Length)
                {
                    for (int j = 0; j < tags.Length; j++)
                    {
                        asset.TagsAndValues[tags[j]] = values[j];
                    }
                }

                using (TArrayUnsafe <int> chunkIdsUnsafe = new TArrayUnsafe <int>(nativeAsset.ChunkIDs))
                {
                    asset.ChunkIDs.AddRange(chunkIdsUnsafe.ToArray());
                }

                assets.Add(asset);
            }

            Native_FAssetRegistryModule.DeleteAssetsArray(assetsArrayPtr);

            return(assets);
        }