9#include "WorldSettings.h"
20 static std::string ReadFileToSpitString(
const std::string& filePath);
21 static std::string GetFilePath(
const std::string& str);
22 static unsigned char* GetImagePixelData(
char const* fileName,
int* width,
int* height,
int* channels,
int req_comp);
82 if (InClass == AActor::StaticClass())
86 for (
ULevel* Level : InWorld->GetLevels())
90 NumActors += Level->Actors.Num();
96 ObjectArray.Reserve(NumActors);
100 for (
ULevel* Level : InWorld->GetLevels())
104 ObjectArray.Append(Level->Actors);
111 constexpr EObjectFlags ExcludeFlags = RF_ClassDefaultObject;
112 GetObjectsOfClass(InClass,
m_ObjectArray,
true, ExcludeFlags, EInternalObjectFlags::Garbage);
152 enum EActorIteratorFlags
154 AllActors = 0x00000000,
155 SkipPendingKill = 0x00000001,
156 OnlySelectedActors = 0x00000002,
157 OnlyActiveLevels = 0x00000004,
161 enum class EActorIteratorType
169 template <
typename Derived>
173 EActorIteratorFlags m_Flags;
176 std::shared_ptr<FActorIteratorState> m_State;
183 : m_Flags(EActorIteratorFlags::AllActors)
200 AActor* localCurrentActor =
nullptr;
201 int32_t localIndex = m_State->m_Index;
204 const UWorld* localCurrentWorld = m_State->m_CurrentWorld;
206 int32_t lObjectArrayNum = int32_t(localObjectArray.Num());
207 int32_t lSAArrayNum = int32_t(localSpawnedActorArray.Num());
209 while (++localIndex < (lObjectArrayNum + lSAArrayNum))
211 if (localIndex < lObjectArrayNum)
213 localCurrentActor =
static_cast<AActor*
>(localObjectArray.GetElements()[localIndex]);
217 localCurrentActor = localSpawnedActorArray.GetElements()[localIndex - lObjectArrayNum];
219 m_State->m_ConsideredCount++;
221 ULevel* actorLevel = localCurrentActor ? localCurrentActor->
GetLevel() :
nullptr;
224 &&
static_cast<const Derived*
>(
this)->
IsActorSuitable(localCurrentActor)
226 && actorLevel->
GetWorld() == localCurrentWorld)
229 if (actorLevel == localCurrentWorld->GetPersistentLevel() || !localCurrentActor->
IsA(AWorldSettings::StaticClass()))
231 m_State->m_CurrentActor = localCurrentActor;
232 m_State->m_Index = localIndex;
237 m_State->m_CurrentActor =
nullptr;
238 m_State->m_ReachedEnd =
true;
248 return m_State->GetActorChecked();
258 return m_State->GetActorChecked();
266 FORCEINLINE
explicit operator bool()
const
268 return !m_State->m_ReachedEnd;
276 KR_CORE_ASSERT(!m_State->m_ReachedEnd,
"");
277 m_State->m_CurrentWorld->RemoveActor(m_State->m_CurrentActor,
true);
288 return m_State->m_ConsideredCount;
331 if (EnumHasAnyFlags(m_Flags, EActorIteratorFlags::SkipPendingKill) && !
IsValid(Actor))
336 if (EnumHasAnyFlags(m_Flags, EActorIteratorFlags::OnlySelectedActors) && !Actor->
IsSelected())
FORCEINLINE bool IsValid(const UObject *Test)
Test validity of object.
Definition Object.h:232
Karma's std::vector wrapper.
Definition KarmaTypes.h:128
ULevel * GetLevel() const
Definition Actor.cpp:18
Definition KarmaUtilities.h:31
FActorIteratorState(const UWorld *InWorld, const TSubclassOf< AActor > InClass)
Definition KarmaUtilities.h:65
UClass * m_DesiredClass
Definition KarmaUtilities.h:55
FActorIteratorState()
Definition KarmaUtilities.h:60
KarmaVector< UObject * > m_ObjectArray
Definition KarmaUtilities.h:37
bool m_ReachedEnd
Definition KarmaUtilities.h:43
const UWorld * m_CurrentWorld
Definition KarmaUtilities.h:34
KarmaVector< AActor * > m_SpawnedActorArray
Definition KarmaUtilities.h:52
FORCEINLINE AActor * GetActorChecked() const
Definition KarmaUtilities.h:132
int32_t m_Index
Definition KarmaUtilities.h:40
int32_t m_ConsideredCount
Definition KarmaUtilities.h:46
AActor * m_CurrentActor
Definition KarmaUtilities.h:49
Definition KarmaUtilities.h:18
Definition KarmaUtilities.h:171
FORCEINLINE AActor * operator->() const
Definition KarmaUtilities.h:256
void operator++()
Definition KarmaUtilities.h:197
FORCEINLINE bool CanIterateLevel(const ULevel *Level) const
Definition KarmaUtilities.h:298
FORCEINLINE bool IsActorSuitable(const AActor *Actor) const
Definition KarmaUtilities.h:329
FORCEINLINE AActor * operator*() const
Definition KarmaUtilities.h:246
TActorIteratorBase(EActorIteratorType)
Definition KarmaUtilities.h:182
void ClearCurrent()
Definition KarmaUtilities.h:274
int32 GetProgressNumerator() const
Definition KarmaUtilities.h:286
Definition SubClassOf.h:64
virtual UWorld * GetWorld() const override final
Returns what UWorld this object is contained within.
Definition Level.cpp:17
bool IsUnreachable() const
Definition UObjectBase.cpp:110
FORCEINLINE bool IsA(OtherClassType SomeBase) const
Definition UObjectBase.h:187
bool IsSelected() const
Test the selection state of a UObject.
Definition Object.cpp:181