KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
Karma::AActor Class Reference

Actor is the base class for an object that can be placed or spawned in a level. More...

#include <Actor.h>

Inheritance diagram for Karma::AActor:
Collaboration diagram for Karma::AActor:

Public Member Functions

 AActor ()
 
ULevelGetLevel () const
 
void PostSpawnInitialize (FTransform const &SpawnTransform, AActor *InOwner, APawn *InInstigator, bool bRemoteOwned, bool bNoFail, bool bDeferConstruction)
 
virtual UWorldGetWorld () const override final
 
bool HasActorBegunPlay () const
 
bool IsActorBeginningPlay () const
 
void DispatchBeginPlay (bool bFromLevelStreaming=false)
 
virtual void SetOwner (AActor *NewOwner)
 
void FinishSpawning (const FTransform &Transform, bool bIsDefaultTransform=false)
 
bool IsOwnedBy (const AActor *TestOwner) const
 
void PostActorConstruction ()
 
void GetComponents (KarmaVector< USceneComponent * > &OutComponents) const
 
void GetComponents (KarmaVector< UActorComponent * > &OutComponents) const
 
void SetInstigator (APawn *InInstigator)
 
FORCEINLINE USceneComponentGetRootComponent () const
 
bool SetRootComponent (USceneComponent *NewRootComponent)
 
const FTransformGetTransform () const
 
const FTransformActorToWorld () const
 
void InitializeComponents ()
 
virtual void PostInitializeComponents ()
 
AActorGetParentActor () const
 
UChildActorComponentGetParentComponent () const
 
void RemoveOwnedComponent (std::shared_ptr< UActorComponent > Component)
 
bool GetAutoDestroyWhenFinished () const
 
bool CanTick () const
 
void DisableTick (bool bDisable)
 
virtual void Tick (float DeltaSeconds)
 
- Public Member Functions inherited from Karma::UObject
 UObject ()
 
virtual void FinishDestroy ()
 
virtual const std::string & GetDesc ()
 Return a one line description of an object for viewing in the thumbnail view of the generic browser.
 
bool IsValidChecked (const UObject *Test)
 
virtual void BeginDestroy ()
 Called before destroying the object. This is called immediately upon deciding to destroy the object, to allow the object to begin an asynchronous cleanup process.
 
FORCEINLINE bool Modify (bool bAlwaysMarkDirty=true)
 
bool IsSelected () const
 Test the selection state of a UObject.
 
- Public Member Functions inherited from Karma::UObjectBase
 UObjectBase (UClass *inClass, EObjectFlags inFlags, EInternalObjectFlags inInternalFlags, UObject *inOuter, const std::string &inName)
 
UPackageGetPackage () const
 
UPackageGetExternalPackage () const
 
bool IsUnreachable () const
 
FORCEINLINE void SetInternalIndex (uint32_t StoreIndex)
 
FORCEINLINE uint32_t GetInternalIndex () const
 
void MarkAsGarbage ()
 
void ClearGarbage ()
 
FORCEINLINE const std::string & GetName () const
 
FORCEINLINE void SetObjectName (const std::string &aName)
 
FORCEINLINE UObjectGetOuter () const
 
UObjectGetTypedOuter (UClass *Target) const
 
template<typename T>
T * GetTypedOuter () const
 
bool IsValidLowLevel () const
 
template<typename OtherClassType>
FORCEINLINE bool IsA (OtherClassType SomeBase) const
 
FORCEINLINE UClassGetClass () const
 
FORCEINLINE EObjectFlags GetFlags () const
 
FORCEINLINE void SetFlags (EObjectFlags NewFlags)
 
FORCEINLINE void ClearFlags (EObjectFlags FlagsToClear)
 
FORCEINLINE bool HasAnyFlags (EObjectFlags FlagsToCheck) const
 
FORCEINLINE bool HasAnyInternalFlags (EInternalObjectFlags FlagsToCheck) const
 
FORCEINLINE void SetInternalFlags (EInternalObjectFlags FlagsToSet) const
 
FORCEINLINE void AddToRoot ()
 

Static Public Member Functions

static void DispatchOnComponentsCreated (AActor *NewActor)
 
static USceneComponentFixupNativeActorComponents (AActor *Actor)
 
- Static Public Member Functions inherited from Karma::UObject
static const char * StaticConfigName ()
 
- Static Public Member Functions inherited from Karma::UObjectBase
static FORCEINLINE EInternalObjectFlags FixGarbageOrPendingKillInternalObjectFlags (const EInternalObjectFlags InFlags)
 

Public Attributes

float m_CreationTime
 
AActorm_Owner
 
KarmaVector< AActor * > m_Children
 

Protected Member Functions

virtual void BeginPlay ()
 
- Protected Member Functions inherited from Karma::UObjectBase
 UObjectBase ()
 Providing a default constructor.
 
FORCEINLINE void SetFlagsTo (EObjectFlags NewFlags)
 

Protected Attributes

USceneComponentm_RootComponent
 
bool m_bCanEverTick
 

Detailed Description

Actor is the base class for an object that can be placed or spawned in a level.

A concept taken from Unreal Engine. Actors may contain a collection of ActorComponents, which can be used to control how actors move, how they are rendered, etc.

Constructor & Destructor Documentation

◆ AActor()

Karma::AActor::AActor ( )

Default constructor for AActor

Since
Karma 1.0.0

Member Function Documentation

◆ ActorToWorld()

const FTransform & Karma::AActor::ActorToWorld ( ) const
inline

Get the local-to-world transform of the RootComponent. Identical to GetTransform().

Warning
Need to test this function rigorously before using
Since
Karma 1.0.0

◆ BeginPlay()

void Karma::AActor::BeginPlay ( )
protectedvirtual

Overridable native event for when play begins for this actor.

Since
Karma 1.0.0

◆ CanTick()

bool Karma::AActor::CanTick ( ) const
inline

Fory querying if the actor can tick.

Returns
true if the actor can tick
Since
Karma 1.0.0

◆ DisableTick()

void Karma::AActor::DisableTick ( bool bDisable)
inline

Routine to enable or disable actor ticking

Parameters
bDisableParameter to set actor ticking
Since
Karma 1.0.0

◆ DispatchBeginPlay()

void Karma::AActor::DispatchBeginPlay ( bool bFromLevelStreaming = false)

Initiate a begin play call on this Actor, will handle calling in the correct order.

Parameters
bFromLevelStreaming- Not functinal -
Since
Karma 1.0.0

GetPathName()

◆ DispatchOnComponentsCreated()

void Karma::AActor::DispatchOnComponentsCreated ( AActor * NewActor)
static

Utility to call OnComponentCreated on components

Parameters
NewActorThe newly created actor
Since
Karma 1.0.0

◆ FinishSpawning()

void Karma::AActor::FinishSpawning ( const FTransform & Transform,
bool bIsDefaultTransform = false )

Called to finish the spawning process, generally in the case of deferred spawning

Parameters
TransformThe FTransform of the spawned actor
bIsDefaultTransform- Not functional -
Since
Karma 1.0.0

◆ FixupNativeActorComponents()

USceneComponent * Karma::AActor::FixupNativeActorComponents ( AActor * Actor)
static

Utility that sets up the actor's component hierarchy (when users forget to do so, in their native ctor)

Parameters
ActorThe actor whose components hierarchy needs to be fixed
Since
Karma 1.0.0

◆ GetAutoDestroyWhenFinished()

bool Karma::AActor::GetAutoDestroyWhenFinished ( ) const
inline

Returns the m_bAutoDestoryWhenFinished

Since
Karma 1.0.0

◆ GetComponents() [1/2]

void Karma::AActor::GetComponents ( KarmaVector< UActorComponent * > & OutComponents) const
inline

Gathers the actor owned componets and appends the OutComponents likewise

Parameters
OutComponentsThe vector of components which is filled with elements of m_OwnedComponents
Since
Karma 1.0.0

◆ GetComponents() [2/2]

void Karma::AActor::GetComponents ( KarmaVector< USceneComponent * > & OutComponents) const
inline

Get all components derived from class 'ComponentType' and fill in the OutComponents array with the result.

Note
ue: It's recommended to use TArrays with a TInlineAllocator to potentially avoid memory allocation costs.
Parameters
bIncludeFromChildActorsIf true then recurse in to ChildActor components and find components of the appropriate type in those Actors as well
Since
Karma 1.0.0

◆ GetLevel()

ULevel * Karma::AActor::GetLevel ( ) const

Return the ULevel that this Actor is part of.

Remarks
Usually LevelToSpawnIn is returned
Since
Karma 1.0.0

◆ GetParentActor()

AActor * Karma::AActor::GetParentActor ( ) const

If this Actor was created by a Child Actor Component returns the Actor that owns that Child Actor Component

Returns
The parent actor that owns the child actor
See also
AActor::PostActorConstruction()
Since
Karma 1.0.0

◆ GetParentComponent()

UChildActorComponent * Karma::AActor::GetParentComponent ( ) const

If this Actor was created by a Child Actor Component returns that Child Actor Component

Returns
m_ParentComponent
Since
Karma 1.0.0

◆ GetRootComponent()

FORCEINLINE USceneComponent * Karma::AActor::GetRootComponent ( ) const
inline

Returns this actor's root component.

Returns
the m_RootComponent
Since
Karma 1.0.0

◆ GetTransform()

const FTransform & Karma::AActor::GetTransform ( ) const
inline

Get the actor-to-world transform.

Returns
The transform that transforms from actor space to world space.
Since
Karma 1.0.0

◆ GetWorld()

UWorld * Karma::AActor::GetWorld ( ) const
finaloverridevirtual

Getter for the cached world pointer, will return null if the actor is not actually spawned in a level

Since
Karma 1.0.0

Reimplemented from Karma::UObject.

◆ HasActorBegunPlay()

bool Karma::AActor::HasActorBegunPlay ( ) const
inline

Returns whether an actor has had BeginPlay called on it (and not subsequently had EndPlay called)

Since
Karma 1.0.0

◆ InitializeComponents()

void Karma::AActor::InitializeComponents ( )

Iterate over components array and call InitializeComponent, which happens once per actor

See also
AActor::PostActorConstruction()
Since
Karma 1.0.0

◆ IsActorBeginningPlay()

bool Karma::AActor::IsActorBeginningPlay ( ) const
inline

Returns whether an actor is in the process of beginning play

Since
Karma 1.0.0

◆ IsOwnedBy()

bool Karma::AActor::IsOwnedBy ( const AActor * TestOwner) const
inline

See if this actor is owned by TestOwner.

Parameters
TestOwnerThe actor to be testified with
See also
AActor::SetOwner(AActor* NewOwner)
Since
Karma 1.0.0

◆ PostActorConstruction()

void Karma::AActor::PostActorConstruction ( )

Called after the actor has run its construction. Responsible for finishing the actor spawn process.

Since
Karma 1.0.0

bDeferBeginPlayAndUpdateOverlaps &&

◆ PostInitializeComponents()

void Karma::AActor::PostInitializeComponents ( )
virtual

Allow actors to initialize themselves on the C++ side after all of their components have been initialized, only called during gameplay

See also
AActor::PostActorConstruction()

◆ PostSpawnInitialize()

void Karma::AActor::PostSpawnInitialize ( FTransform const & SpawnTransform,
AActor * InOwner,
APawn * InInstigator,
bool bRemoteOwned,
bool bNoFail,
bool bDeferConstruction )

Called after the actor is spawned in the world. Responsible for setting up actor for play.

For instance the time of spawning is recorded, owner is set, instigator is set, and all that.

Parameters
SpawnTransformThe FTransform of the actor with which the spawning happens
InOwnerThe actor that owns this actor
InInstigatorThe pawn that is the cause for instigated relevant part of actor
bRemoteOwned- Not functional -
bNoFailForce continue spawning even if not valid
bDeferConstruction- Not functional - (for waiting for BP construction script)
Remarks
bNoFail is little finicky for me to comprehend. May become clear on actual game development, hehe.
Since
Karma 1.0.0

◆ RemoveOwnedComponent()

void Karma::AActor::RemoveOwnedComponent ( std::shared_ptr< UActorComponent > Component)

Removes a component from the OwnedComponents array of the Actor. In general this should not need to be called directly by anything other than UActorComponent functions

Todo
Not functional yet
Since
Karma 1.0.0

◆ SetInstigator()

void Karma::AActor::SetInstigator ( APawn * InInstigator)

Sets the value of Instigator without causing other side effects to this instance.

Parameters
InInstigatorThe pawn who is the cause of instigation by this actor
Since
Karma 1.0.0

◆ SetOwner()

void Karma::AActor::SetOwner ( AActor * NewOwner)
virtual

Set the owner of this Actor, used primarily for network replication.

Parameters
NewOwnerThe Actor who takes over ownership of this Actor
Since
Karma 1.0.0

◆ SetRootComponent()

bool Karma::AActor::SetRootComponent ( USceneComponent * NewRootComponent)

Sets root component to be the specified component. NewRootComponent's owner should be this actor.

Returns
true if successful
Since
Karma 1.0.0

Only components owned by this actor can be used as a its root component.

◆ Tick()

void Karma::AActor::Tick ( float DeltaSeconds)
virtual

Function called every frame on this Actor. Override this function to implement custom logic to be executed every frame.

Remarks
Note that Tick is enabled by default, and you will need to check m_bCanEverTick is set to false to disable it.
Parameters
DeltaSecondsGame time elapsed during last frame modified by the time dilation
Since
Karma 1.0.0

Member Data Documentation

◆ m_Children

KarmaVector<AActor*> Karma::AActor::m_Children

Array of all Actors whose Owner is this actor, these are not necessarily spawned by UChildActorComponent Needs to be raw pointer only.

◆ m_CreationTime

float Karma::AActor::m_CreationTime

The time this actor was created, relative to World->GetTimeSeconds().

See also
UWorld::GetTimeSeconds()

◆ m_Owner

AActor* Karma::AActor::m_Owner

Owner of this Actor, used primarily for replication (bNetUseOwnerRelevancy & bOnlyRelevantToOwner) and visibility (PrimitiveComponent bOwnerNoSee and bOnlyOwnerSee)

See also
SetOwner(), GetOwner()

◆ m_RootComponent

USceneComponent* Karma::AActor::m_RootComponent
protected

Event when play begins for this actor. For blueprint trigger The component that defines the transform (location, rotation, scale) of this Actor in the world, all other components must be attached to this one somehow.

Needs be raw pointer only


The documentation for this class was generated from the following files: