48 static std::string
GetFilePath(
const std::string& str);
79 static unsigned char*
GetImagePixelData(
char const* fileName,
int* width,
int* height,
int* channels,
int req_comp);
150 if (InClass == AActor::StaticClass())
154 for (
ULevel* Level : InWorld->GetLevels())
158 NumActors += Level->Actors.Num();
163 ObjectArray.Reserve(NumActors);
167 for (
ULevel* Level : InWorld->GetLevels())
171 ObjectArray.Append(Level->Actors);
257 template <
typename Derived>
264 std::shared_ptr<FActorIteratorState> m_State;
307 AActor* localCurrentActor =
nullptr;
308 int32_t localIndex = m_State->m_Index;
311 const UWorld* localCurrentWorld = m_State->m_CurrentWorld;
313 int32_t lObjectArrayNum = int32_t(localObjectArray.
Num());
314 int32_t lSAArrayNum = int32_t(localSpawnedActorArray.
Num());
316 while (++localIndex < (lObjectArrayNum + lSAArrayNum))
318 if (localIndex < lObjectArrayNum)
320 localCurrentActor =
static_cast<AActor*
>(localObjectArray.
GetElements()[localIndex]);
324 localCurrentActor = localSpawnedActorArray.
GetElements()[localIndex - lObjectArrayNum];
326 m_State->m_ConsideredCount++;
328 ULevel* actorLevel = localCurrentActor ? localCurrentActor->
GetLevel() :
nullptr;
331 &&
static_cast<const Derived*
>(
this)->
IsActorSuitable(localCurrentActor)
332 &&
static_cast<const Derived*
>(
this)->
CanIterateLevel(actorLevel) && actorLevel->
GetWorld() == localCurrentWorld)
335 if (actorLevel == localCurrentWorld->
GetPersistentLevel() || !localCurrentActor->
IsA(AWorldSettings::StaticClass()))
337 m_State->m_CurrentActor = localCurrentActor;
338 m_State->m_Index = localIndex;
343 m_State->m_CurrentActor =
nullptr;
344 m_State->m_ReachedEnd =
true;
355 return m_State->GetActorChecked();
366 return m_State->GetActorChecked();
378 return !m_State->m_ReachedEnd;
388 KR_CORE_ASSERT(!m_State->m_ReachedEnd,
"");
389 m_State->m_CurrentWorld->RemoveActor(m_State->m_CurrentActor,
true);
401 return m_State->m_ConsideredCount;
This file contains the class AActor.
#define KARMA_API
Defining Karma's API macro for storage class information.
Definition Core.h:41
#define FORCEINLINE
Typical inlining macro for clarity.
Definition Core.h:170
EActorIteratorFlags
Iteration flags, specifies which types of levels and actors should be iterated.
Definition KarmaUtilities.h:227
@ OnlySelectedActors
Only iterate actors that are selected.
Definition KarmaUtilities.h:239
@ SkipPendingKill
Skip pending kill actors.
Definition KarmaUtilities.h:235
@ OnlyActiveLevels
Only iterate active levels.
Definition KarmaUtilities.h:243
@ AllActors
No flags, iterate all actors.
Definition KarmaUtilities.h:231
EActorIteratorType
Type enum, used to represent the special End iterator.
Definition KarmaUtilities.h:250
This file contains the class ULevel.
FORCEINLINE bool IsValid(const UObject *Test)
Test validity of object.
Definition Object.h:239
This file contains the class TSubclassOf and relevant helpers.
constexpr bool EnumHasAnyFlags(Enum Flags, Enum Contains)
Sees if a specified flag(s) exists in the linear combination of flags.
Definition UObjectGlobals.h:45
EObjectFlags
Flags describing an object instance.
Definition UObjectGlobals.h:183
@ RF_ClassDefaultObject
This object is its class's default object.
Definition UObjectGlobals.h:194
@ Garbage
Garbage from logical point of view and should not be referenced. This flag is mirrored in EObjectFlag...
Definition UObjectGlobals.h:247
signed int int32
32-bit signed integer
Definition UObjectGlobals.h:33
This file contains UWorld class and FActorSpawnParameters.
This file contains the class AWorldSettings.
Actor is the base class for an object that can be placed or spawned in a level.
Definition Actor.h:35
ULevel * GetLevel() const
Definition Actor.cpp:18
Abstract base class for actor iteration. Implements all operators and relies on IsActorSuitable to be...
Definition KarmaUtilities.h:89
FActorIteratorState(const UWorld *InWorld, const TSubclassOf< AActor > InClass)
Default constructor, initializes everything relevant.
Definition KarmaUtilities.h:133
UClass * m_DesiredClass
Definition KarmaUtilities.h:113
FActorIteratorState()
Default constructor.
Definition KarmaUtilities.h:123
KarmaVector< UObject * > m_ObjectArray
Definition KarmaUtilities.h:95
bool m_ReachedEnd
Definition KarmaUtilities.h:101
const UWorld * m_CurrentWorld
Definition KarmaUtilities.h:92
KarmaVector< AActor * > m_SpawnedActorArray
Definition KarmaUtilities.h:110
~FActorIteratorState()
A destructor.
Definition KarmaUtilities.h:192
FORCEINLINE AActor * GetActorChecked() const
Returns the current suitable actor pointed at by the Iterator.
Definition KarmaUtilities.h:204
int32_t m_Index
Definition KarmaUtilities.h:98
int32_t m_ConsideredCount
Definition KarmaUtilities.h:104
AActor * m_CurrentActor
Definition KarmaUtilities.h:107
The basic utilities class.
Definition KarmaUtilities.h:30
static unsigned char * GetImagePixelData(char const *fileName, int *width, int *height, int *channels, int req_comp)
Gathers image pixel data, arranged left-to-right, top-to-bottom, for the supplied image file.
Definition KarmaUtilities.cpp:32
static std::string GetFilePath(const std::string &str)
Extracts the file path from file source string (filepath + filename.extention).
Definition KarmaUtilities.cpp:26
static std::string ReadFileToSpitString(const std::string &filePath)
Generates a sting of text contained within a file.
Definition KarmaUtilities.cpp:5
FORCEINLINE AActor * operator->() const
Returns the current suitable actor pointed at by the Iterator.
Definition KarmaUtilities.h:364
void operator++()
Iterates to next suitable actor.
Definition KarmaUtilities.h:304
TActorIteratorBase(const UWorld *InWorld, TSubclassOf< AActor > InClass, const EActorIteratorFlags InFlags)
Constructor for setting m_State (FActorIteratorState) with the supplied InWorld and InClass.
Definition KarmaUtilities.h:290
FORCEINLINE bool CanIterateLevel(const ULevel *Level) const
Used to examine whether this level is valid for iteration or not. This function should be redefined (...
Definition KarmaUtilities.h:413
FORCEINLINE bool IsActorSuitable(const AActor *Actor) const
Determines whether this is a valid actor or not. This function should be redefined (thus hiding this ...
Definition KarmaUtilities.h:446
FORCEINLINE AActor * operator*() const
Returns the current suitable actor pointed at by the Iterator.
Definition KarmaUtilities.h:353
TActorIteratorBase(EActorIteratorType)
A constructor.
Definition KarmaUtilities.h:275
void ClearCurrent()
Clears the current Actor in the array (setting it to NULL).
Definition KarmaUtilities.h:386
int32 GetProgressNumerator() const
Returns the number of actors considered thus far. Can be used in combination with GetProgressDenomina...
Definition KarmaUtilities.h:399
Template to allow TClassType's to be passed around with type safety.
Definition SubClassOf.h:117
An object class.
Definition Class.h:158
A Level is a collection of Actors (lights, volumes, mesh instances etc.). Multiple Levels can be load...
Definition Level.h:28
virtual UWorld * GetWorld() const override final
Override for UObject's GetWorld.
Definition Level.cpp:17
FORCEINLINE bool IsA(OtherClassType SomeBase) const
Definition UObjectBase.h:288
The base class of all the game code relevant objects.
Definition Object.h:106
bool IsSelected() const
Test the selection state of a UObject.
Definition Object.cpp:181
The World is the top level object representing a map or a sandbox in which Actors and Components will...
Definition World.h:148
ULevel * GetPersistentLevel() const
Definition World.h:199
Karma's std::vector wrapper with additional functionalities.
Definition KarmaTypes.h:243
uint32_t Num() const
Returns the total number of elements in a vector.
Definition KarmaTypes.h:454
const std::vector< BuildingBlock > & GetElements() const
Getter for the elements of vector.
Definition KarmaTypes.h:536