Ejemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="outer">value for LimitOuter</param>
 /// <param name="requireDirectOuter">Determines whether nested objects contained within LimitOuter are considered.</param>
 /// <param name="shouldIgnoreArchetype">whether to disable serialization of ObjectArchetype references</param>
 /// <param name="serializeRecursively">only applicable when LimitOuter != NULL && bRequireDirectOuter==true;
 /// serializes each object encountered looking for subobjects of referenced
 /// objects that have LimitOuter for their Outer (i.e. nested subobjects/components)</param>
 /// <param name="shouldIgnoreTransient">true to skip serialization of transient properties</param>
 public FReferenceFinder(IntPtr outer, bool requireDirectOuter = true, bool shouldIgnoreArchetype  = false,
                         bool serializeRecursively             = false, bool shouldIgnoreTransient = false)
 {
     objArray = new TArrayUnsafe <IntPtr>();
     address  = Native_FReferenceFinder.New(objArray.Address, outer, requireDirectOuter, shouldIgnoreArchetype,
                                            serializeRecursively, shouldIgnoreTransient);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Get the localization paths for all enabled plugins.
 /// </summary>
 /// <returns>The localization paths for all enabled plugins.</returns>
 public string[] GetLocalizationPathsForEnabledPlugins()
 {
     using (TArrayUnsafe <string> resultUnsafe = new TArrayUnsafe <string>())
     {
         Native_IPluginManager.GetLocalizationPathsForEnabledPlugins(Address, resultUnsafe.Address);
         return(resultUnsafe.ToArray());
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Uses the TArchiveObjectReferenceCollector to build a list of all components referenced by this object which have this object as the outer
 /// </summary>
 /// <param name="includeNestedSubobjects">controls whether subobjects which are contained by this object, but do not have this object
 /// as its direct Outer should be included</param>
 /// <returns>the array that should be populated with the default subobjects "owned" by this object</returns>
 public UObject[] CollectDefaultSubobjects(bool includeNestedSubobjects = false)
 {
     using (TArrayUnsafe <UObject> result = new TArrayUnsafe <UObject>())
     {
         Native_UObject.CollectDefaultSubobjects(Address, result.Address, includeNestedSubobjects);
         return(result.ToArray());
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets an array of plugins that loaded their own content pak file
 /// </summary>
 public IPlugin[] GetPluginsWithPakFile()
 {
     using (TArrayUnsafe <FSharedPtr> resultUnsafe = new TArrayUnsafe <FSharedPtr>())
     {
         Native_IPluginManager.GetPluginsWithPakFile(Address, resultUnsafe.Address);
         return(GetPluginArray(resultUnsafe));
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Gets all default instanced objects (often components).
 /// </summary>
 /// <param name="outDefaultSubobjects">An array to be filled with default subobjects.</param>
 public void GetDefaultObjectSubobjects(out UObject[] outDefaultSubobjects)
 {
     using (TArrayUnsafe <UObject> defaultSubobjectsUnsafe = new TArrayUnsafe <UObject>())
     {
         Native_UClass.GetDefaultObjectSubobjects(Address, defaultSubobjectsUnsafe.Address);
         outDefaultSubobjects = defaultSubobjectsUnsafe.ToArray();
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Returns an array of classes that were derived from the specified class.
 /// </summary>
 /// <param name="classToLookFor">The parent class of the classes to return.</param>
 /// <param name="recursive">If true, the results will include children of the children classes, recursively. Otherwise, only direct decedents will be included.</param>
 /// <returns></returns>
 public static UClass[] GetDerivedClasses(UClass classToLookFor, bool recursive = true)
 {
     using (TArrayUnsafe <UClass> result = new TArrayUnsafe <UClass>())
     {
         Native_UObjectHash.GetDerivedClasses(classToLookFor.Address, result.Address, recursive);
         return(result.ToArray());
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Finds the common base class that parents the array of classes passed in.
 /// </summary>
 /// <param name="inClasses">the array of classes to find the common base for</param>
 /// <returns>the common base class or NULL</returns>
 public static UClass FindCommonBase(UClass[] inClasses)
 {
     using (TArrayUnsafe <UClass> inClassesUnsafe = new TArrayUnsafe <UClass>())
     {
         inClassesUnsafe.AddRange(inClasses);
         return(GCHelper.Find <UClass>(Native_UClass.FindCommonBaseMany(inClassesUnsafe.Address)));
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Queries all of the root content paths, like "/Game/", "/Engine/", and any dynamically added paths
 /// </summary>
 /// <returns>List of content paths</returns>
 public static string[] QueryRootContentPaths()
 {
     using (TArrayUnsafe <string> resultUnsafe = new TArrayUnsafe <string>())
     {
         Native_FPackageName.QueryRootContentPaths(resultUnsafe.Address);
         return(resultUnsafe.ToArray());
     }
 }
Ejemplo n.º 9
0
 public void Execute(string[] args, UObject world, IntPtr outputDevice)
 {
     using (TArrayUnsafe <string> argsUnsafe = new TArrayUnsafe <string>())
     {
         argsUnsafe.AddRange(args);
         Native_IConsoleCommand.Execute(Address, argsUnsafe.Address, world == null ? IntPtr.Zero : world.Address, outputDevice);
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Return all objects with a given outer
 /// </summary>
 /// <param name="outer">Outer to search for</param>
 /// <param name="includeNestedObjects">If true, then things whose outers directly or indirectly have Outer as an outer are included, these are the nested objects.</param>
 /// <param name="exclusionFlags">Specifies flags to use as a filter for which objects to return</param>
 /// <param name="exclusionInternalFlags">Specifies internal flags to use as a filter for which objects to return</param>
 /// <returns></returns>
 public static UObject[] GetObjectsWithOuter(UObject outer, bool includeNestedObjects = true, EObjectFlags exclusionFlags = EObjectFlags.NoFlags, EInternalObjectFlags exclusionInternalFlags = EInternalObjectFlags.None)
 {
     using (TArrayUnsafe <UObject> result = new TArrayUnsafe <UObject>())
     {
         Native_UObjectHash.GetObjectsWithOuter(outer.Address, result.Address, includeNestedObjects, exclusionFlags, exclusionInternalFlags);
         return(result.ToArray());
     }
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Returns an array of objects of a specific class. Optionally, results can include objects of derived classes as well.
 /// </summary>
 /// <param name="classToLookFor">Class of the objects to return.</param>
 /// <param name="includeDerivedClasses">If true, the results will include objects of child classes as well.</param>
 /// <param name="additionalExcludeFlags">Objects with any of these flags will be excluded from the results.</param>
 /// <param name="exclusionInternalFlags">Specifies internal flags to use as a filter for which objects to return</param>
 /// <returns></returns>
 public static UObject[] GetObjectsOfClass(UClass classToLookFor, bool includeDerivedClasses = true, EObjectFlags additionalExcludeFlags = EObjectFlags.ClassDefaultObject, EInternalObjectFlags exclusionInternalFlags = EInternalObjectFlags.None)
 {
     using (TArrayUnsafe <UObject> result = new TArrayUnsafe <UObject>())
     {
         Native_UObjectHash.GetObjectsOfClass(classToLookFor.Address, result.Address, includeDerivedClasses, additionalExcludeFlags, exclusionInternalFlags);
         return(result.ToArray());
     }
 }
Ejemplo n.º 12
0
        private static void SetAllMetaData(IntPtr obj, ManagedUnrealReflectionBase field, UMeta.Target target)
        {
            if (!FBuild.WithEditor || !metaDataEnabled || field == null || string.IsNullOrEmpty(field.Path))
            {
                return;
            }

            IntPtr outermost = Native_UObjectBaseUtility.GetOutermost(obj);
            IntPtr metadata  = outermost == IntPtr.Zero ? IntPtr.Zero : Native_UPackage.GetMetaData(outermost);

            if (metadata == IntPtr.Zero)
            {
                return;
            }

            Dictionary <FName, string> values = null;

            if (!metaDataMap.TryGetValue(field.Path.ToLower(), out values))
            {
                values = new Dictionary <FName, string>();
            }

            switch (target)
            {
            // Class / interface
            case UMeta.Target.Class:
            case UMeta.Target.Interface:
                // See GetMetadataKeyword (Engine\Source\Programs\UnrealHeaderTool\Private\BaseParser.cpp)
                // "NotBlueprintable" removes "NotBlueprintable" and adds "IsBlueprintBase=false"
                // "Blueprintable" and adds "IsBlueprintBase=true"
                // "BlueprintInternalUseOnly" adds "BlueprintType"

                if (!values.ContainsKey(UMeta.GetKeyName(MDClass.IsBlueprintBase)))
                {
                    if (values.ContainsKey(UMeta.GetKeyName(MDClass.Blueprintable)))
                    {
                        values[UMeta.GetKeyName(MDClass.IsBlueprintBase)] = "true";
                    }
                    else if (values.ContainsKey(UMeta.GetKeyName(MDClass.NotBlueprintable)))
                    {
                        values[UMeta.GetKeyName(MDClass.IsBlueprintBase)] = "false";
                    }
                }

                MetaDataMergeClassCategories(metadata, obj, values);
                break;
            }
            SetMetaDataBlueprintability(values, target, field as ManagedUnrealTypeInfo);

            using (TArrayUnsafe <FName> keysUnsafe = new TArrayUnsafe <FName>())
                using (TArrayUnsafe <string> valuesUnsafe = new TArrayUnsafe <string>())
                {
                    keysUnsafe.AddRange(values.Keys.ToArray());
                    valuesUnsafe.AddRange(values.Values.ToArray());
                    Native_UMetaData.SetObjectValues(metadata, obj, keysUnsafe.Address, valuesUnsafe.Address);
                }
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Utility functions to query the object name redirects list for previous names for a class
 /// </summary>
 /// <param name="currentClassPath">The current name of the class, with a full path</param>
 /// <param name="isInstance">If true, we're an instance, so check instance only maps as well</param>
 /// <returns>Names without path of all classes that were redirected to this name. Empty if none found.</returns>
 public static unsafe FName[] FindPreviousNamesForClass(string currentClassPath, bool isInstance)
 {
     using (FStringUnsafe currentClassPathUnsafe = new FStringUnsafe(currentClassPath))
         using (TArrayUnsafe <FName> resultUnsafe = new TArrayUnsafe <FName>())
         {
             Native_FLinkerLoad.FindPreviousNamesForClass(ref currentClassPathUnsafe.Array, isInstance, resultUnsafe.Address);
             return(resultUnsafe.ToArray());
         }
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Finds module files on the disk for loadable modules matching the specified wildcard.
 /// </summary>
 /// <param name="wildcardWithoutExtension">Filename part (no path, no extension, no build config info) to search for.</param>
 /// <returns>List of modules found.</returns>
 public FName[] FindModules(string wildcardWithoutExtension)
 {
     using (FStringUnsafe wildcardWithoutExtensionUnsafe = new FStringUnsafe(wildcardWithoutExtension))
         using (TArrayUnsafe <FName> modulesUnsafe = new TArrayUnsafe <FName>())
         {
             Native_FModuleManager.FindModules(Address, ref wildcardWithoutExtensionUnsafe.Array, modulesUnsafe.Address);
             return(modulesUnsafe.ToArray());
         }
 }
Ejemplo n.º 15
0
 public string[] GetConsoleHistory(string key)
 {
     using (FStringUnsafe keyUnsafe = new FStringUnsafe(key))
         using (TArrayUnsafe <string> result = new TArrayUnsafe <string>())
         {
             Native_IConsoleManager.GetConsoleHistory(Address, ref keyUnsafe.Array, result.Address);
             return(result.ToArray());
         }
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Sets the array of enums.
 /// </summary>
 /// <param name="names">List of enum names.</param>
 /// <param name="inCppForm">The form of enum.</param>
 /// <param name="addMaxKeyIfMissing">Should a default Max item be added.</param>
 /// <returns>true unless the MAX enum already exists and isn't the last enum.</returns>
 public bool SetEnums(Dictionary <FName, long> names, UEnum.ECppForm inCppForm, bool addMaxKeyIfMissing = true)
 {
     using (TArrayUnsafe <FName> namesUnsafe = new TArrayUnsafe <FName>())
         using (TArrayUnsafe <long> valuesUnsafe = new TArrayUnsafe <long>())
         {
             namesUnsafe.AddRange(names.Keys.ToArray());
             valuesUnsafe.AddRange(names.Values.ToArray());
             return(Native_UEnum.SetEnums(Address, namesUnsafe.Address, valuesUnsafe.Address, inCppForm, addMaxKeyIfMissing));
         }
 }
Ejemplo n.º 17
0
 /// <summary>
 /// This will recurse over a directory structure looking for packages.
 /// </summary>
 /// <param name="rootDir">The root of the directory structure to recurse through</param>
 /// <param name="packages">The output array that is filled out with a file paths</param>
 /// <returns>Returns true if any packages have been found, otherwise false</returns>
 public static bool FindPackagesInDirectory(string rootDir, out string[] packages)
 {
     using (FStringUnsafe rootDirUnsafe = new FStringUnsafe(rootDir))
         using (TArrayUnsafe <string> packagesUnsafe = new TArrayUnsafe <string>())
         {
             bool result = Native_FPackageName.FindPackagesInDirectory(packagesUnsafe.Address, ref rootDirUnsafe.Array);
             packages = packagesUnsafe.ToArray();
             return(result);
         }
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Returns list of names it may have been before
 /// </summary>
 public static bool FindPreviousNames(ECoreRedirectFlags type, FCoreRedirectObjectName newObjectName,
                                      out FCoreRedirectObjectName[] previousNames)
 {
     using (TArrayUnsafe <FCoreRedirectObjectName> previousNamesUnsafe = new TArrayUnsafe <FCoreRedirectObjectName>())
     {
         bool result = Native_FCoreRedirects.FindPreviousNames(type, ref newObjectName, previousNamesUnsafe.Address);
         previousNames = previousNamesUnsafe.ToArray();
         return(result);
     }
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Set the key/value pair in the Property's metadata
 /// </summary>
 /// <param name="obj">the object to set the metadata for</param>
 /// <param name="value">The metadata key/value pairs</param>
 public void SetObjectValues(UObject obj, Dictionary <FName, string> value)
 {
     using (TArrayUnsafe <FName> keysUnsafe = new TArrayUnsafe <FName>())
         using (TArrayUnsafe <string> valuesUnsafe = new TArrayUnsafe <string>())
         {
             keysUnsafe.AddRange(value.Keys.ToArray());
             valuesUnsafe.AddRange(value.Values.ToArray());
             Native_UMetaData.SetObjectValues(Address, obj == null ? IntPtr.Zero : obj.Address, keysUnsafe.Address, valuesUnsafe.Address);
         }
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Gets an array of all blueprints used to generate this class and its parents.  0th elements is the BP used to generate InClass
 /// </summary>
 /// <param name="inClass">The class to get the blueprint lineage for</param>
 /// <param name="outBlueprintParents">Array with the blueprints used to generate this class and its parents.  0th = this, Nth = least derived BP-based parent</param>
 /// <returns>true if there were no status errors in any of the parent blueprints, otherwise false</returns>
 public static bool GetBlueprintHierarchyFromClass(UClass inClass, UBlueprint[] outBlueprintParents)
 {
     using (TArrayUnsafe <UBlueprint> outBlueprintParentsUnsafe = new TArrayUnsafe <UBlueprint>())
     {
         bool result = Native_UBlueprint.GetBlueprintHierarchyFromClass(
             inClass == null ? IntPtr.Zero : inClass.Address,
             outBlueprintParentsUnsafe.Address);
         outBlueprintParents = outBlueprintParentsUnsafe.ToArray();
         return(result);
     }
 }
Ejemplo n.º 21
0
 public void Dispose()
 {
     if (address != IntPtr.Zero)
     {
         Native_FReferenceFinder.Delete(address);
         address = IntPtr.Zero;
     }
     if (objArray != null)
     {
         objArray.Dispose();
         objArray = null;
     }
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Returns true if this property, or in the case of e.g. array or struct properties any sub- property, contains a
 /// UObject reference.
 /// </summary>
 /// <returns>true if property (or sub- properties) contain a UObject reference, false otherwise</returns>
 public bool ContainsObjectReference(List <UStructProperty> encounteredStructProps)
 {
     using (TArrayUnsafe <UStructProperty> encounteredStructPropsUnsafe = new TArrayUnsafe <UStructProperty>())
     {
         bool result = Native_UProperty.ContainsObjectReference(Address, encounteredStructPropsUnsafe.Address);
         if (encounteredStructProps != null)
         {
             encounteredStructProps.Clear();
             encounteredStructProps.AddRange(encounteredStructPropsUnsafe);
         }
         return(result);
     }
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Emits tokens used by realtime garbage collection code to passed in ReferenceTokenStream. The offset emitted is relative
 /// to the passed in BaseOffset which is used by e.g. arrays of structs.
 /// </summary>
 /// <param name="unrealClass"></param>
 /// <param name="baseOffset"></param>
 /// <param name="encounteredStructProps"></param>
 public void EmitReferenceInfo(UClass unrealClass, int baseOffset, List <UStructProperty> encounteredStructProps)
 {
     using (TArrayUnsafe <UStructProperty> encounteredStructPropsUnsafe = new TArrayUnsafe <UStructProperty>())
     {
         Native_UProperty.EmitReferenceInfo(Address, unrealClass == null ? IntPtr.Zero : unrealClass.Address, baseOffset,
                                            encounteredStructPropsUnsafe.Address);
         if (encounteredStructProps != null)
         {
             encounteredStructProps.Clear();
             encounteredStructProps.AddRange(encounteredStructPropsUnsafe);
         }
     }
 }
Ejemplo n.º 24
0
        public IntPtr GetAddress()
        {
            if (address == IntPtr.Zero)
            {
                return(address);
            }

            using (TArrayUnsafe <FName> packageNamesUnsafe = new TArrayUnsafe <FName>())
            {
                packageNamesUnsafe.AddRange(PackageNames.ToArray());
                Native_FARFilter.Set_PackageNames(address, packageNamesUnsafe.Address);
            }

            using (TArrayUnsafe <FName> packagePathsUnsafe = new TArrayUnsafe <FName>())
            {
                packagePathsUnsafe.AddRange(PackagePaths.ToArray());
                Native_FARFilter.Set_PackagePaths(address, packagePathsUnsafe.Address);
            }

            using (TArrayUnsafe <FName> objectPathsUnsafe = new TArrayUnsafe <FName>())
            {
                objectPathsUnsafe.AddRange(ObjectPaths.ToArray());
                Native_FARFilter.Set_ObjectPaths(address, objectPathsUnsafe.Address);
            }

            using (TArrayUnsafe <FName> classNamesUnsafe = new TArrayUnsafe <FName>())
            {
                classNamesUnsafe.AddRange(ClassNames.ToArray());
                Native_FARFilter.Set_ClassNames(address, classNamesUnsafe.Address);
            }

            using (TArrayUnsafe <FName> tagsUnsafe = new TArrayUnsafe <FName>())
                using (TArrayUnsafe <string> valuesUnsafe = new TArrayUnsafe <string>())
                {
                    tagsUnsafe.AddRange(TagsAndValues.Keys.ToArray());
                    valuesUnsafe.AddRange(TagsAndValues.Values.ToArray());
                    Native_FARFilter.Set_TagsAndValues(address, tagsUnsafe.Address, valuesUnsafe.Address);
                }

            using (TArrayUnsafe <FName> recursiveClassesExclusionSet = new TArrayUnsafe <FName>())
            {
                recursiveClassesExclusionSet.AddRange(RecursiveClassesExclusionSet.ToArray());
                Native_FARFilter.Set_RecursiveClassesExclusionSet(address, recursiveClassesExclusionSet.Address);
            }

            Native_FARFilter.Set_bRecursivePaths(address, RecursivePaths);
            Native_FARFilter.Set_bRecursiveClasses(address, RecursiveClasses);
            Native_FARFilter.Set_bIncludeOnlyOnDiskAssets(address, IncludeOnlyOnDiskAssets);

            return(address);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Queries information about all of the currently known modules.
        /// </summary>
        /// <returns>Status of all modules.</returns>
        public FModuleStatus[] QueryModules()
        {
            List <FModuleStatus> modules = new List <FModuleStatus>();

            using (TArrayUnsafe <FModuleStatusNative> modulesUnsafe = new TArrayUnsafe <FModuleStatusNative>())
            {
                Native_FModuleManager.QueryModules(Address, modulesUnsafe.Address);
                foreach (FModuleStatusNative moduleStatusUnsafe in modulesUnsafe)
                {
                    modules.Add(new FModuleStatus(moduleStatusUnsafe));
                }
            }
            return(modules.ToArray());
        }
Ejemplo n.º 26
0
        private IPlugin[] GetPluginArray(TArrayUnsafe <FSharedPtr> sharedPtrs)
        {
            int count = sharedPtrs.Count;

            IPlugin[] result = new IPlugin[count];
            for (int i = 0; i < count; i++)
            {
                FSharedPtr sharedPtr = sharedPtrs[i];
                if (sharedPtr.IsValid())
                {
                    result[i] = new IPlugin(sharedPtr);
                }
            }
            return(result);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Checks whether modules for the enabled plug-ins are up to date.
        /// </summary>
        /// <param name="incompatibleModules">Incompatible module names.</param>
        /// <returns>true if the enabled plug-in modules are up to date.</returns>
        public bool CheckModuleCompatibility(out string[] incompatibleModules)
        {
            // !IS_MONOLITHIC
            if (Native_IPluginManager.CheckModuleCompatibility == null)
            {
                incompatibleModules = null;
                return(true);
            }

            using (TArrayUnsafe <string> incompatibleModulesUnsafe = new TArrayUnsafe <string>())
            {
                bool result = Native_IPluginManager.CheckModuleCompatibility(Address, incompatibleModulesUnsafe.Address);
                incompatibleModules = incompatibleModulesUnsafe.ToArray();
                return(result);
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Find the name/value map for metadata for a specific object
        /// </summary>
        public static Dictionary <FName, string> GetMapForObject(UObject obj)
        {
            Dictionary <FName, string> result = new Dictionary <FName, string>();

            using (TArrayUnsafe <FName> keysUnsafe = new TArrayUnsafe <FName>())
                using (TArrayUnsafe <string> valuesUnsafe = new TArrayUnsafe <string>())
                {
                    Native_UMetaData.GetMapForObject(obj == null ? IntPtr.Zero : obj.Address, keysUnsafe.Address, valuesUnsafe.Address);
                    if (keysUnsafe.Count == valuesUnsafe.Count)
                    {
                        int count = keysUnsafe.Count;
                        for (int i = 0; i < count; i++)
                        {
                            result[keysUnsafe[i]] = valuesUnsafe[i];
                        }
                    }
                }
            return(result);
        }
Ejemplo n.º 29
0
        public static Dictionary <FName, string> FindModulePaths(string namePattern, bool canUseCache = true)
        {
            Dictionary <FName, string> result = new Dictionary <FName, string>();

            using (FStringUnsafe namePatternUnsafe = new FStringUnsafe(namePattern))
                using (TArrayUnsafe <FName> keysUnsafe = new TArrayUnsafe <FName>())
                    using (TArrayUnsafe <string> valuesUnsafe = new TArrayUnsafe <string>())
                    {
                        Native_FModulePaths.FindModulePaths(ref namePatternUnsafe.Array, canUseCache, keysUnsafe.Address, valuesUnsafe.Address);

                        if (keysUnsafe.Count == valuesUnsafe.Count)
                        {
                            int count = keysUnsafe.Count;
                            for (int i = 0; i < count; i++)
                            {
                                result[keysUnsafe[i]] = valuesUnsafe[i];
                            }
                        }
                    }

            return(result);
        }
Ejemplo n.º 30
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();
        }