Пример #1
0
 /// <summary>
 /// Looks for a given function name
 /// </summary>
 public UFunction FindFunctionChecked(FName name)
 {
     return(GCHelper.Find <UFunction>(Native_UObject.FindFunctionChecked(Address, ref name)));
 }
Пример #2
0
 /// <summary>
 /// Traverses the outer chain searching for the next object of a certain type.  (T must be derived from UObject)
 /// </summary>
 /// <param name="target">class to search for</param>
 /// <returns>a pointer to the first object in this object's Outer chain which is of the correct type.</returns>
 public UObject GetTypedOuter(UClass target)
 {
     return(GCHelper.Find(Native_UObjectBaseUtility.GetTypedOuter(Address, target == null ? IntPtr.Zero : target.Address)));
 }
Пример #3
0
 /// <summary>
 /// Finds the most-derived class which is a parent of both TestClass and this object's class.
 /// </summary>
 /// <param name="testClass"></param>
 /// <returns>the class to find the common base for</returns>
 public UClass FindNearestCommonBaseClass(UClass testClass)
 {
     return(GCHelper.Find <UClass>(Native_UObjectBaseUtility.FindNearestCommonBaseClass(Address, testClass == null ? IntPtr.Zero : testClass.Address)));
 }
Пример #4
0
 /// <summary>
 /// Return the class of the object that is being constructed
 /// </summary>
 public UClass GetClass()
 {
     return(GCHelper.Find <UClass>(Native_FObjectInitializer.GetClass(NativeObjectInitializer)));
 }
Пример #5
0
        public T this[int index]
        {
            get
            {
                if (!nativeArray->IsValidIndex(index))
                {
                    throw new IndexOutOfRangeException();
                }

                IntPtr address = IntPtr.Add(nativeArray->Data, numBytesPerElement * index);
                if (isUObject)
                {
                    return((T)(object)GCHelper.Find(Marshal.ReadIntPtr(address)));
                }
                else if (isString)
                {
                    return((T)(object)FStringMarshaler.FromPtr(address));
                }
                else
                {
                    return((T)Marshal.PtrToStructure(address, typeof(T)));
                }
            }
            set
            {
                if (!nativeArray->IsValidIndex(index))
                {
                    throw new IndexOutOfRangeException();
                }

                IntPtr address = IntPtr.Add(nativeArray->Data, numBytesPerElement * index);
                if (isUObject)
                {
                    if (value == null)
                    {
                        Marshal.WriteIntPtr(address, IntPtr.Zero);
                    }
                    else
                    {
                        UObject obj = (UObject)(object)value;
                        Marshal.WriteIntPtr(address, obj.Address);
                    }
                }
                else if (isString)
                {
                    unsafe
                    {
                        // Get the current value, clear the current value and write the new value
                        FScriptArray *current = (FScriptArray *)address;
                        current->Destroy();

                        string valueStr = value == null ? null : (string)(object)value;
                        if (!string.IsNullOrEmpty(valueStr))
                        {
                            FStringMarshaler.ToArray(address, valueStr);
                        }
                    }
                }
                else
                {
                    Marshal.StructureToPtr(value, address, false);
                }
            }
        }
Пример #6
0
 public UObject GetObjectPropertyValue_InContainer(IntPtr propertyValueAddress, int arrayIndex)
 {
     return(GCHelper.Find(Native_UObjectPropertyBase.GetObjectPropertyValue_InContainer(Address, propertyValueAddress, arrayIndex)));
 }
Пример #7
0
 /// <summary>
 /// Return the object that is being constructed
 /// </summary>
 public UObject GetObj()
 {
     return(GCHelper.Find(Native_FObjectInitializer.GetObj(NativeObjectInitializer)));
 }
Пример #8
0
 /// <summary>
 /// Return the UEnum if this property is a UByteProperty with a non-null Enum
 /// </summary>
 /// <returns></returns>
 public UEnum GetIntPropertyEnum()
 {
     return(GCHelper.Find <UEnum>(Native_UNumericProperty.GetIntPropertyEnum(Address)));
 }
Пример #9
0
 public UObject GetValuePtr(IntPtr address)
 {
     return(GCHelper.Find(Marshal.ReadIntPtr(address)));
 }
Пример #10
0
        public void GenerateCodeForGame(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);
                foreach (FAssetData asset in assets)
                {
                    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();
        }
Пример #11
0
 /// <summary>
 /// Returns the property representing the element of the set
 /// </summary>
 public UProperty GetElementProperty()
 {
     return(GCHelper.Find <UProperty>(elementProp));
 }
Пример #12
0
 /// <summary>
 /// Attempts to find a currently loaded object that matches this object ID
 /// </summary>
 /// <returns>Found UObject, or NULL if not currently loaded</returns>
 public UObject ResolveObject()
 {
     return(GCHelper.Find(Native_FSoftObjectPath.ResolveObject(ref this)));
 }
Пример #13
0
 /// <summary>
 /// Attempts to load the asset.
 /// </summary>
 /// <returns>Loaded UObject, or null if the asset fails to load, or if the reference is not valid.</returns>
 public UObject TryLoad()
 {
     return(GCHelper.Find(Native_FSoftObjectPath.TryLoad(ref this)));
 }
Пример #14
0
 public UObject GetObjectPropertyValue(IntPtr propertyValueAddress)
 {
     return(GCHelper.Find(Native_UObjectPropertyBase.GetObjectPropertyValue(Address, propertyValueAddress)));
 }
Пример #15
0
 /// <summary>
 /// Returns a pointer to the UEnum of this property
 /// </summary>
 /// <returns></returns>
 public UEnum GetEnum()
 {
     return(GCHelper.Find <UEnum>(Native_UEnumProperty.GetEnum(Address)));
 }
Пример #16
0
 /// <summary>
 /// Return the archetype that this object will copy properties from later
 /// </summary>
 public UObject GetArchetype()
 {
     return(GCHelper.Find(Native_FObjectInitializer.GetArchetype(NativeObjectInitializer)));
 }
Пример #17
0
 /// <summary>
 /// Returns the numeric property which represents the integral type of the enum.
 /// </summary>
 /// <returns></returns>
 public UNumericProperty GetUnderlyingProperty()
 {
     return(GCHelper.Find <UNumericProperty>(Native_UEnumProperty.GetUnderlyingProperty(Address)));
 }
Пример #18
0
 /// <summary>
 /// Returns the replication owner, which is the property itself, or NULL if this isn't important for replication.
 /// It is relevant if the property is a net relevant and not being run in the editor
 /// </summary>
 /// <returns></returns>
 public UProperty GetRepOwner()
 {
     return(GCHelper.Find <UProperty>(Native_UProperty.GetRepOwner(Address)));
 }