49 static std::string
GetFilePath(
const std::string& str);
80 static unsigned char*
GetImagePixelData(
char const* fileName,
int* width,
int* height,
int* channels,
int req_comp);
151 if (InClass == AActor::StaticClass())
155 for (
ULevel* Level : InWorld->GetLevels())
159 NumActors += Level->Actors.Num();
164 ObjectArray.Reserve(NumActors);
168 for (
ULevel* Level : InWorld->GetLevels())
172 ObjectArray.Append(Level->Actors);
258 template <
typename Derived>
265 std::shared_ptr<FActorIteratorState> m_State;
308 AActor* localCurrentActor =
nullptr;
309 int32_t localIndex = m_State->m_Index;
312 const UWorld* localCurrentWorld = m_State->m_CurrentWorld;
314 int32_t lObjectArrayNum = int32_t(localObjectArray.
Num());
315 int32_t lSAArrayNum = int32_t(localSpawnedActorArray.
Num());
317 while (++localIndex < (lObjectArrayNum + lSAArrayNum))
319 if (localIndex < lObjectArrayNum)
321 localCurrentActor =
static_cast<AActor*
>(localObjectArray.
GetElements()[localIndex]);
325 localCurrentActor = localSpawnedActorArray.
GetElements()[localIndex - lObjectArrayNum];
327 m_State->m_ConsideredCount++;
329 ULevel* actorLevel = localCurrentActor ? localCurrentActor->
GetLevel() :
nullptr;
332 &&
static_cast<const Derived*
>(
this)->
IsActorSuitable(localCurrentActor)
333 &&
static_cast<const Derived*
>(
this)->
CanIterateLevel(actorLevel) && actorLevel->
GetWorld() == localCurrentWorld)
336 if (actorLevel == localCurrentWorld->
GetPersistentLevel() || !localCurrentActor->
IsA(AWorldSettings::StaticClass()))
338 m_State->m_CurrentActor = localCurrentActor;
339 m_State->m_Index = localIndex;
344 m_State->m_CurrentActor =
nullptr;
345 m_State->m_ReachedEnd =
true;
356 return m_State->GetActorChecked();
367 return m_State->GetActorChecked();
379 return !m_State->m_ReachedEnd;
389 KR_CORE_ASSERT(!m_State->m_ReachedEnd,
"");
390 m_State->m_CurrentWorld->RemoveActor(m_State->m_CurrentActor,
true);
402 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:157
EActorIteratorFlags
Iteration flags, specifies which types of levels and actors should be iterated.
Definition KarmaUtilities.h:228
@ OnlySelectedActors
Only iterate actors that are selected.
Definition KarmaUtilities.h:240
@ SkipPendingKill
Skip pending kill actors.
Definition KarmaUtilities.h:236
@ OnlyActiveLevels
Only iterate active levels.
Definition KarmaUtilities.h:244
@ AllActors
No flags, iterate all actors.
Definition KarmaUtilities.h:232
EActorIteratorType
Type enum, used to represent the special End iterator.
Definition KarmaUtilities.h:251
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:34
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:90
FActorIteratorState(const UWorld *InWorld, const TSubclassOf< AActor > InClass)
Default constructor, initializes everything relevant.
Definition KarmaUtilities.h:134
UClass * m_DesiredClass
Definition KarmaUtilities.h:114
FActorIteratorState()
Default constructor.
Definition KarmaUtilities.h:124
KarmaVector< UObject * > m_ObjectArray
Definition KarmaUtilities.h:96
bool m_ReachedEnd
Definition KarmaUtilities.h:102
const UWorld * m_CurrentWorld
Definition KarmaUtilities.h:93
KarmaVector< AActor * > m_SpawnedActorArray
Definition KarmaUtilities.h:111
~FActorIteratorState()
A destructor.
Definition KarmaUtilities.h:193
FORCEINLINE AActor * GetActorChecked() const
Returns the current suitable actor pointed at by the Iterator.
Definition KarmaUtilities.h:205
int32_t m_Index
Definition KarmaUtilities.h:99
int32_t m_ConsideredCount
Definition KarmaUtilities.h:105
AActor * m_CurrentActor
Definition KarmaUtilities.h:108
The basic utilities class.
Definition KarmaUtilities.h:31
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:365
void operator++()
Iterates to next suitable actor.
Definition KarmaUtilities.h:305
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:291
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:414
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:447
FORCEINLINE AActor * operator*() const
Returns the current suitable actor pointed at by the Iterator.
Definition KarmaUtilities.h:354
TActorIteratorBase(EActorIteratorType)
A constructor.
Definition KarmaUtilities.h:276
void ClearCurrent()
Clears the current Actor in the array (setting it to NULL).
Definition KarmaUtilities.h:387
int32 GetProgressNumerator() const
Returns the number of actors considered thus far. Can be used in combination with GetProgressDenomina...
Definition KarmaUtilities.h:400
Template to allow TClassType's to be passed around with type safety.
Definition SubClassOf.h:119
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:30
virtual UWorld * GetWorld() const override final
Override for UObject's GetWorld.
Definition Level.cpp:17
FORCEINLINE bool IsA(OtherClassType SomeBase) const
Definition UObjectBase.h:278
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:150
ULevel * GetPersistentLevel() const
Definition World.h:195
Karma's std::vector wrapper.
Definition KarmaTypes.h:152
uint32_t Num() const
Returns the total number of elements in a vector.
Definition KarmaTypes.h:302
const std::vector< BuildingBlock > & GetElements() const
Getter for the elements of vector.
Definition KarmaTypes.h:371