示例#1
0
 public TObjectIterator(EObjectFlags additionalExclusionFlags       = EObjectFlags.ClassDefaultObject,
                        bool includeDerivedClasses                  = true,
                        EInternalObjectFlags internalExclusionFlags = EInternalObjectFlags.None)
 {
     index       = -1;
     objectArray = UObjectHash.GetObjectsOfClass <T>(includeDerivedClasses, additionalExclusionFlags, internalExclusionFlags);
 }
示例#2
0
 /// <summary>
 /// Gets all objects, including class default objects.
 /// </summary>
 public static FObjectIterator GetObjectsEx(
     bool onlyGCedObjects = false,
     EObjectFlags additionalExclusionFlags       = EObjectFlags.NoFlags,
     EInternalObjectFlags internalExclusionFlags = EInternalObjectFlags.None)
 {
     return(new FObjectIterator(null, onlyGCedObjects, additionalExclusionFlags, internalExclusionFlags));
 }
示例#3
0
 /// <summary>
 /// Gets all objects which inherit from a specified base class.
 /// Does not include any class default objects
 /// </summary>
 public static TObjectIterator <T> GetObjects <T>(
     EObjectFlags additionalExclusionFlags       = EObjectFlags.ClassDefaultObject,
     bool includeDerivedClasses                  = true,
     EInternalObjectFlags internalExclusionFlags = EInternalObjectFlags.None) where T : UObject
 {
     return(new TObjectIterator <T>(additionalExclusionFlags, includeDerivedClasses, internalExclusionFlags));
 }
示例#4
0
 /// <summary>
 /// Gets all objects, including class default objects.
 /// </summary>
 public static FObjectIterator GetObjectsEx <T>(
     bool onlyGCedObjects = false,
     EObjectFlags additionalExclusionFlags       = EObjectFlags.NoFlags,
     EInternalObjectFlags internalExclusionFlags = EInternalObjectFlags.None) where T : UObject
 {
     return(GetObjectsEx(UClass.GetClass <T>(), onlyGCedObjects, additionalExclusionFlags, internalExclusionFlags));
 }
示例#5
0
        /// <summary>
        /// Create a new instance of an object or replace an existing object.  If both an Outer and Name are specified, and there is an object already in memory with the same Class, Outer, and Name, the
        /// existing object will be destructed, and the new object will be created in its place.
        /// </summary>
        /// <param name="unrealClass">the class of the object to create</param>
        /// <param name="outer">the object to create this object within (the Outer property for the new object will be set to the value specified here).</param>
        /// <param name="name">the name to give the new object. If no value (NAME_None) is specified, the object will be given a unique name in the form of ClassName_#.</param>
        /// <param name="outReusedSubobject">flag indicating if the object is a subobject that has already been created (in which case further initialization is not necessary).</param>
        /// <param name="setFlags">the ObjectFlags to assign to the new object. some flags can affect the behavior of constructing the object.</param>
        /// <param name="internalSetFlags">the InternalObjectFlags to assign to the new object. some flags can affect the behavior of constructing the object.</param>
        /// <param name="canReuseSubobjects">if set to true, SAO will not attempt to destroy a subobject if it already exists in memory.</param>
        /// <returns>a pointer to a fully initialized object of the specified class.</returns>
        public static UObject StaticAllocateObject(UClass unrealClass, ObjectOuter outer, FName name, out bool outReusedSubobject,
                                                   EObjectFlags setFlags, EInternalObjectFlags internalSetFlags, bool canReuseSubobjects = false)
        {
            csbool  outReusedSubobjectTemp;
            UObject result = GCHelper.Find(Native_UObjectGlobals.StaticAllocateObject(
                                               unrealClass == null ? IntPtr.Zero : unrealClass.Address,
                                               outer.Address, ref name, setFlags, internalSetFlags, canReuseSubobjects, out outReusedSubobjectTemp));

            outReusedSubobject = outReusedSubobjectTemp;
            return(result);
        }
示例#6
0
        /// <summary>
        /// Find an optional object, relies on the name being unqualified
        /// </summary>
        public static T FindObjectFast <T>(
            ObjectOuter outer,
            FName name,
            bool exactClass             = false,
            bool anyPackage             = false,
            EObjectFlags exclusiveFlags = EObjectFlags.NoFlags,
            EInternalObjectFlags exclusiveInternalFlags = EInternalObjectFlags.None) where T : UObject
        {
            UClass unrealClass = UClass.GetClass <T>();

            return(GCHelper.Find <T>(Native_UObjectGlobals.StaticFindObjectFast(
                                         unrealClass == null ? IntPtr.Zero : unrealClass.Address,
                                         outer.Address, ref name, exactClass, anyPackage, exclusiveFlags, exclusiveInternalFlags)));
        }
示例#7
0
 public FObjectIterator(UClass unrealClass,
                        bool onlyGCedObjects = false,
                        EObjectFlags additionalExclusionFlags       = EObjectFlags.NoFlags,
                        EInternalObjectFlags internalExclusionFlags = EInternalObjectFlags.None)
 {
     objectArrayPtr              = Native_FUObjectArray.GetGUObjectArray();
     index                       = -1;
     this.unrealClass            = unrealClass;
     this.exclusionFlags         = additionalExclusionFlags;
     this.internalExclusionFlags = internalExclusionFlags;
     if (this.unrealClass == UClass.GetClass <UObject>())
     {
         // Set to null to avoid additional UClass checks if this already the UObject class
         this.unrealClass = null;
     }
 }
示例#8
0
 /// <summary>
 /// Creates a copy of SourceObject using the Outer and Name specified, as well as copies of all objects contained by SourceObject.
 /// Any objects referenced by SourceOuter or RootObject and contained by SourceOuter are also copied, maintaining their name relative to SourceOuter.  Any
 /// references to objects that are duplicated are automatically replaced with the copy of the object.
 /// </summary>
 /// <typeparam name="T">the object type</typeparam>
 /// <param name="sourceObject">the object to duplicate</param>
 /// <param name="outer">the object to use as the Outer for the copy of SourceObject</param>
 /// <param name="name">the name to use for the copy of SourceObject</param>
 /// <param name="flagMask">a bitmask of EObjectFlags that should be propagated to the object copies.  The resulting object copies will only have the object flags
 /// specified copied from their source object.</param>
 /// <param name="destClass">optional class to specify for the destination object. MUST BE SERIALIZATION COMPATIBLE WITH SOURCE OBJECT!!!</param>
 /// <param name="duplicateForPIE"></param>
 /// <param name="internalFlagsMask">bitmask of EInternalObjectFlags that should be propagated to the object copies.</param>
 /// <returns></returns>
 public static T DuplicateObject <T>(
     T sourceObject,
     ObjectOuter outer,
     FName name                             = default(FName),
     EObjectFlags flagMask                  = EObjectFlags.AllFlags,
     UClass destClass                       = null,
     EDuplicateMode duplicateMode           = EDuplicateMode.Normal,
     EInternalObjectFlags internalFlagsMask = EInternalObjectFlags.AllFlags) where T : UObject
 {
     if (sourceObject != null)
     {
         if (!outer.IsAnyPackage && outer.Object == null)
         {
             outer.Object = GetTransientPackage();
         }
         return(GCHelper.Find <T>(Native_UObjectGlobals.StaticDuplicateObject(
                                      sourceObject == null ? IntPtr.Zero : sourceObject.Address,
                                      outer.Address, ref name, flagMask,
                                      destClass == null ? IntPtr.Zero : destClass.Address,
                                      duplicateMode, internalFlagsMask)));
     }
     return(null);
 }
示例#9
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());
     }
 }
示例#10
0
 /// <summary>
 /// Returns an array of objects of a specific class. Optionally, results can include objects of derived classes as well.
 /// </summary>
 /// <typeparam name="T">Class of the objects to return.</typeparam>
 /// <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 <T>(bool includeDerivedClasses = true, EObjectFlags additionalExcludeFlags = EObjectFlags.ClassDefaultObject, EInternalObjectFlags exclusionInternalFlags = EInternalObjectFlags.None)
 {
     return(GetObjectsOfClass(UClass.GetClass <T>(), includeDerivedClasses, additionalExcludeFlags, exclusionInternalFlags));
 }
示例#11
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());
     }
 }
示例#12
0
 /// <summary>
 /// Used to safely check whether any of the passed in internal flags are set.
 /// </summary>
 /// <param name="flagsToCheck">Object flags to check for.</param>
 /// <returns>true if any of the passed in flags are set, false otherwise  (including no flags passed in).</returns>
 public bool HasAnyInternalFlags(EInternalObjectFlags flagsToCheck)
 {
     return(Native_UObjectBaseUtility.HasAnyInternalFlags(Address, flagsToCheck));
 }
示例#13
0
 /// <summary>
 /// Sets passed in internal object flags.
 /// </summary>
 /// <param name="flagsToSet">Internal object flags to set.</param>
 public void SetInternalFlags(EInternalObjectFlags flagsToSet)
 {
     Native_UObjectBaseUtility.SetInternalFlags(Address, flagsToSet);
 }
示例#14
0
 /// <summary>
 /// Returns whether an object is referenced, not counting the one
 /// reference at Obj.
 /// </summary>
 /// <param name="res">Object to check</param>
 /// <param name="keepFlags">Objects with these flags will be considered as being referenced</param>
 /// <param name="internalKeepFlags">Objects with these internal flags will be considered as being referenced</param>
 /// <param name="checkSubObjects">Treat subobjects as if they are the same as passed in object</param>
 /// <returns>true if object is referenced, false otherwise</returns>
 public static bool IsReferenced(UObject res, EObjectFlags keepFlags, EInternalObjectFlags internalKeepFlags, bool checkSubObjects = false)
 {
     // TODO: Support FReferencerInformationList
     return(Native_UObjectGlobals.IsReferenced(res == null ? IntPtr.Zero : res.Address, keepFlags, internalKeepFlags, checkSubObjects, IntPtr.Zero));
 }