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

ActorComponent is the base class for components that define reusable behavior that can be added to different types of Actors. ActorComponents that have a transform are known as SceneComponents and those that can be rendered are PrimitiveComponents. Components are a special type of Object that Actors can attach to themselves as sub-objects. Components are useful for sharing common behaviors. More...

#include <ActorComponent.h>

Inheritance diagram for Karma::UActorComponent:
Collaboration diagram for Karma::UActorComponent:

Public Member Functions

 UActorComponent ()
 A constructor.
 
virtual void TickComponent (float deltaTime)
 Function called every frame on this ActorComponent. Override this function to implement custom logic to be executed every frame. Only executes if the component is registered, and also PrimaryComponentTick.bCanEverTick must be set to true.
 
virtual void BeginPlay ()
 Begins Play for the component. Called when the owning Actor begins play or when the component is created if the Actor has already begun play. Actor BeginPlay normally happens right after PostInitializeComponents but can be delayed for networked or child actors. Requires component to be registered and initialized.
 
virtual void EndPlay (const EEndPlayReason::Type EndPlayReason)
 Ends gameplay for this component. //Called from AActor::EndPlay only if bHasBegunPlay is true// <- not quite sure about the call.
 
AActorGetOwner () const
 Follow the Outer chain to get the AActor that 'Owns' this component.
 
bool HasBeenCreated () const
 Indicates that OnCreatedComponent has been called, but OnDestroyedComponent has not yet.
 
virtual void OnComponentCreated ()
 Called when a component is created (not loaded). This can happen in the editor or during gameplay.
 
bool IsRegistered () const
 See if this component is currently registered.
 
bool IsActive () const
 Returns whether the component is active or not.
 
virtual void Activate (bool bReset=false)
 Activates the SceneComponent, should be overridden by native child classes.
 
void SetActiveFlag (const bool bNewIsActive)
 Sets the value of bIsActive without causing other side effects to this instance.
 
bool HasBeenInitialized () const
 Indicates that InitializeComponent has been called, but UninitializeComponent has not yet.
 
virtual void InitializeComponent ()
 Initializes the component. Occurs at level startup or actor spawn. This is before BeginPlay (Actor or Component). All Components in the level will be Initialized on load before any Actor/Component gets BeginPlay Requires component to be registered, and bWantsInitializeComponent to be true.
 
bool HasBegunPlay () const
 Indicates that BeginPlay has been called, but EndPlay has not yet.
 
virtual void BeginDestroy () override
 Overridden BeginDestroy() for UActorComponent.
 
virtual void UninitializeComponent ()
 Handle this component being Uninitialized.
 
virtual void OnComponentDestroyed (bool bDestroyingHierarchy)
 Called when a component is destroyed.
 
- 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.
 
virtual class UWorldGetWorld () const
 Returns what UWorld this object is contained within.
 
bool IsValidChecked (const UObject *Test)
 
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 ()
 

Public Attributes

EComponentCreationMethod m_CreationMethod
 
uint8_t m_bAutoActivate: 1
 
uint8_t m_bWantsInitializeComponent: 1
 

Protected Member Functions

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

Protected Attributes

uint8_t m_bRegistered: 1
 

Additional Inherited Members

- 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)
 

Detailed Description

ActorComponent is the base class for components that define reusable behavior that can be added to different types of Actors. ActorComponents that have a transform are known as SceneComponents and those that can be rendered are PrimitiveComponents. Components are a special type of Object that Actors can attach to themselves as sub-objects. Components are useful for sharing common behaviors.

See also
ActorComponent
https://docs.unrealengine.com/5.2/en-US/components-in-unreal-engine/
USceneComponent
UPrimitiveComponent

Constructor & Destructor Documentation

◆ UActorComponent()

Karma::UActorComponent::UActorComponent ( )

A constructor.

Since
Karma 1.0.0

Member Function Documentation

◆ Activate()

void Karma::UActorComponent::Activate ( bool bReset = false)
virtual

Activates the SceneComponent, should be overridden by native child classes.

Parameters
bReset- Whether the activation should happen even if ShouldActivate returns false.
Since
Karma 1.0.0

◆ BeginDestroy()

void Karma::UActorComponent::BeginDestroy ( )
overridevirtual

◆ BeginPlay()

void Karma::UActorComponent::BeginPlay ( )
virtual

Begins Play for the component. Called when the owning Actor begins play or when the component is created if the Actor has already begun play. Actor BeginPlay normally happens right after PostInitializeComponents but can be delayed for networked or child actors. Requires component to be registered and initialized.

See also
AActor::BeginPlay()
Since
Karma 1.0.0

Reimplemented in Karma::UPrimitiveComponent.

◆ EndPlay()

void Karma::UActorComponent::EndPlay ( const EEndPlayReason::Type EndPlayReason)
virtual

Ends gameplay for this component. //Called from AActor::EndPlay only if bHasBegunPlay is true// <- not quite sure about the call.

See also
UActorComponent::BeginDestroy()
Since
Karma 1.0.0

◆ GetOwner()

AActor * Karma::UActorComponent::GetOwner ( ) const

Follow the Outer chain to get the AActor that 'Owns' this component.

Since
Karma 1.0.0

◆ HasBeenCreated()

bool Karma::UActorComponent::HasBeenCreated ( ) const
inline

Indicates that OnCreatedComponent has been called, but OnDestroyedComponent has not yet.

Since
Karma 1.0.0

◆ HasBeenInitialized()

bool Karma::UActorComponent::HasBeenInitialized ( ) const
inline

Indicates that InitializeComponent has been called, but UninitializeComponent has not yet.

Since
Karma 1.0.0

◆ HasBegunPlay()

bool Karma::UActorComponent::HasBegunPlay ( ) const
inline

Indicates that BeginPlay has been called, but EndPlay has not yet.

Since
Karma 1.0.0

◆ InitializeComponent()

void Karma::UActorComponent::InitializeComponent ( )
virtual

Initializes the component. Occurs at level startup or actor spawn. This is before BeginPlay (Actor or Component). All Components in the level will be Initialized on load before any Actor/Component gets BeginPlay Requires component to be registered, and bWantsInitializeComponent to be true.

Since
Karma 1.0.0

◆ IsActive()

bool Karma::UActorComponent::IsActive ( ) const
inline

Returns whether the component is active or not.

Returns
- The active state of the component.
Since
Karma 1.0.0

◆ IsRegistered()

bool Karma::UActorComponent::IsRegistered ( ) const
inline

See if this component is currently registered.

Since
Karma 1.0.0

◆ OnComponentCreated()

void Karma::UActorComponent::OnComponentCreated ( )
virtual

Called when a component is created (not loaded). This can happen in the editor or during gameplay.

Since
Karma 1.0.0

◆ OnComponentDestroyed()

void Karma::UActorComponent::OnComponentDestroyed ( bool bDestroyingHierarchy)
virtual

Called when a component is destroyed.

Parameters
bDestroyingHierarchy- True if the entire component hierarchy is being torn down, allows avoiding expensive operations

◆ SetActiveFlag()

void Karma::UActorComponent::SetActiveFlag ( const bool bNewIsActive)

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

Activate, Deactivate, and SetActive are preferred in most cases because they respect virtual behavior.

Since
Karma 1.0.0

◆ ShouldActivate()

bool Karma::UActorComponent::ShouldActivate ( ) const
protectedvirtual

Return true if this component is in a state where it can be activated normally.

◆ TickComponent()

void Karma::UActorComponent::TickComponent ( float deltaTime)
virtual

Function called every frame on this ActorComponent. Override this function to implement custom logic to be executed every frame. Only executes if the component is registered, and also PrimaryComponentTick.bCanEverTick must be set to true.

Note
Not functional yet this seems
Parameters
deltaTime- The time since the last tick. Rest of the params shall be functionla later
TickType- The kind of tick this is, for example, are we paused, or 'simulating' in the editor
ThisTickFunction- Internal tick function struct that caused this to run

◆ UninitializeComponent()

void Karma::UActorComponent::UninitializeComponent ( )
virtual

Handle this component being Uninitialized.

See also
Called from AActor::EndPlay only if bHasBeenInitialized is true

Member Data Documentation

◆ m_bAutoActivate

uint8_t Karma::UActorComponent::m_bAutoActivate

Whether the component is activated at creation or must be explicitly activated.

◆ m_bRegistered

uint8_t Karma::UActorComponent::m_bRegistered
protected

Indicates if this ActorComponent is currently registered with a scene.

◆ m_bWantsInitializeComponent

uint8_t Karma::UActorComponent::m_bWantsInitializeComponent

If true, we call the virtual InitializeComponent

◆ m_CreationMethod

EComponentCreationMethod Karma::UActorComponent::m_CreationMethod

Describes how a component instance will be created


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