Advertisement
CorrM

UObject

Jun 13th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 56.34 KB | None | 0 0
  1. // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
  2.  
  3. #pragma once
  4.  
  5. /*=============================================================================
  6.     Object.h: Direct base class for all UE4 objects
  7. =============================================================================*/
  8.  
  9. #include "CoreMinimal.h"
  10. #include "UObject/Script.h"
  11. #include "UObject/ObjectMacros.h"
  12. #include "UObject/UObjectBaseUtility.h"
  13. #include "ProfilingDebugging/ResourceSize.h"
  14. #include "UObject/PrimaryAssetId.h"
  15.  
  16. class FConfigCacheIni;
  17. class FEditPropertyChain;
  18. class ITargetPlatform;
  19. class ITransactionObjectAnnotation;
  20. class FTransactionObjectEvent;
  21. struct FFrame;
  22. struct FObjectInstancingGraph;
  23. struct FPropertyChangedChainEvent;
  24.  
  25. DECLARE_LOG_CATEGORY_EXTERN(LogObj, Log, All);
  26.  
  27. /** Parameter enum for CastChecked() function, defines when it will check/assert */
  28. namespace ECastCheckedType
  29. {
  30.     enum Type
  31.     {
  32.         /** Null is okay, only assert on incorrect type */
  33.         NullAllowed,
  34.         /** Null is not allowed, assert on incorrect type or null */
  35.         NullChecked
  36.     };
  37. };
  38.  
  39. /**
  40.  * The base class of all UE4 objects. The type of an object is defined by its UClass.
  41.  * This provides support functions for creating and using objects, and virtual functions that should be overridden in child classes.
  42.  *
  43.  * @see https://docs.unrealengine.com/en-us/Programming/UnrealArchitecture/Objects
  44.  */
  45. class COREUOBJECT_API UObject : public UObjectBaseUtility
  46. {
  47.     // Declarations, normally created by UnrealHeaderTool boilerplate code
  48.     DECLARE_CLASS(UObject,UObject,CLASS_Abstract|CLASS_NoExport|CLASS_Intrinsic|CLASS_MatchedSerializers,CASTCLASS_None,TEXT("/Script/CoreUObject"),NO_API)
  49.     DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(UObject)
  50.     typedef UObject WithinClass;
  51.     static UObject* __VTableCtorCaller(FVTableHelper& Helper)
  52.     {
  53.         return new (EC_InternalUseOnlyConstructor, (UObject*)GetTransientPackage(), NAME_None, RF_NeedLoad | RF_ClassDefaultObject | RF_TagGarbageTemp) UObject(Helper);
  54.     }
  55.     static const TCHAR* StaticConfigName()
  56.     {
  57.         return TEXT("Engine");
  58.     }
  59.     static void StaticRegisterNativesUObject()
  60.     {
  61.     }
  62.  
  63.     /** Default constructor */
  64.     UObject();
  65.  
  66.     /** Deprecated constructor, ObjectInitializer is no longer needed but is supported for older classes. */
  67.     UObject(const FObjectInitializer& ObjectInitializer);
  68.  
  69.     /** DO NOT USE. This constructor is for internal usage only for statically-created objects. */
  70.     UObject(EStaticConstructor, EObjectFlags InFlags);
  71.  
  72.     /** DO NOT USE. This constructor is for internal usage only for hot-reload purposes. */
  73.     UObject(FVTableHelper& Helper);
  74.  
  75.     /** Utility function for templates below */
  76.     UObject* CreateDefaultSubobject(FName SubobjectFName, UClass* ReturnType, UClass* ClassToCreateByDefault, bool bIsRequired, bool bAbstract, bool bIsTransient);
  77.  
  78.     /**
  79.      * Create a component or subobject only to be used with the editor. They will be stripped out in packaged builds.
  80.      * @param   TReturnType                 Class of return type, all overrides must be of this type
  81.      * @param   SubobjectName               Name of the new component
  82.      * @param   bTransient                  True if the component is being assigned to a transient property. This does not make the component itself transient, but does stop it from inheriting parent defaults
  83.      */
  84.     template<class TReturnType>
  85.     TReturnType* CreateEditorOnlyDefaultSubobject(FName SubobjectName, bool bTransient = false)
  86.     {
  87.         UClass* ReturnType = TReturnType::StaticClass();
  88.         return static_cast<TReturnType*>(CreateEditorOnlyDefaultSubobjectImpl(SubobjectName, ReturnType, bTransient));
  89.     }
  90.  
  91.     /**
  92.      * Create a component or subobject.
  93.      * @param   TReturnType                 Class of return type, all overrides must be of this type
  94.      * @param   SubobjectName               Name of the new component
  95.      * @param   bTransient                  True if the component is being assigned to a transient property. This does not make the component itself transient, but does stop it from inheriting parent defaults
  96.      */
  97.     template<class TReturnType>
  98.     TReturnType* CreateDefaultSubobject(FName SubobjectName, bool bTransient = false)
  99.     {
  100.         UClass* ReturnType = TReturnType::StaticClass();
  101.         return static_cast<TReturnType*>(CreateDefaultSubobject(SubobjectName, ReturnType, ReturnType, /*bIsRequired =*/ true, /*bIsAbstract =*/ false, bTransient));
  102.     }
  103.    
  104.     /**
  105.      * Create a component or subobject, allows creating a child class and returning the parent class.
  106.      * @param   TReturnType                 Class of return type, all overrides must be of this type
  107.      * @param   TClassToConstructByDefault  Class of object to actually construct
  108.      * @param   SubobjectName               Name of the new component
  109.      * @param   bTransient                  True if the component is being assigned to a transient property. This does not make the component itself transient, but does stop it from inheriting parent defaults
  110.      */
  111.     template<class TReturnType, class TClassToConstructByDefault>
  112.     TReturnType* CreateDefaultSubobject(FName SubobjectName, bool bTransient = false)
  113.     {
  114.         return static_cast<TReturnType*>(CreateDefaultSubobject(SubobjectName, TReturnType::StaticClass(), TClassToConstructByDefault::StaticClass(), /*bIsRequired =*/ true, /*bIsAbstract =*/ false, bTransient));
  115.     }
  116.    
  117.     /**
  118.      * Create an optional component or subobject. Optional subobjects may not get created.
  119.      * when a derived class specified DoNotCreateDefaultSubobject with the subobject's name.
  120.      * @param   TReturnType                 Class of return type, all overrides must be of this type
  121.      * @param   SubobjectName               Name of the new component
  122.      * @param   bTransient                  True if the component is being assigned to a transient property. This does not make the component itself transient, but does stop it from inheriting parent defaults
  123.      */
  124.     template<class TReturnType>
  125.     TReturnType* CreateOptionalDefaultSubobject(FName SubobjectName, bool bTransient = false)
  126.     {
  127.         UClass* ReturnType = TReturnType::StaticClass();
  128.         return static_cast<TReturnType*>(CreateDefaultSubobject(SubobjectName, ReturnType, ReturnType, /*bIsRequired =*/ false, /*bIsAbstract =*/ false, bTransient));
  129.     }
  130.    
  131.     /**
  132.      * Create a subobject that has the Abstract class flag, child classes are expected to override this by calling CreateDEfaultObject with the same name and a non-abstract class.
  133.      * @param   TReturnType                 Class of return type, all overrides must be of this type
  134.      * @param   SubobjectName               Name of the new component
  135.      * @param   bTransient                  True if the component is being assigned to a transient property. This does not make the component itself transient, but does stop it from inheriting parent defaults
  136.      */
  137.     template<class TReturnType>
  138.     TReturnType* CreateAbstractDefaultSubobject(FName SubobjectName, bool bTransient = false)
  139.     {
  140.         UClass* ReturnType = TReturnType::StaticClass();
  141.         return static_cast<TReturnType*>(CreateDefaultSubobject(SubobjectName, ReturnType, ReturnType, /*bIsRequired =*/ true, /*bIsAbstract =*/ true, bTransient));
  142.     }
  143.  
  144.     /**
  145.      * Gets all default subobjects associated with this object instance.
  146.      * @param   OutDefaultSubobjects    Array containing all default subobjects of this object.
  147.      */
  148.     void GetDefaultSubobjects(TArray<UObject*>& OutDefaultSubobjects);
  149.  
  150.     /**
  151.      * Finds a subobject associated with this object instance by its name
  152.      * @param   Name    Object name to look for
  153.      */
  154.     UObject* GetDefaultSubobjectByName(FName ToFind);
  155.  
  156.     /*----------------------------------
  157.             UObject interface
  158.     ----------------------------------*/
  159.  
  160. protected:
  161.     /**
  162.      * This function actually does the work for the GetDetailedInfo() and is virtual.  
  163.      * It should only be called from GetDetailedInfo as GetDetailedInfo is safe to call on NULL object pointers
  164.      */
  165.     virtual FString GetDetailedInfoInternal() const { return TEXT("No_Detailed_Info_Specified"); }
  166.  
  167. public:
  168.     /**
  169.      * Called after the C++ constructor and after the properties have been initialized, including those loaded from config.
  170.      * This is called before any serialization or other setup has happened.
  171.      */
  172.     virtual void PostInitProperties();
  173.  
  174.     /**
  175.     * Called after the C++ constructor has run on the CDO for a class. This is an obscure routine used to deal with the recursion
  176.     * in the construction of the default materials
  177.     */
  178.     virtual void PostCDOContruct()
  179.     {
  180.     }
  181.  
  182.     /**
  183.      * Called from within SavePackage on the passed in base/root object. The return value of this function will be passed to PostSaveRoot.
  184.      * This is used to allow objects used as a base to perform required actions before saving and cleanup afterwards.
  185.      * @param Filename: Name of the file being saved to (includes path)
  186.  
  187.      * @return  Whether PostSaveRoot needs to perform internal cleanup
  188.      */
  189.     virtual bool PreSaveRoot(const TCHAR* Filename)
  190.     {
  191.         return false;
  192.     }
  193.  
  194.     /**
  195.      * Called from within SavePackage on the passed in base/root object.
  196.      * This function is called after the package has been saved and can perform cleanup.
  197.      *
  198.      * @param   bCleanupIsRequired  Whether PreSaveRoot dirtied state that needs to be cleaned up
  199.      */
  200.     virtual void PostSaveRoot( bool bCleanupIsRequired ) {}
  201.  
  202.     /**
  203.      * Presave function. Gets called once before an object gets serialized for saving. This function is necessary
  204.      * for save time computation as Serialize gets called three times per object from within SavePackage.
  205.      *
  206.      * @warning: Objects created from within PreSave will NOT have PreSave called on them!!!
  207.      */
  208.     virtual void PreSave(const class ITargetPlatform* TargetPlatform);
  209.  
  210.     /**
  211.      * Note that the object will be modified.  If we are currently recording into the
  212.      * transaction buffer (undo/redo), save a copy of this object into the buffer and
  213.      * marks the package as needing to be saved.
  214.      *
  215.      * @param   bAlwaysMarkDirty    if true, marks the package dirty even if we aren't
  216.      *                              currently recording an active undo/redo transaction
  217.      * @return true if the object was saved to the transaction buffer
  218.      */
  219.     virtual bool Modify( bool bAlwaysMarkDirty=true );
  220.  
  221.     /** Utility to allow overrides of Modify to avoid doing work if this object cannot be safely modified */
  222.     bool CanModify() const;
  223.  
  224. #if WITH_EDITOR
  225.     /**
  226.      * Called when the object was loaded from another class via active class redirects.
  227.      */
  228.     virtual void LoadedFromAnotherClass(const FName& OldClassName) {}
  229. #endif
  230.  
  231.     /**
  232.      * Do any object-specific cleanup required immediately after loading an object.
  233.      * This is not called for newly-created objects, and by default will always execute on the game thread.
  234.      */
  235.     virtual void PostLoad();
  236.  
  237.     /**
  238.      * Instances components for objects being loaded from disk, if necessary.  Ensures that component references
  239.      * between nested components are fixed up correctly.
  240.      *
  241.      * @param   OuterInstanceGraph  when calling this method on subobjects, specifies the instancing graph which contains all instanced
  242.      *                              subobjects and components for a subobject root.
  243.      */
  244.     virtual void PostLoadSubobjects(FObjectInstancingGraph* OuterInstanceGraph);
  245.    
  246.     /**
  247.      * Called before destroying the object.  This is called immediately upon deciding to destroy the object, to allow the object to begin an
  248.      * asynchronous cleanup process.
  249.      */
  250.     virtual void BeginDestroy();
  251.  
  252.     /**
  253.      * Called to check if the object is ready for FinishDestroy.  This is called after BeginDestroy to check the completion of the
  254.      * potentially asynchronous object cleanup.
  255.      * @return True if the object's asynchronous cleanup has completed and it is ready for FinishDestroy to be called.
  256.      */
  257.     virtual bool IsReadyForFinishDestroy() { return true; }
  258.  
  259. #if WITH_EDITOR
  260.     /**
  261.      * Called in response to the linker changing, this can only happen in the editor
  262.      */
  263.     virtual void PostLinkerChange() {}
  264. #endif
  265.  
  266.     /**
  267.      * Called to finish destroying the object.  After UObject::FinishDestroy is called, the object's memory should no longer be accessed.
  268.      *
  269.      * @warning Because properties are destroyed here, Super::FinishDestroy() should always be called at the end of your child class's FinishDestroy() method, rather than at the beginning.
  270.      */
  271.     virtual void FinishDestroy();
  272.  
  273.     /**
  274.      * Handles reading, writing, and reference collecting using FArchive.
  275.      * This implementation handles all UProperty serialization, but can be overridden for native variables.
  276.      */
  277.     virtual void Serialize(FArchive& Ar);
  278.     virtual void Serialize(FStructuredArchive::FRecord Record);
  279.  
  280.     /** After a critical error, perform any mission-critical cleanup, such as restoring the video mode orreleasing hardware resources. */
  281.     virtual void ShutdownAfterError() {}
  282.  
  283.     /**
  284.      * This is called when property is modified by InterpPropertyTracks
  285.      *
  286.      * @param PropertyThatChanged   Property that changed
  287.      */
  288.     virtual void PostInterpChange(UProperty* PropertyThatChanged) {}
  289.  
  290. #if WITH_EDITOR
  291.     /**
  292.      * This is called when a property is about to be modified externally
  293.      *
  294.      * @param PropertyThatWillChange    Property that will be changed
  295.      */
  296.     virtual void PreEditChange(UProperty* PropertyAboutToChange);
  297.  
  298.     /**
  299.      * This alternate version of PreEditChange is called when properties inside structs are modified.  The property that was actually modified
  300.      * is located at the tail of the list.  The head of the list of the UStructProperty member variable that contains the property that was modified.
  301.      *
  302.      * @param PropertyAboutToChange the property that is about to be modified
  303.      */
  304.     virtual void PreEditChange( class FEditPropertyChain& PropertyAboutToChange );
  305.  
  306.     /**
  307.      * Called by the editor to query whether a property of this object is allowed to be modified.
  308.      * The property editor uses this to disable controls for properties that should not be changed.
  309.      * When overriding this function you should always call the parent implementation first.
  310.      *
  311.      * @param   InProperty  The property to query
  312.      *
  313.      * @return  true if the property can be modified in the editor, otherwise false
  314.      */
  315.     virtual bool CanEditChange( const UProperty* InProperty ) const;
  316.  
  317.     /**
  318.      * Intentionally non-virtual as it calls the FPropertyChangedEvent version
  319.      */
  320.     void PostEditChange();
  321.  
  322.     /**
  323.      * Called when a property on this object has been modified externally
  324.      *
  325.      * @param PropertyThatChanged the property that was modified
  326.      */
  327.     virtual void PostEditChangeProperty( struct FPropertyChangedEvent& PropertyChangedEvent);
  328.  
  329.     /**
  330.      * This alternate version of PostEditChange is called when properties inside structs are modified.  The property that was actually modified
  331.      * is located at the tail of the list.  The head of the list of the UStructProperty member variable that contains the property that was modified.
  332.      */
  333.     virtual void PostEditChangeChainProperty( struct FPropertyChangedChainEvent& PropertyChangedEvent );
  334.  
  335.     /** Called before applying a transaction to the object.  Default implementation simply calls PreEditChange. */
  336.     virtual void PreEditUndo();
  337.  
  338.     /** Called after applying a transaction to the object.  Default implementation simply calls PostEditChange. */
  339.     virtual void PostEditUndo();
  340.  
  341.     /** Called after applying a transaction to the object in cases where transaction annotation was provided. Default implementation simply calls PostEditChange. */
  342.     virtual void PostEditUndo(TSharedPtr<ITransactionObjectAnnotation> TransactionAnnotation);
  343.  
  344.     /**
  345.      * Called after the object has been transacted in some way.
  346.      * TransactionEvent describes what actually happened.
  347.      * @note Unlike PostEditUndo (which is called for any object in the transaction), this is only called on objects that are actually changed by the transaction.
  348.      */
  349.     virtual void PostTransacted(const FTransactionObjectEvent& TransactionEvent);
  350.  
  351.     /** Find or create and populate an annotation object with any external data required for applying a transaction */
  352.     TSharedPtr<ITransactionObjectAnnotation> FindOrCreateTransactionAnnotation() const;
  353.  
  354.     /** Create and restore a previously serialized annotation object with any external data required for applying a transaction */
  355.     TSharedPtr<ITransactionObjectAnnotation> CreateAndRestoreTransactionAnnotation(FArchive& Ar) const;
  356.  
  357. protected:
  358.     /** Factory a new annotation object and optionally populate it with data */
  359.     enum class ETransactionAnnotationCreationMode : uint8 { DefaultInstance, FindOrCreate };
  360.     virtual TSharedPtr<ITransactionObjectAnnotation> FactoryTransactionAnnotation(const ETransactionAnnotationCreationMode InCreationMode) const { return nullptr; }
  361.  
  362. private:
  363.     /**
  364.      * Test the selection state of a UObject
  365.      *
  366.      * @return      true if the object is selected, false otherwise.
  367.      * @todo UE4 this doesn't belong here, but it doesn't belong anywhere else any better
  368.      */
  369.     virtual bool IsSelectedInEditor() const;
  370.  
  371. public:
  372. #endif // WITH_EDITOR
  373.  
  374.     /** Called at the end of Rename(), but only if the rename was actually carried out */
  375.     virtual void PostRename(UObject* OldOuter, const FName OldName) {}
  376.    
  377.     /**
  378.      * Called after duplication & serialization and before PostLoad. Used to e.g. make sure UStaticMesh's UModel gets copied as well.
  379.      * Note: NOT called on components on actor duplication (alt-drag or copy-paste).  Use PostEditImport as well to cover that case.
  380.      */
  381.     virtual void PostDuplicate(bool bDuplicateForPIE) {}
  382.     virtual void PostDuplicate(EDuplicateMode::Type DuplicateMode)
  383.     {
  384.         PostDuplicate(DuplicateMode == EDuplicateMode::PIE);
  385.     }
  386.  
  387.     /**
  388.      * Called during saving to determine the load flags to save with the object.
  389.      * If false, this object will be discarded on clients
  390.      *
  391.      * @return  true if this object should be loaded on clients
  392.      */
  393.     virtual bool NeedsLoadForClient() const;
  394.  
  395.     /**
  396.      * Called during saving to determine the load flags to save with the object.
  397.      * If false, this object will be discarded on servers
  398.      *
  399.      * @return  true if this object should be loaded on servers
  400.      */
  401.     virtual bool NeedsLoadForServer() const;
  402.  
  403.     /**
  404.      * Called during saving to determine the load flags to save with the object.
  405.      * If false, this object will be discarded on the target platform
  406.      *
  407.      * @return  true if this object should be loaded on the target platform
  408.      */
  409.     virtual bool NeedsLoadForTargetPlatform(const class ITargetPlatform* TargetPlatform) const;
  410.  
  411.     /**
  412.      * Called during saving to include this object in client/servers running in editor builds, even if they wouldn't normally be.
  413.      * If false, this object will still get loaded if NeedsLoadForServer/Client are true
  414.      *
  415.      * @return  true if this object should always be loaded for games running in editor builds
  416.      */
  417.     virtual bool NeedsLoadForEditorGame() const
  418.     {
  419.         return false;
  420.     }
  421.  
  422.     /**
  423.     * Called during saving to determine if the object is forced to be editor only or not
  424.     *
  425.     * @return   true if this object should never be loaded outside the editor
  426.     */
  427.     virtual bool IsEditorOnly() const
  428.     {
  429.         return false;
  430.     }
  431.  
  432.     /**
  433.     * Called during async load to determine if PostLoad can be called on the loading thread.
  434.     *
  435.     * @return   true if this object's PostLoad is thread safe
  436.     */
  437.     virtual bool IsPostLoadThreadSafe() const
  438.     {
  439.         return false;
  440.     }
  441.  
  442.     /**
  443.     * Called during cooking. Must return all objects that will be Preload()ed when this is serialized at load time. Only used by the EDL.
  444.     *
  445.     * @param    OutDeps             all objects that will be preloaded when this is serialized at load time
  446.     */
  447.     virtual void GetPreloadDependencies(TArray<UObject*>& OutDeps);
  448.  
  449.     /**
  450.     * Called during cooking. Returns a list of objects. The packages containing those objects will be prestreamed, when the package containing this is loaded. Only used by the EDL.
  451.     *
  452.     * @param    OutPrestream                all objects that will be prestreamed when this packages is streamed
  453.     */
  454.     virtual void GetPrestreamPackages(TArray<UObject*>& OutPrestream)
  455.     {
  456.     }
  457.  
  458.     /**
  459.     *   Update the list of classes that we should exclude from dedicated server builds
  460.     */
  461.     static void UpdateClassesExcludedFromDedicatedServer(const TArray<FString>& InClassNames, const TArray<FString>& InModulesNames);
  462.  
  463.     /**
  464.     *   Update the list of classes that we should exclude from dedicated client builds
  465.     */
  466.     static void UpdateClassesExcludedFromDedicatedClient(const TArray<FString>& InClassNames, const TArray<FString>& InModulesNames);
  467.  
  468.     /**
  469.      *  Determines if you can create an object from the supplied template in the current context (editor, client only, dedicated server, game/listen)
  470.      *  This calls NeedsLoadForClient & NeedsLoadForServer
  471.      */
  472.     static bool CanCreateInCurrentContext(UObject* Template);
  473.  
  474.     /**
  475.      * Exports the property values for the specified object as text to the output device.
  476.      * Override this if you need custom support for copy/paste.
  477.      *
  478.      * @param   Out             The output device to send the exported text to
  479.      * @param   Indent          Number of spaces to prepend to each line of output
  480.      *
  481.      * @see ImportCustomProperties()
  482.      */
  483.     virtual void ExportCustomProperties(FOutputDevice& Out, uint32 Indent)  {}
  484.  
  485.     /**
  486.      * Exports the property values for the specified object as text to the output device. Required for Copy&Paste
  487.      * Override this if you need custom support for copy/paste.
  488.      *
  489.      * @param   SourceText      The input data (zero terminated), will never be null
  490.      * @param   Warn            For error reporting, will never be null
  491.      *
  492.      * @see ExportCustomProperties()
  493.      */
  494.     virtual void ImportCustomProperties(const TCHAR* SourceText, FFeedbackContext* Warn) {}
  495.  
  496.     /**
  497.      * Called after importing property values for this object (paste, duplicate or .t3d import)
  498.      * Allow the object to perform any cleanup for properties which shouldn't be duplicated or
  499.      * are unsupported by the script serialization
  500.      */
  501.     virtual void PostEditImport() {}
  502.  
  503.     /**
  504.      * Called from ReloadConfig after the object has reloaded its configuration data.
  505.      */
  506.     virtual void PostReloadConfig( class UProperty* PropertyThatWasLoaded ) {}
  507.  
  508.     /**
  509.      * Rename this object to a unique name, or change its outer.
  510.      * @warning Unless ForceNoResetLoaders is passed in, this will cause a flush of all level streaming.
  511.      *
  512.      * @param   NewName     The new name of the object, if null then NewOuter should be set
  513.      * @param   NewOuter    New Outer this object will be placed within, if null it will use the current outer
  514.      * @param   Flags       Flags to specify what happens during the rename
  515.      */
  516.     virtual bool Rename(const TCHAR* NewName=nullptr, UObject* NewOuter=nullptr, ERenameFlags Flags=REN_None);
  517.  
  518.     /** Return a one line description of an object for viewing in the thumbnail view of the generic browser */
  519.     virtual FString GetDesc() { return TEXT( "" ); }
  520.  
  521. #if WITH_ENGINE
  522.     /**
  523.      * Returns what UWorld this object is contained within.
  524.      * By default this will follow its Outer chain, but it should be overridden if that will not work.
  525.      */
  526.     virtual class UWorld* GetWorld() const;
  527.  
  528.     /** Internal function used by UEngine::GetWorldFromContextObject() */
  529.     class UWorld* GetWorldChecked(bool& bSupported) const;
  530.  
  531.     /** Checks to see if GetWorld() is implemented on a specific class */
  532.     bool ImplementsGetWorld() const;
  533. #endif
  534.  
  535.     /**
  536.      * Callback for retrieving a textual representation of natively serialized properties.  Child classes should implement this method if they wish
  537.      * to have natively serialized property values included in things like diffcommandlet output.
  538.      *
  539.      * @param   out_PropertyValues  receives the property names and values which should be reported for this object.  The map's key should be the name of
  540.      *                              the property and the map's value should be the textual representation of the property's value.  The property value should
  541.      *                              be formatted the same way that UProperty::ExportText formats property values (i.e. for arrays, wrap in quotes and use a comma
  542.      *                              as the delimiter between elements, etc.)
  543.      * @param   ExportFlags         bitmask of EPropertyPortFlags used for modifying the format of the property values
  544.      *
  545.      * @return  true if property values were added to the map.
  546.      */
  547.     virtual bool GetNativePropertyValues( TMap<FString,FString>& out_PropertyValues, uint32 ExportFlags=0 ) const
  548.     {
  549.         return false;
  550.     }
  551.  
  552.     /**
  553.      * Get the size of the object/resource for use in memory tools or to display to artists/LDs in the Editor
  554.      * This is the extended version which separates up the used memory into different memory regions (the actual definition of which may be platform specific).
  555.      *
  556.      * @param   CumulativeResourceSize  Struct used to count up the cumulative size of the resource as to be displayed to artists/LDs in the Editor.
  557.      */
  558.     virtual void GetResourceSizeEx(FResourceSizeEx& CumulativeResourceSize);
  559.  
  560.     /**
  561.      * Get the size of the object/resource for use in memory tools or to display to artists/LDs in the Editor
  562.      * This is the simple version which just returns the total number of bytes used by this object.
  563.      *
  564.      * @param   Mode                    Indicates which resource size should be returned.
  565.      * @return The cumulative size of this object in memory
  566.      */
  567.     SIZE_T GetResourceSizeBytes(EResourceSizeMode::Type Mode)
  568.     {
  569.         FResourceSizeEx ResSize = FResourceSizeEx(Mode);
  570.         GetResourceSizeEx(ResSize);
  571.         return ResSize.GetTotalMemoryBytes();
  572.     }
  573.  
  574.     /**
  575.      * Returns the name of the exporter factory used to export this object
  576.      * Used when multiple factories have the same extension
  577.      */
  578.     virtual FName GetExporterName( void )
  579.     {
  580.         return( FName( TEXT( "" ) ) );
  581.     }
  582.  
  583.     /**
  584.      * Callback used to allow object register its direct object references that are not already covered by
  585.      * the token stream.
  586.      *
  587.      * @param InThis Object to collect references from.
  588.      * @param Collector FReferenceCollector objects to be used to collect references.
  589.      */
  590.     static void AddReferencedObjects(UObject* InThis, FReferenceCollector& Collector);
  591.  
  592.     /**
  593.      * Helper function to call AddReferencedObjects for this object's class.
  594.      *
  595.      * @param Collector FReferenceCollector objects to be used to collect references.
  596.      */
  597.     void CallAddReferencedObjects(FReferenceCollector& Collector);
  598.  
  599.     /**
  600.      * Save information for StaticAllocateObject in the case of overwriting an existing object.
  601.      * StaticAllocateObject will call delete on the result after calling Restore()
  602.      *
  603.      * @return An FRestoreForUObjectOverwrite that can restore the object or NULL if this is not necessary.
  604.      */
  605.     virtual FRestoreForUObjectOverwrite* GetRestoreForUObjectOverwrite()
  606.     {
  607.         return NULL;
  608.     }
  609.  
  610.     /**
  611.      * Returns whether native properties are identical to the one of the passed in component.
  612.      *
  613.      * @param   Other   Other component to compare against
  614.      *
  615.      * @return true if native properties are identical, false otherwise
  616.      */
  617.     virtual bool AreNativePropertiesIdenticalTo( UObject* Other ) const
  618.     {
  619.         return true;
  620.     }
  621.  
  622.     /** Struct used by GetAssetRegistryTags() to return tag info */
  623.     struct FAssetRegistryTag
  624.     {
  625.         /** Enum specifying the type of this tag */
  626.         enum ETagType
  627.         {
  628.             /** This tag should not be shown in the UI */
  629.             TT_Hidden,
  630.             /** This tag should be shown, and sorted alphabetically in the UI */
  631.             TT_Alphabetical,
  632.             /** This tag should be shown, and is a number */
  633.             TT_Numerical,
  634.             /** This tag should be shown, and is an "x" delimited list of dimensions */
  635.             TT_Dimensional,
  636.             /** This tag should be shown, and is a timestamp formatted via FDateTime::ToString */
  637.             TT_Chronological,
  638.         };
  639.  
  640.         /** Flags controlling how this tag should be shown in the UI */
  641.         enum ETagDisplay
  642.         {
  643.             /** No special display */
  644.             TD_None = 0,
  645.             /** For TT_Chronological, include the date */
  646.             TD_Date = 1<<0,
  647.             /** For TT_Chronological, include the time */
  648.             TD_Time = 1<<1,
  649.             /** For TT_Chronological, specifies that the timestamp should be displayed using the invariant timezone (typically for timestamps that are already in local time) */
  650.             TD_InvariantTz = 1<<2,
  651.             /** For TT_Numerical, specifies that the number is a value in bytes that should be displayed using FText::AsMemory */
  652.             TD_Memory = 1<<3,
  653.         };
  654.        
  655.         /** Logical name of this tag */
  656.         FName Name;
  657.  
  658.         /** Value string for this tag, may represent any data type */
  659.         FString Value;
  660.  
  661.         /** Broad description of kind of data represented in Value */
  662.         ETagType Type;
  663.  
  664.         /** Flags describing more detail for displaying in the UI */
  665.         uint32 DisplayFlags;
  666.  
  667.         FAssetRegistryTag(FName InName, const FString& InValue, ETagType InType, uint32 InDisplayFlags = TD_None)
  668.             : Name(InName), Value(InValue), Type(InType), DisplayFlags(InDisplayFlags) {}
  669.  
  670.         /** Gathers a list of asset registry searchable tags from given objects properties */
  671.         COREUOBJECT_API static void GetAssetRegistryTagsFromSearchableProperties(const UObject* Object, TArray<FAssetRegistryTag>& OutTags);
  672.  
  673.         /** Returns true if this FName is a special UStruct that should be exported even if not tagged, with the struct name as the tag name */
  674.         COREUOBJECT_API static bool IsUniqueAssetRegistryTagStruct(FName StructName, ETagType& TagType);
  675.     };
  676.  
  677.     /**
  678.      * Gathers a list of asset registry searchable tags which are name/value pairs with some type information
  679.      * This only needs to be implemented for asset objects
  680.      *
  681.      * @param   OutTags     A list of key-value pairs associated with this object and their types
  682.      */
  683.     virtual void GetAssetRegistryTags(TArray<FAssetRegistryTag>& OutTags) const;
  684.  
  685.     /** Get the common tag name used for all asset source file import paths */
  686.     static const FName& SourceFileTagName();
  687.  
  688. #if WITH_EDITOR
  689.     /**
  690.      * Additional data pertaining to asset registry tags used by the editor
  691.      */
  692.     struct FAssetRegistryTagMetadata
  693.     {
  694.         FText DisplayName;
  695.         FText TooltipText;
  696.         FText Suffix;
  697.         FString ImportantValue;
  698.  
  699.         /** Set override display name */
  700.         FAssetRegistryTagMetadata& SetDisplayName(const FText& InDisplayName)
  701.         {
  702.             DisplayName = InDisplayName;
  703.             return *this;
  704.         }
  705.  
  706.         /** Set tooltip text pertaining to the asset registry tag in the column view header */
  707.         FAssetRegistryTagMetadata& SetTooltip(const FText& InTooltipText)
  708.         {
  709.             TooltipText = InTooltipText;
  710.             return *this;
  711.         }
  712.  
  713.         /** Set suffix appended to the tag value */
  714.         FAssetRegistryTagMetadata& SetSuffix(const FText& InSuffix)
  715.         {
  716.             Suffix = InSuffix;
  717.             return *this;
  718.         }
  719.  
  720.         /** Set value deemed to be 'important' for this registry tag */
  721.         FAssetRegistryTagMetadata& SetImportantValue(const FString& InImportantValue)
  722.         {
  723.             ImportantValue = InImportantValue;
  724.             return *this;
  725.         }
  726.     };
  727.  
  728.     /** Gathers a collection of asset registry tag metadata */
  729.     virtual void GetAssetRegistryTagMetadata(TMap<FName, FAssetRegistryTagMetadata>& OutMetadata) const;
  730.  
  731.     /** The metadata tags to be transferred from the UMetaData to the Asset Registry */
  732.     static TSet<FName>& GetMetaDataTagsForAssetRegistry();
  733.  
  734. #endif
  735.  
  736.     /** Returns true if this object is considered an asset. */
  737.     virtual bool IsAsset() const;
  738.  
  739.     /**
  740.      * Returns an Type:Name pair representing the PrimaryAssetId for this object.
  741.      * Assets that need to be globally referenced at runtime should return a valid Identifier.
  742.      * If this is valid, the object can be referenced by identifier using the AssetManager
  743.      */
  744.     virtual FPrimaryAssetId GetPrimaryAssetId() const;
  745.  
  746.     /** Returns true if this object is considered a localized resource. */
  747.     virtual bool IsLocalizedResource() const;
  748.  
  749.     /** Returns true if this object is safe to add to the root set. */
  750.     virtual bool IsSafeForRootSet() const;
  751.  
  752.     /**
  753.      * Tags objects that are part of the same asset with the specified object flag, used for GC checking
  754.      *
  755.      * @param   ObjectFlags Object Flags to enable on the related objects
  756.      */
  757.     virtual void TagSubobjects(EObjectFlags NewFlags);
  758.  
  759.     /** Returns properties that are replicated for the lifetime of the actor channel */
  760.     virtual void GetLifetimeReplicatedProps( TArray< class FLifetimeProperty > & OutLifetimeProps ) const;
  761.  
  762.     /** IsNameStableForNetworking means an object can be referred to its path name (relative to outer) over the network */
  763.     virtual bool IsNameStableForNetworking() const;
  764.  
  765.     /** IsFullNameStableForNetworking means an object can be referred to its full path name over the network */
  766.     virtual bool IsFullNameStableForNetworking() const;
  767.  
  768.     /** IsSupportedForNetworking means an object can be referenced over the network */
  769.     virtual bool IsSupportedForNetworking() const;
  770.  
  771.     /** Returns a list of sub-objects that have stable names for networking */
  772.     virtual void GetSubobjectsWithStableNamesForNetworking(TArray<UObject*> &ObjList) {}
  773.  
  774.     /** Called right before receiving a bunch */
  775.     virtual void PreNetReceive();
  776.  
  777.     /** Called right after receiving a bunch */
  778.     virtual void PostNetReceive();
  779.  
  780.     /** Called right after calling all OnRep notifies (called even when there are no notifies) */
  781.     virtual void PostRepNotifies() {}
  782.  
  783.     /** Called right before being marked for destruction due to network replication */
  784.     virtual void PreDestroyFromReplication();
  785.  
  786. #if WITH_EDITOR
  787.     /**
  788.      * @return      Returns Valid if this object has data validation rules set up for it and the data for this object is valid. Returns Invalid if it does not pass the rules. Returns NotValidated if no rules are set for this object.
  789.      */
  790.     virtual EDataValidationResult IsDataValid(TArray<FText>& ValidationErrors);
  791. #endif // WITH_EDITOR
  792.  
  793.     /*----------------------------------------------------------
  794.         Non virtual functions, not intended to be overridden
  795.     ----------------------------------------------------------*/
  796.  
  797.     /**
  798.      * Test the selection state of a UObject
  799.      *
  800.      * @return      true if the object is selected, false otherwise.
  801.      * @todo UE4 this doesn't belong here, but it doesn't belong anywhere else any better
  802.      */
  803.     bool IsSelected() const;
  804.  
  805. #if WITH_EDITOR
  806.     /**
  807.      * Calls PreEditChange on all instances based on an archetype in AffectedObjects. Recurses on any instances.
  808.      *
  809.      * @param   AffectedObjects     the array of objects which have this object in their ObjectArchetype chain and will be affected by the change.
  810.      *                              Objects which have this object as their direct ObjectArchetype are removed from the list once they're processed.
  811.      */
  812.     void PropagatePreEditChange( TArray<UObject*>& AffectedObjects, FEditPropertyChain& PropertyAboutToChange );
  813.  
  814.     /**
  815.      * Calls PostEditChange on all instances based on an archetype in AffectedObjects. Recurses on any instances.
  816.      *
  817.      * @param   AffectedObjects     the array of objects which have this object in their ObjectArchetype chain and will be affected by the change.
  818.      *                              Objects which have this object as their direct ObjectArchetype are removed from the list once they're processed.
  819.      */
  820.     void PropagatePostEditChange( TArray<UObject*>& AffectedObjects, FPropertyChangedChainEvent& PropertyChangedEvent );
  821. #endif // WITH_EDITOR
  822.  
  823.     /**
  824.      * Serializes the script property data located at Data.  When saving, only saves those properties which differ from the corresponding
  825.      * value in the specified 'DiffObject' (usually the object's archetype).
  826.      *
  827.      * @param   Ar              the archive to use for serialization
  828.      */
  829.     void SerializeScriptProperties( FArchive& Ar ) const;
  830.  
  831.     /**
  832.      * Serializes the script property data located at Data.  When saving, only saves those properties which differ from the corresponding
  833.      * value in the specified 'DiffObject' (usually the object's archetype).
  834.      *
  835.      * @param   Slot                the archive slot to serialize to
  836.      */
  837.     void SerializeScriptProperties( FStructuredArchive::FSlot Slot ) const;
  838.  
  839.     /**
  840.      * Wrapper function for InitProperties() which handles safely tearing down this object before re-initializing it
  841.      * from the specified source object.
  842.      *
  843.      * @param   SourceObject    the object to use for initializing property values in this object.  If not specified, uses this object's archetype.
  844.      * @param   InstanceGraph   contains the mappings of instanced objects and components to their templates
  845.      */
  846.     void ReinitializeProperties( UObject* SourceObject=NULL, struct FObjectInstancingGraph* InstanceGraph=NULL );
  847.  
  848.     /**
  849.      * This will return detail info about this specific object. (e.g. AudioComponent will return the name of the cue,
  850.      * ParticleSystemComponent will return the name of the ParticleSystem)  The idea here is that in many places
  851.      * you have a component of interest but what you really want is some characteristic that you can use to track
  852.      * down where it came from.  
  853.      *
  854.      * @note    safe to call on NULL object pointers!
  855.      */
  856.     FString GetDetailedInfo() const;
  857.  
  858.     /**
  859.      * Called before destroying the object.  This is called immediately upon deciding to destroy the object, to allow the object to begin an
  860.      * asynchronous cleanup process.
  861.      */
  862.     bool ConditionalBeginDestroy();
  863.  
  864.     /** Called when an object is actually destroyed, memory should never be accessed again */
  865.     bool ConditionalFinishDestroy();
  866.    
  867.     /** PostLoad if needed. */
  868.     void ConditionalPostLoad();
  869.  
  870.     /**
  871.      * Instances subobjects and components for objects being loaded from disk, if necessary.  Ensures that references
  872.      * between nested components are fixed up correctly.
  873.      *
  874.      * @param   OuterInstanceGraph  when calling this method on subobjects, specifies the instancing graph which contains all instanced
  875.      *                              subobjects and components for a subobject root.
  876.      */
  877.     void ConditionalPostLoadSubobjects( struct FObjectInstancingGraph* OuterInstanceGraph=NULL );
  878.  
  879. #if WITH_EDITOR
  880.     /**
  881.      * Starts caching of platform specific data for the target platform
  882.      * Called when cooking before serialization so that object can prepare platform specific data
  883.      * Not called during normal loading of objects
  884.      *
  885.      * @param   TargetPlatform  target platform to cache platform specific data for
  886.      */
  887.     virtual void BeginCacheForCookedPlatformData( const ITargetPlatform* TargetPlatform ) {  }
  888.    
  889.     /**
  890.      * Have we finished loading all the cooked platform data for the target platforms requested in BeginCacheForCookedPlatformData
  891.      *
  892.      * @param   TargetPlatform target platform to check for cooked platform data
  893.      */
  894.     virtual bool IsCachedCookedPlatformDataLoaded( const ITargetPlatform* TargetPlatform ) { return true; }
  895.  
  896.     /**
  897.      * All caching has finished for this object (all IsCachedCookedPlatformDataLoaded functions have finished for all platforms)
  898.      */
  899.     virtual void WillNeverCacheCookedPlatformDataAgain() { }
  900.  
  901.     /**
  902.      * Clears cached cooked platform data for specific platform
  903.      *
  904.      * @param   TargetPlatform  target platform to cache platform specific data for
  905.      */
  906.     virtual void ClearCachedCookedPlatformData( const ITargetPlatform* TargetPlatform ) {  }
  907.  
  908.     /**
  909.      * Clear all cached cooked platform data
  910.      *
  911.      * @param   TargetPlatform  target platform to cache platform specific data for
  912.      */
  913.     virtual void ClearAllCachedCookedPlatformData() { }
  914.  
  915.     /**
  916.      * Called during cook to allow objects to generate additional cooked files alongside their cooked package.
  917.      * @note These should typically match the name of the package, but with a different extension.
  918.      *
  919.      * @param   PackageFilename full path to the package that this object is being saved to on disk
  920.      * @param   TargetPlatform  target platform to cook additional files for
  921.      */
  922.     virtual void CookAdditionalFiles( const TCHAR* PackageFilename, const ITargetPlatform* TargetPlatform ) { }
  923. #endif
  924.     /**
  925.      * Determine if this object has SomeObject in its archetype chain.
  926.      */
  927.     inline bool IsBasedOnArchetype( const UObject* const SomeObject ) const;
  928.  
  929.     /** Returns a UFunction with the specified name, wrapper for UClass::FindFunctionByName() */
  930.     UFunction* FindFunction( FName InName ) const;
  931.    
  932.     /** Version of FindFunction() that will assert if the function was not found */
  933.     UFunction* FindFunctionChecked( FName InName ) const;
  934.  
  935.     /**
  936.      * Given OtherObject (which will be the same type as 'this'), recursively find any matching sub-objects from 'this' that also exist within OtherObject, and add the mappings to ObjectMapping.
  937.      *
  938.      * @param   OtherObject     The to find matching sub-objects within.
  939.      * @param   ObjectMapping   The complete mapping between this object hierarchy and the other object hierarchy.
  940.      */
  941.     virtual void BuildSubobjectMapping(UObject* OtherObject, TMap<UObject*, UObject*>& ObjectMapping) const;
  942.  
  943.     /**
  944.      * Uses the TArchiveObjectReferenceCollector to build a list of all components referenced by this object which have this object as the outer
  945.      *
  946.      * @param   OutDefaultSubobjects    the array that should be populated with the default subobjects "owned" by this object
  947.      * @param   bIncludeNestedSubobjects    controls whether subobjects which are contained by this object, but do not have this object
  948.      *                                      as its direct Outer should be included
  949.      */
  950.     void CollectDefaultSubobjects( TArray<UObject*>& OutDefaultSubobjects, bool bIncludeNestedSubobjects=false ) const;
  951.  
  952.     /**
  953.      * Checks default sub-object assumptions.
  954.      *
  955.      * @param bForceCheck Force checks even if not enabled globally.
  956.      * @return true if the assumptions are met, false otherwise.
  957.      */
  958.     bool CheckDefaultSubobjects(bool bForceCheck = false) const;
  959.  
  960.     /**
  961.      * Save configuration out to ini files
  962.      * @warning Must be safe to call on class-default object
  963.      */
  964.     void SaveConfig( uint64 Flags=CPF_Config, const TCHAR* Filename=NULL, FConfigCacheIni* Config=GConfig );
  965.  
  966.     /**
  967.      * Saves just the section(s) for this class into the default ini file for the class (with just the changes from base)
  968.      */
  969.     void UpdateDefaultConfigFile(const FString& SpecificFileLocation = "");
  970.  
  971.     /**
  972.      * Saves just the section(s) for this class into the global user ini file for the class (with just the changes from base)
  973.      */
  974.     void UpdateGlobalUserConfigFile();
  975.  
  976.     /**
  977.      * Saves just the property into the global user ini file for the class (with just the changes from base)
  978.      */
  979.     void UpdateSinglePropertyInConfigFile(const UProperty* InProperty, const FString& InConfigIniName);
  980.  
  981. private:
  982.     /**
  983.      * Saves just the section(s) for this class into the given ini file for the class (with just the changes from base)
  984.      */
  985.     void UpdateSingleSectionOfConfigFile(const FString& ConfigIniName);
  986.  
  987.     /**
  988.      * Ensures that current thread is NOT during vtable ptr retrieval process
  989.      * of some UClass.
  990.      */
  991.     void EnsureNotRetrievingVTablePtr() const;
  992.  
  993. public:
  994.     /**
  995.      * Get the default config filename for the specified UObject
  996.      */
  997.     FString GetDefaultConfigFilename() const;
  998.  
  999.     /**
  1000.      * Get the global user override config filename for the specified UObject
  1001.      */
  1002.     FString GetGlobalUserConfigFilename() const;
  1003.  
  1004.     /** Returns the override config hierarchy platform (if NDAd platforms need defaults to not be in Base*.ini but still want editor to load them) */
  1005.     virtual const TCHAR* GetConfigOverridePlatform() const { return nullptr; }
  1006.  
  1007.     /**
  1008.      * Allows PerObjectConfig classes, to override the ini section name used for the PerObjectConfig object.
  1009.      *
  1010.      * @param SectionName   Reference to the unmodified config section name, that can be altered/modified
  1011.      */
  1012.     virtual void OverridePerObjectConfigSection(FString& SectionName) {}
  1013.  
  1014.     /**
  1015.      * Imports property values from an .ini file.
  1016.      *
  1017.      * @param   Class               the class to use for determining which section of the ini to retrieve text values from
  1018.      * @param   Filename            indicates the filename to load values from; if not specified, uses ConfigClass's ClassConfigName
  1019.      * @param   PropagationFlags    indicates how this call to LoadConfig should be propagated; expects a bitmask of UE4::ELoadConfigPropagationFlags values.
  1020.      * @param   PropertyToLoad      if specified, only the ini value for the specified property will be imported.
  1021.      */
  1022.     void LoadConfig( UClass* ConfigClass=NULL, const TCHAR* Filename=NULL, uint32 PropagationFlags=UE4::LCPF_None, class UProperty* PropertyToLoad=NULL );
  1023.  
  1024.     /**
  1025.      * Wrapper method for LoadConfig that is used when reloading the config data for objects at runtime which have already loaded their config data at least once.
  1026.      * Allows the objects the receive a callback that its configuration data has been reloaded.
  1027.      *
  1028.      * @param   Class               the class to use for determining which section of the ini to retrieve text values from
  1029.      * @param   Filename            indicates the filename to load values from; if not specified, uses ConfigClass's ClassConfigName
  1030.      * @param   PropagationFlags    indicates how this call to LoadConfig should be propagated; expects a bitmask of UE4::ELoadConfigPropagationFlags values.
  1031.      * @param   PropertyToLoad      if specified, only the ini value for the specified property will be imported
  1032.      */
  1033.     void ReloadConfig( UClass* ConfigClass=NULL, const TCHAR* Filename=NULL, uint32 PropagationFlags=UE4::LCPF_None, class UProperty* PropertyToLoad=NULL );
  1034.  
  1035.     /** Import an object from a file. */
  1036.     void ParseParms( const TCHAR* Parms );
  1037.  
  1038.     /**
  1039.      * Outputs a string to an arbitrary output device, describing the list of objects which are holding references to this one.
  1040.      *
  1041.      * @param   Ar                      the output device to send output to
  1042.      * @param   Referencers             optionally allows the caller to specify the list of references to output.
  1043.      */
  1044.     void OutputReferencers( FOutputDevice& Ar, FReferencerInformationList* Referencers=NULL );
  1045.    
  1046.     /** Called by OutputReferencers() to get the internal list of referencers to write */
  1047.     void RetrieveReferencers( TArray<FReferencerInformation>* OutInternalReferencers, TArray<FReferencerInformation>* OutExternalReferencers);
  1048.  
  1049.     /**
  1050.      * Changes the linker and linker index to the passed in one. A linker of NULL and linker index of INDEX_NONE
  1051.      * indicates that the object is without a linker.
  1052.      *
  1053.      * @param LinkerLoad                New LinkerLoad object to set
  1054.      * @param LinkerIndex               New LinkerIndex to set
  1055.      * @param bShouldDetachExisting     If true, detach existing linker and call PostLinkerChange
  1056.      */
  1057.     void SetLinker( FLinkerLoad* LinkerLoad, int32 LinkerIndex, bool bShouldDetachExisting=true );
  1058.  
  1059.     /**
  1060.      * Return the template that an object with this class, outer and name would be
  1061.      *
  1062.      * @return the archetype for this object
  1063.      */
  1064.     static UObject* GetArchetypeFromRequiredInfo(UClass* Class, UObject* Outer, FName Name, EObjectFlags ObjectFlags);
  1065.  
  1066.     /**
  1067.      * Return the template this object is based on.
  1068.      *
  1069.      * @return the archetype for this object
  1070.      */
  1071.     UObject* GetArchetype() const;
  1072.  
  1073.     /**
  1074.      * Builds a list of objects which have this object in their archetype chain.
  1075.      *
  1076.      * @param   Instances   receives the list of objects which have this one in their archetype chain
  1077.      */
  1078.     void GetArchetypeInstances( TArray<UObject*>& Instances );
  1079.  
  1080.     /**
  1081.      * Wrapper for calling UClass::InstanceSubobjectTemplates() for this object.
  1082.      */
  1083.     void InstanceSubobjectTemplates( struct FObjectInstancingGraph* InstanceGraph = NULL );
  1084.  
  1085.     /**
  1086.      * Returns true if this object implements the interface T, false otherwise.
  1087.      */
  1088.     template<class T>
  1089.     bool Implements() const;
  1090.  
  1091.  
  1092.     /*-----------------------------
  1093.             Virtual Machine
  1094.     -----------------------------*/
  1095.  
  1096.     /** Called by VM to execute a UFunction with a filled in UStruct of parameters */
  1097.     virtual void ProcessEvent( UFunction* Function, void* Parms );
  1098.  
  1099.     /**
  1100.      * Return the space this function should be called.   Checks to see if this function should
  1101.      * be called locally, remotely, or simply absorbed under the given conditions
  1102.      *
  1103.      * @param Function function to call
  1104.      * @param Parameters arguments to the function call
  1105.      * @param Stack stack frame for the function call
  1106.      * @return bitmask representing all callspaces that apply to this UFunction in the given context
  1107.      */
  1108.     virtual int32 GetFunctionCallspace( UFunction* Function, void* Parameters, FFrame* Stack )
  1109.     {
  1110.         return FunctionCallspace::Local;
  1111.     }
  1112.  
  1113.     /**
  1114.      * Call the actor's function remotely
  1115.      *
  1116.      * @param Function function to call
  1117.      * @param Parameters arguments to the function call
  1118.      * @param Stack stack frame for the function call
  1119.      */
  1120.     virtual bool CallRemoteFunction( UFunction* Function, void* Parms, struct FOutParmRec* OutParms, FFrame* Stack )
  1121.     {
  1122.         return false;
  1123.     }
  1124.  
  1125.     /** Handle calling a function by name when executed from the console or a command line */
  1126.     bool CallFunctionByNameWithArguments( const TCHAR* Cmd, FOutputDevice& Ar, UObject* Executor, bool bForceCallWithNonExec = false );
  1127.  
  1128.     /** Internal VM method for executing a function */
  1129.     void CallFunction( FFrame& Stack, RESULT_DECL, UFunction* Function );
  1130.  
  1131.     /**
  1132.      * Internal function call processing.
  1133.      * @warning: might not write anything to Result if proper type isn't returned.
  1134.      */
  1135.     DECLARE_FUNCTION(ProcessInternal);
  1136.  
  1137.     /**
  1138.      * This function handles a console exec sent to the object; it is virtual so 'nexus' objects like
  1139.      * a player controller can reroute the command to several different objects.
  1140.      */
  1141.     virtual bool ProcessConsoleExec(const TCHAR* Cmd, FOutputDevice& Ar, UObject* Executor)
  1142.     {
  1143.         return CallFunctionByNameWithArguments(Cmd, Ar, Executor);
  1144.     }
  1145.  
  1146.     /** advances Stack's code past the parameters to the given Function and if the function has a return value, copies the zero value for that property to the memory for the return value
  1147.      * @param Stack the script stack frame
  1148.      * @param Result pointer to where the return value should be written
  1149.      * @param Function the function being called
  1150.      */
  1151.     void SkipFunction(FFrame& Stack, RESULT_DECL, UFunction* Function);
  1152.  
  1153.     /**
  1154.      * Called on the target when a class is loaded with ClassGeneratedBy is loaded.  Should regenerate the class if needed, and return the updated class
  1155.      * @return  Updated instance of the class, if needed, or NULL if no regeneration was necessary
  1156.      */
  1157.     virtual UClass* RegenerateClass(UClass* ClassToRegenerate, UObject* PreviousCDO) { return NULL; };
  1158.  
  1159.     /**
  1160.      * Returns whether this object is contained in or part of a blueprint object
  1161.      */
  1162.     bool IsInBlueprint() const;
  1163.  
  1164.     /**
  1165.      *  Destroy properties that won't be destroyed by the native destructor
  1166.      */
  1167.     void DestroyNonNativeProperties();
  1168.  
  1169.     /** Called during subobject creation to mark this component as editor only, which causes it to get stripped in packaged builds */
  1170.     virtual void MarkAsEditorOnlySubobject() { }
  1171.  
  1172.     /**
  1173.      * Abort with a member function call at the top of the callstack, helping to ensure that most platforms will stuff this object's memory into the resulting minidump.
  1174.      */
  1175.     void AbortInsideMemberFunction() const;
  1176.  
  1177.     // UnrealScript intrinsics, do not call directly
  1178.  
  1179.     // Undefined native handler
  1180.     DECLARE_FUNCTION(execUndefined);
  1181.  
  1182.     // Variables
  1183.     DECLARE_FUNCTION(execLocalVariable);
  1184.     DECLARE_FUNCTION(execInstanceVariable);
  1185.     DECLARE_FUNCTION(execDefaultVariable);
  1186.     DECLARE_FUNCTION(execLocalOutVariable);
  1187.     DECLARE_FUNCTION(execInterfaceVariable);
  1188.     DECLARE_FUNCTION(execInterfaceContext);
  1189.     DECLARE_FUNCTION(execArrayElement);
  1190.     DECLARE_FUNCTION(execBoolVariable);
  1191.     DECLARE_FUNCTION(execClassDefaultVariable);
  1192.     DECLARE_FUNCTION(execEndFunctionParms);
  1193.  
  1194.     // Do Nothing
  1195.     DECLARE_FUNCTION(execNothing);
  1196.     DECLARE_FUNCTION(execNothingOp4a);
  1197.  
  1198.     /** Breakpoint; only observed in the editor; executing it at any other time is a NOP */
  1199.     DECLARE_FUNCTION(execBreakpoint);
  1200.  
  1201.     /** Tracepoint; only observed in the editor; executing it at any other time is a NOP */
  1202.     DECLARE_FUNCTION(execTracepoint);
  1203.     DECLARE_FUNCTION(execWireTracepoint);
  1204.  
  1205.     /** Instrumentation event for profiling; only observed in the builds with blueprint instrumentation */
  1206.     DECLARE_FUNCTION(execInstrumentation);
  1207.  
  1208.     DECLARE_FUNCTION(execEndOfScript);
  1209.  
  1210.     /** failsafe for functions that return a value - returns the zero value for a property and logs that control reached the end of a non-void function */
  1211.     DECLARE_FUNCTION(execReturnNothing);
  1212.     DECLARE_FUNCTION(execEmptyParmValue);
  1213.  
  1214.     // Commands
  1215.     DECLARE_FUNCTION(execJump);
  1216.     DECLARE_FUNCTION(execJumpIfNot);
  1217.     DECLARE_FUNCTION(execAssert);
  1218.  
  1219.     /**
  1220.      * Push a code offset onto the execution flow stack for future execution.  
  1221.      * Current execution continues to the next instruction after the push one.
  1222.      */
  1223.     DECLARE_FUNCTION(execPushExecutionFlow);
  1224.  
  1225.     /**
  1226.      * Pops a code offset from the execution flow stack and starts execution there.
  1227.      * If there are no stack entries left, it is treated as an execution error.
  1228.      */
  1229.     DECLARE_FUNCTION(execPopExecutionFlow);
  1230.     DECLARE_FUNCTION(execComputedJump);
  1231.  
  1232.     /**
  1233.      * Pops a code offset from the execution flow stack and starts execution there, if a condition is not true.
  1234.      * If there are no stack entries left, it is treated as an execution error.
  1235.      */
  1236.     DECLARE_FUNCTION(execPopExecutionFlowIfNot);
  1237.  
  1238.  
  1239.     // Assignment
  1240.     DECLARE_FUNCTION(execLet);
  1241.     DECLARE_FUNCTION(execLetObj);
  1242.     DECLARE_FUNCTION(execLetWeakObjPtr);
  1243.     DECLARE_FUNCTION(execLetBool);
  1244.     DECLARE_FUNCTION(execLetDelegate);
  1245.     DECLARE_FUNCTION(execLetMulticastDelegate);
  1246.  
  1247.     // Delegates
  1248.     DECLARE_FUNCTION(execAddMulticastDelegate);
  1249.     DECLARE_FUNCTION(execClearMulticastDelegate);
  1250.     DECLARE_FUNCTION(execEatReturnValue);
  1251.     DECLARE_FUNCTION(execRemoveMulticastDelegate);
  1252.  
  1253.     // Context expressions
  1254.     DECLARE_FUNCTION(execSelf);
  1255.     DECLARE_FUNCTION(execContext);
  1256.     DECLARE_FUNCTION(execContext_FailSilent);
  1257.     DECLARE_FUNCTION(execStructMemberContext);
  1258.  
  1259.     // Function calls
  1260.     DECLARE_FUNCTION(execVirtualFunction);
  1261.     DECLARE_FUNCTION(execFinalFunction);
  1262.     DECLARE_FUNCTION(execLocalVirtualFunction);
  1263.     DECLARE_FUNCTION(execLocalFinalFunction);
  1264.  
  1265.     // Struct comparison
  1266.     DECLARE_FUNCTION(execStructCmpEq);
  1267.     DECLARE_FUNCTION(execStructCmpNe);
  1268.     DECLARE_FUNCTION(execStructMember);
  1269.  
  1270.     DECLARE_FUNCTION(execEqualEqual_DelegateDelegate);
  1271.     DECLARE_FUNCTION(execNotEqual_DelegateDelegate);
  1272.     DECLARE_FUNCTION(execEqualEqual_DelegateFunction);
  1273.     DECLARE_FUNCTION(execNotEqual_DelegateFunction);
  1274.  
  1275.     // Constants
  1276.     DECLARE_FUNCTION(execIntConst);
  1277.     DECLARE_FUNCTION(execInt64Const);
  1278.     DECLARE_FUNCTION(execUInt64Const);
  1279.     DECLARE_FUNCTION(execSkipOffsetConst);
  1280.     DECLARE_FUNCTION(execFloatConst);
  1281.     DECLARE_FUNCTION(execStringConst);
  1282.     DECLARE_FUNCTION(execUnicodeStringConst);
  1283.     DECLARE_FUNCTION(execTextConst);
  1284.     DECLARE_FUNCTION(execObjectConst);
  1285.     DECLARE_FUNCTION(execSoftObjectConst);
  1286.  
  1287.     DECLARE_FUNCTION(execInstanceDelegate);
  1288.     DECLARE_FUNCTION(execNameConst);
  1289.     DECLARE_FUNCTION(execByteConst);
  1290.     DECLARE_FUNCTION(execIntZero);
  1291.     DECLARE_FUNCTION(execIntOne);
  1292.     DECLARE_FUNCTION(execTrue);
  1293.     DECLARE_FUNCTION(execFalse);
  1294.     DECLARE_FUNCTION(execNoObject);
  1295.     DECLARE_FUNCTION(execNullInterface);
  1296.     DECLARE_FUNCTION(execIntConstByte);
  1297.     DECLARE_FUNCTION(execRotationConst);
  1298.     DECLARE_FUNCTION(execVectorConst);
  1299.     DECLARE_FUNCTION(execTransformConst);
  1300.     DECLARE_FUNCTION(execStructConst);
  1301.     DECLARE_FUNCTION(execSetArray);
  1302.     DECLARE_FUNCTION(execSetSet);
  1303.     DECLARE_FUNCTION(execSetMap);
  1304.     DECLARE_FUNCTION(execArrayConst);
  1305.     DECLARE_FUNCTION(execSetConst);
  1306.     DECLARE_FUNCTION(execMapConst);
  1307.  
  1308.     // Object construction
  1309.     DECLARE_FUNCTION(execNew);
  1310.     DECLARE_FUNCTION(execClassContext);
  1311.     DECLARE_FUNCTION(execNativeParm);
  1312.  
  1313.     // Conversions
  1314.     DECLARE_FUNCTION(execDynamicCast);
  1315.     DECLARE_FUNCTION(execMetaCast);
  1316.     DECLARE_FUNCTION(execPrimitiveCast);
  1317.     DECLARE_FUNCTION(execInterfaceCast);
  1318.  
  1319.     // Cast functions
  1320.     DECLARE_FUNCTION(execObjectToBool);
  1321.     DECLARE_FUNCTION(execInterfaceToBool);
  1322.     DECLARE_FUNCTION(execObjectToInterface);
  1323.     DECLARE_FUNCTION(execInterfaceToInterface);
  1324.     DECLARE_FUNCTION(execInterfaceToObject);
  1325.  
  1326.     // Dynamic array functions
  1327.     // Array support
  1328.     DECLARE_FUNCTION(execGetDynArrayElement);
  1329.     DECLARE_FUNCTION(execSetDynArrayElement);
  1330.     DECLARE_FUNCTION(execGetDynArrayLength);
  1331.     DECLARE_FUNCTION(execSetDynArrayLength);
  1332.     DECLARE_FUNCTION(execDynArrayInsert);
  1333.     DECLARE_FUNCTION(execDynArrayRemove);
  1334.     DECLARE_FUNCTION(execDynArrayFind);
  1335.     DECLARE_FUNCTION(execDynArrayFindStruct);
  1336.     DECLARE_FUNCTION(execDynArrayAdd);
  1337.     DECLARE_FUNCTION(execDynArrayAddItem);
  1338.     DECLARE_FUNCTION(execDynArrayInsertItem);
  1339.     DECLARE_FUNCTION(execDynArrayRemoveItem);
  1340.     DECLARE_FUNCTION(execDynArraySort);
  1341.  
  1342.     DECLARE_FUNCTION(execBindDelegate);
  1343.     DECLARE_FUNCTION(execCallMulticastDelegate);
  1344.  
  1345.     DECLARE_FUNCTION(execLetValueOnPersistentFrame);
  1346.  
  1347.     DECLARE_FUNCTION(execCallMathFunction);
  1348.  
  1349.     DECLARE_FUNCTION(execSwitchValue);
  1350.  
  1351.     DECLARE_FUNCTION(execArrayGetByRef);
  1352.  
  1353.     /** Wrapper struct to hold the entrypoint in the right memory address */
  1354.     struct Object_eventExecuteUbergraph_Parms
  1355.     {
  1356.         int32 EntryPoint;
  1357.     };
  1358.  
  1359.     /** Execute the ubergraph from a specific entry point */
  1360.     void ExecuteUbergraph(int32 EntryPoint)
  1361.     {
  1362.         Object_eventExecuteUbergraph_Parms Parms;
  1363.         Parms.EntryPoint=EntryPoint;
  1364.         ProcessEvent(FindFunctionChecked(NAME_ExecuteUbergraph),&Parms);
  1365.     }
  1366.  
  1367. protected:
  1368.     /** Checks it's ok to perform subobjects check at this time. */
  1369.     bool CanCheckDefaultSubObjects(bool bForceCheck, bool& bResult) const;
  1370.  
  1371.     /**
  1372.     * Checks default sub-object assumptions.
  1373.     *
  1374.     * @return true if the assumptions are met, false otherwise.
  1375.     */
  1376.     virtual bool CheckDefaultSubobjectsInternal() const;
  1377.  
  1378. private:
  1379.     void ProcessContextOpcode(FFrame& Stack, RESULT_DECL, bool bCanFailSilent);
  1380.  
  1381.     /**
  1382.     * Create a component or subobject only to be used with the editor.
  1383.     * @param    Outer                       outer to construct the subobject in
  1384.     * @param    ReturnType                  type of the new component
  1385.     * @param    SubobjectName               name of the new component
  1386.     * @param    bTransient                  true if the component is being assigned to a transient property
  1387.     */
  1388.     UObject* CreateEditorOnlyDefaultSubobjectImpl(FName SubobjectName, UClass* ReturnType, bool bTransient = false);
  1389. };
  1390.  
  1391. /**
  1392. * Test validity of object
  1393. *
  1394. * @param    Test            The object to test
  1395. * @return   Return true if the object is usable: non-null and not pending kill
  1396. */
  1397. FORCEINLINE bool IsValid(const UObject *Test)
  1398. {
  1399.     return Test && !Test->IsPendingKill();
  1400. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement