Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Components::Logic 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 Engine::Components::Logic:
Collaboration diagram for Engine::Components::Logic:

Public Member Functions

 Logic (Entities::Scene *owningScene)
virtual ~Logic ()=default
virtual std::string getComponentName () const
 Gets the component type name for debugging/UI.
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 hasBegunPlay () const
bool canTick () const
 Checks if the component is currently set to tick.
void setCanTick (bool enable)
 Enables or disables ticking for this component.
Entities::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.
static constexpr const char * ComponentName = "Logic"
 Fallback component type name. Derived classes may override getComponentName() for custom labels.

Protected Member Functions

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

Private Member Functions

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

Private Attributes

Entities::Scenescene_ = nullptr
Entities::EntityowningEntity_ = nullptr
bool tickEnabled = false
bool hasBegunPlay_ = false

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.

Definition at line 22 of file LogicComponent.h.

Constructor & Destructor Documentation

◆ Logic()

Engine::Components::Logic::Logic ( Entities::Scene * owningScene)
explicit

Referenced by Engine::Components::Mesh::ownsCollisionChild().

Here is the caller graph for this function:

◆ ~Logic()

virtual Engine::Components::Logic::~Logic ( )
virtualdefault

Member Function Documentation

◆ beginPlay()

virtual void Engine::Components::Logic::beginPlay ( )
virtual

◆ canTick()

bool Engine::Components::Logic::canTick ( ) const
nodiscard

Checks if the component is currently set to tick.

Returns
true if ticking is enabled.

◆ endPlay()

◆ getComponentName()

virtual std::string Engine::Components::Logic::getComponentName ( ) const
nodiscardvirtual

Gets the component type name for debugging/UI.

Returns
The component display name.

Reimplemented in Engine::Components::DirectionalLight, and Engine::Components::VrGlider.

◆ getOwningEntity()

Entities::Entity * Engine::Components::Logic::getOwningEntity ( ) const
nodiscard

Gets the entity this component belongs to.

Returns
Pointer to the owning Entity.

◆ getScene()

Entities::Scene * Engine::Components::Logic::getScene ( ) const
nodiscardprotected

Gets the scene this component belongs to.

Returns
Pointer to the owning Scene.

◆ getSceneManager()

Core::SceneManager * Engine::Components::Logic::getSceneManager ( ) const
nodiscardprotected

Helper to get the SceneManager from the owning scene.

Returns
Pointer to the SceneManager.

◆ hasBegunPlay()

bool Engine::Components::Logic::hasBegunPlay ( ) const
nodiscard

◆ setCanTick()

void Engine::Components::Logic::setCanTick ( bool enable)

Enables or disables ticking for this component.

Parameters
enableTrue to enable ticking, false to disable.

◆ setOwningEntity()

void Engine::Components::Logic::setOwningEntity ( Entities::Entity * entity)
private

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

Parameters
entityPointer to the owning entity.

◆ tick()

virtual void Engine::Components::Logic::tick ( double deltaTime)
virtual

Called every frame if ticking is enabled.

Parameters
deltaTimeTime elapsed since last frame.

Reimplemented in Engine::Components::Camera, Engine::Components::VrCamera, Engine::Components::VrGlider, and Engine::Components::VrMovement.

Member Data Documentation

◆ ComponentName

const char* Engine::Components::Logic::ComponentName = "Logic"
staticconstexpr

Fallback component type name. Derived classes may override getComponentName() for custom labels.

Definition at line 32 of file LogicComponent.h.

◆ hasBegunPlay_

bool Engine::Components::Logic::hasBegunPlay_ = false
private

Definition at line 104 of file LogicComponent.h.

◆ IsUnique

bool Engine::Components::Logic::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 27 of file LogicComponent.h.

◆ owningEntity_

Entities::Entity* Engine::Components::Logic::owningEntity_ = nullptr
private

Definition at line 102 of file LogicComponent.h.

◆ scene_

Entities::Scene* Engine::Components::Logic::scene_ = nullptr
private

Definition at line 101 of file LogicComponent.h.

◆ tickEnabled

bool Engine::Components::Logic::tickEnabled = false
private

Definition at line 103 of file LogicComponent.h.


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