Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
EngineCore::LogicComponent Class Reference

Base class for all logic components that can be attached to an actor. Provides access to the scene, tick functionality, and lifecycle events. More...

#include <LogicComponent.h>

Inheritance diagram for EngineCore::LogicComponent:
Collaboration diagram for EngineCore::LogicComponent:

Public Member Functions

 LogicComponent (Scene *owningScene)
virtual ~LogicComponent ()=default
virtual void beginPlay ()
 Called when the component is added to the scene or the game starts.
virtual void tick (double deltaTime)
 Called every frame if ticking is enabled.
virtual void endPlay ()
 Called when the component is removed or the game ends.
bool canTick () const
 Checks if the component is currently set to tick.
void setCanTick (bool enable)
 Enables or disables ticking for this component.
EntitygetOwningEntity () const
 Gets the entity this component belongs to.

Static Public Attributes

static constexpr bool IsUnique = false
 Defines whether multiple instances of this component can exist on the same entity. Defaults to false (multiple allowed). Override in derived classes with static constexpr bool IsUnique = true; if needed.

Protected Member Functions

ScenegetScene () const
 Gets the scene this component belongs to.
SceneManagergetSceneManager () const
 Helper to get the SceneManager from the owning scene.

Private Member Functions

void setOwningEntity (Entity *entity)
 Sets the owning entity. Called by Entity::addComponent().

Private Attributes

Scenescene = nullptr
EntityowningEntity_ = nullptr
bool tickEnabled = false

Friends

class Entity

Detailed Description

Base class for all logic components that can be attached to an actor. Provides access to the scene, tick functionality, and lifecycle events.

Date
2025-12-06
Author
Konstantin Passig

Definition at line 14 of file LogicComponent.h.

Constructor & Destructor Documentation

◆ LogicComponent()

◆ ~LogicComponent()

virtual EngineCore::LogicComponent::~LogicComponent ( )
virtualdefault

References Entity.

Here is the call graph for this function:

Member Function Documentation

◆ beginPlay()

void EngineCore::LogicComponent::beginPlay ( )
virtual

Called when the component is added to the scene or the game starts.

Reimplemented in EngineCore::CameraComponent, EngineCore::CollisionComponent, EngineCore::MeshComponent, EngineCore::PhysicsBodyComponent, EngineCore::TestComponent, and EngineCore::VrMovementComponent.

Definition at line 10 of file LogicComponent.cpp.

Referenced by EngineCore::CameraComponent::beginPlay(), EngineCore::CollisionComponent::beginPlay(), EngineCore::MeshComponent::beginPlay(), EngineCore::PhysicsBodyComponent::beginPlay(), and EngineCore::VrMovementComponent::beginPlay().

Here is the caller graph for this function:

◆ canTick()

bool EngineCore::LogicComponent::canTick ( ) const
nodiscard

Checks if the component is currently set to tick.

Returns
true if ticking is enabled.

Definition at line 22 of file LogicComponent.cpp.

References tickEnabled.

◆ endPlay()

void EngineCore::LogicComponent::endPlay ( )
virtual

Called when the component is removed or the game ends.

Reimplemented in EngineCore::CameraComponent, EngineCore::CollisionComponent, EngineCore::MeshComponent, EngineCore::PhysicsBodyComponent, EngineCore::TestComponent, and EngineCore::VrMovementComponent.

Definition at line 18 of file LogicComponent.cpp.

Referenced by EngineCore::CameraComponent::endPlay(), EngineCore::CollisionComponent::endPlay(), EngineCore::MeshComponent::endPlay(), EngineCore::PhysicsBodyComponent::endPlay(), and EngineCore::VrMovementComponent::endPlay().

Here is the caller graph for this function:

◆ getOwningEntity()

Entity * EngineCore::LogicComponent::getOwningEntity ( ) const
nodiscard

Gets the entity this component belongs to.

Returns
Pointer to the owning Entity.

Definition at line 41 of file LogicComponent.cpp.

References Entity, and owningEntity_.

Referenced by EngineCore::PhysicsBodyComponent::beginPlay(), and EngineCore::CollisionComponent::registerWithBody().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getScene()

Scene * EngineCore::LogicComponent::getScene ( ) const
nodiscardprotected

Gets the scene this component belongs to.

Returns
Pointer to the owning Scene.

Definition at line 30 of file LogicComponent.cpp.

References scene.

◆ getSceneManager()

SceneManager * EngineCore::LogicComponent::getSceneManager ( ) const
nodiscardprotected

Helper to get the SceneManager from the owning scene.

Returns
Pointer to the SceneManager.

Definition at line 34 of file LogicComponent.cpp.

References scene.

◆ setCanTick()

void EngineCore::LogicComponent::setCanTick ( bool enable)

Enables or disables ticking for this component.

Parameters
enableTrue to enable ticking, false to disable.

Definition at line 26 of file LogicComponent.cpp.

References tickEnabled.

Referenced by EngineCore::CameraComponent::CameraComponent(), EngineCore::TestComponent::TestComponent(), and EngineCore::VrMovementComponent::VrMovementComponent().

Here is the caller graph for this function:

◆ setOwningEntity()

void EngineCore::LogicComponent::setOwningEntity ( Entity * entity)
private

Sets the owning entity. Called by Entity::addComponent().

Parameters
entityPointer to the owning entity.

Definition at line 45 of file LogicComponent.cpp.

References Entity, and owningEntity_.

Here is the call graph for this function:

◆ tick()

void EngineCore::LogicComponent::tick ( double deltaTime)
virtual

Called every frame if ticking is enabled.

Parameters
deltaTimeTime elapsed since last frame.

Reimplemented in EngineCore::CameraComponent, EngineCore::TestComponent, and EngineCore::VrMovementComponent.

Definition at line 14 of file LogicComponent.cpp.

◆ Entity

Member Data Documentation

◆ IsUnique

bool EngineCore::LogicComponent::IsUnique = false
staticconstexpr

Defines whether multiple instances of this component can exist on the same entity. Defaults to false (multiple allowed). Override in derived classes with static constexpr bool IsUnique = true; if needed.

Definition at line 19 of file LogicComponent.h.

◆ owningEntity_

Entity* EngineCore::LogicComponent::owningEntity_ = nullptr
private

Definition at line 81 of file LogicComponent.h.

Referenced by getOwningEntity(), and setOwningEntity().

◆ scene

◆ tickEnabled

bool EngineCore::LogicComponent::tickEnabled = false
private

Definition at line 82 of file LogicComponent.h.

Referenced by canTick(), and setCanTick().


The documentation for this class was generated from the following files:
  • /home/magerbeton/Documents/gl3-vulkan/Engine/include/Engine/Component/LogicComponent.h
  • /home/magerbeton/Documents/gl3-vulkan/Engine/src/Engine/Component/LogicComponent.cpp