17#include "Core/UObjectGlobals.h"
27 #define RF_AllFlags (EObjectFlags)0xffffffff
44 KR_CORE_ASSERT((NewFlags & ~RF_AllFlags) == 0,
"%s flagged as 0x%x but is trying to set flags to RF_AllFlags");
45 m_ObjectFlags = NewFlags;
58 UObjectBase(
UClass* inClass, EObjectFlags inFlags, EInternalObjectFlags inInternalFlags,
UObject* inOuter,
const std::string& inName);
68 UPackage* GetExternalPackage()
const;
72 bool IsUnreachable()
const;
75 FORCEINLINE
void SetInternalIndex(uint32_t StoreIndex) { m_InternalIndex = StoreIndex; }
77 FORCEINLINE uint32_t GetInterIndex()
const {
return m_InternalIndex; }
83 EObjectFlags m_ObjectFlags;
89 uint32_t m_InternalIndex;
92 UObject* m_OuterPrivate;
95 UClass* m_ClassPrivate;
98 std::string m_NamePrivate;
101 static bool m_bPendingKillDisabled;
110 void AddObject(
const std::string& name, EInternalObjectFlags inSetInternalFlags);
116 void MarkAsGarbage();
124 FORCEINLINE
const std::string&
GetName()
const
126 return m_NamePrivate;
129 FORCEINLINE
void SetObjectName(
const std::string& aName)
131 m_NamePrivate = aName;
137 return m_OuterPrivate;
156 return (T*)GetTypedOuter(T::StaticClass());
163 bool IsValidLowLevel()
const;
169 if (!(int32_t(InFlags) & (int32_t(EInternalObjectFlags::Garbage) | int32_t(EInternalObjectFlags::PendingKill))))
176 return m_bPendingKillDisabled ?
177 EInternalObjectFlags(((int32_t(InFlags) & ~int32_t(EInternalObjectFlags::PendingKill)) | int32_t(EInternalObjectFlags::Garbage))) :
178 EInternalObjectFlags(((int32_t(InFlags) & ~int32_t(EInternalObjectFlags::Garbage)) | int32_t(EInternalObjectFlags::PendingKill)));
186 template <
typename OtherClassType>
187 FORCEINLINE
bool IsA(OtherClassType SomeBase)
const
193 const UClass* SomeBaseClass = SomeBase;
195 KR_CORE_ASSERT(SomeBaseClass,
"IsA(NULL) cannot yield meaningful results");
197 const UClass* ThisClass = GetClass();
204 KR_CORE_ASSERT(ThisClass,
"Comparing with null is useless");
206 return IsChildOfWorkaround(ThisClass, SomeBaseClass);
212 return m_ClassPrivate;
226 KR_CORE_ASSERT((m_ObjectFlags & ~RF_AllFlags) == 0,
"{0} flagged as RF_ALLFlags", GetName());
227 return m_ObjectFlags;
235 KR_CORE_ASSERT(!(NewFlags & (RF_MarkAsNative | RF_MarkAsRootSet | RF_PendingKill | RF_Garbage)),
"These flags can't be used outside of constructors / internal code");
236 KR_CORE_ASSERT(!(NewFlags & (EObjectFlags)(RF_PendingKill | RF_Garbage)) || (GetFlags() & (NewFlags & (EObjectFlags)(RF_PendingKill | RF_Garbage))) == (NewFlags & (EObjectFlags)(RF_PendingKill | RF_Garbage)),
"RF_PendingKill and RF_garbage can not be set through SetFlags function. Use MarkAsGarbage() instead");
238 SetFlagsTo(EObjectFlags (GetFlags() | NewFlags));
244 KR_CORE_ASSERT(!(NewFlags & (RF_MarkAsNative | RF_MarkAsRootSet | RF_PendingKill | RF_Garbage)) || NewFlags == RF_AllFlags,
"These flags can't be used outside of constructors / internal code");
245 KR_CORE_ASSERT(!(NewFlags & (EObjectFlags)(RF_PendingKill | RF_Garbage)) || (GetFlags() & (NewFlags & (EObjectFlags)(RF_PendingKill | RF_Garbage))) == RF_NoFlags,
"RF_PendingKill and RF_garbage can not be cleared through ClearFlags function. Use ClearGarbage() instead");
247 SetFlagsTo(EObjectFlags (GetFlags() & ~NewFlags));
258 KR_CORE_ASSERT(!(FlagsToCheck & (RF_MarkAsNative | RF_MarkAsRootSet)) || FlagsToCheck == RF_AllFlags,
"Illegal flags being used");
259 return (GetFlags() & FlagsToCheck) != 0;
270 return GUObjectStore.
IndexToObject(m_InternalIndex)->HasAnyFlags(FlagsToCheck);
281 KR_CORE_ASSERT(!(int32_t(FlagsToSet) & (int32_t(EInternalObjectFlags::PendingKill) | int32_t(EInternalObjectFlags::Garbage))) || (int32_t(FlagsToSet) & (int32_t(EInternalObjectFlags::PendingKill) | int32_t(EInternalObjectFlags::Garbage))) == (int32_t(ObjectItem->GetFlags()) & (int32_t(EInternalObjectFlags::PendingKill) | int32_t(EInternalObjectFlags::Garbage))),
"");
283 ObjectItem->SetFlags(FlagsToSet);
305 static bool IsChildOfWorkaround(
const UClass* ObjClass,
const UClass* TestClass);
FORCEINLINE BuildingBlock & IndexToObject(int32_t Index)
Definition KarmaTypes.h:308
Low level implementation of UObject, should not be used directly in game code Taken from UE's UObject...
Definition UObjectBase.h:34
FORCEINLINE void SetFlagsTo(EObjectFlags NewFlags)
Definition UObjectBase.h:42
FORCEINLINE const std::string & GetName() const
Definition UObjectBase.h:124
static FORCEINLINE EInternalObjectFlags FixGarbageOrPendingKillInternalObjectFlags(const EInternalObjectFlags InFlags)
Definition UObjectBase.h:166
FORCEINLINE void ClearFlags(EObjectFlags NewFlags)
Definition UObjectBase.h:242
FORCEINLINE UObject * GetOuter() const
Definition UObjectBase.h:135
T * GetTypedOuter() const
Definition UObjectBase.h:154
FORCEINLINE UClass * GetClass() const
Definition UObjectBase.h:210
FORCEINLINE bool HasAnyFlags(EObjectFlags FlagsToCheck) const
Definition UObjectBase.h:256
FORCEINLINE void SetInternalIndex(uint32_t StoreIndex)
Definition UObjectBase.h:75
FORCEINLINE void SetFlags(EObjectFlags NewFlags)
Definition UObjectBase.h:233
FORCEINLINE void SetInternalFlags(EInternalObjectFlags FlagsToSet) const
Definition UObjectBase.h:278
FORCEINLINE EObjectFlags GetFlags() const
Definition UObjectBase.h:224
FORCEINLINE bool IsA(OtherClassType SomeBase) const
Definition UObjectBase.h:187
FORCEINLINE void AddToRoot()
Definition UObjectBase.h:290
FORCEINLINE bool HasAnyInternalFlags(EInternalObjectFlags FlagsToCheck) const
Definition UObjectBase.h:268
The base class of all the game code relevant objects.
Definition Object.h:106
Definition UObjectGlobals.h:248