|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
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>
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. | |
| Entity * | getOwningEntity () 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 | |
| Scene * | getScene () const |
| Gets the scene this component belongs to. | |
| SceneManager * | getSceneManager () 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 | |
| Scene * | scene = nullptr |
| Entity * | owningEntity_ = nullptr |
| bool | tickEnabled = false |
Friends | |
| class | Entity |
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 14 of file LogicComponent.h.
|
explicit |
Definition at line 7 of file LogicComponent.cpp.
References scene.
Referenced by EngineCore::CameraComponent::CameraComponent(), EngineCore::CollisionComponent::CollisionComponent(), EngineCore::MeshComponent::MeshComponent(), EngineCore::PhysicsBodyComponent::PhysicsBodyComponent(), EngineCore::SceneComponent::SceneComponent(), EngineCore::SceneComponent::SceneComponent(), EngineCore::SceneComponent::SceneComponent(), EngineCore::SceneComponent::SceneComponent(), EngineCore::SceneComponent::SceneComponent(), EngineCore::SceneComponent::SceneComponent(), EngineCore::TestComponent::TestComponent(), EngineCore::UniqueTestComponent::UniqueTestComponent(), and EngineCore::VrMovementComponent::VrMovementComponent().
|
virtualdefault |
|
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().
|
nodiscard |
Checks if the component is currently set to tick.
Definition at line 22 of file LogicComponent.cpp.
References tickEnabled.
|
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().
|
nodiscard |
Gets the entity this component belongs to.
Definition at line 41 of file LogicComponent.cpp.
References Entity, and owningEntity_.
Referenced by EngineCore::PhysicsBodyComponent::beginPlay(), and EngineCore::CollisionComponent::registerWithBody().
|
nodiscardprotected |
Gets the scene this component belongs to.
Definition at line 30 of file LogicComponent.cpp.
References scene.
|
nodiscardprotected |
Helper to get the SceneManager from the owning scene.
Definition at line 34 of file LogicComponent.cpp.
References scene.
| void EngineCore::LogicComponent::setCanTick | ( | bool | enable | ) |
Enables or disables ticking for this component.
| enable | True 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().
|
private |
Sets the owning entity. Called by Entity::addComponent().
| entity | Pointer to the owning entity. |
Definition at line 45 of file LogicComponent.cpp.
References Entity, and owningEntity_.
|
virtual |
Called every frame if ticking is enabled.
| deltaTime | Time elapsed since last frame. |
Reimplemented in EngineCore::CameraComponent, EngineCore::TestComponent, and EngineCore::VrMovementComponent.
Definition at line 14 of file LogicComponent.cpp.
|
friend |
Definition at line 72 of file LogicComponent.h.
References Entity.
Referenced by EngineCore::PhysicsBodyComponent::beginPlay(), Entity, getOwningEntity(), EngineCore::CollisionComponent::registerWithBody(), setOwningEntity(), and ~LogicComponent().
|
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.
|
private |
Definition at line 81 of file LogicComponent.h.
Referenced by getOwningEntity(), and setOwningEntity().
|
private |
Definition at line 80 of file LogicComponent.h.
Referenced by EngineCore::BoxCollisionComponent::BoxCollisionComponent(), EngineCore::CapsuleCollisionComponent::CapsuleCollisionComponent(), EngineCore::CollisionComponent::CollisionComponent(), getScene(), getSceneManager(), LogicComponent(), EngineCore::PhysicsBodyComponent::PhysicsBodyComponent(), EngineCore::SceneComponent::SceneComponent(), EngineCore::SceneComponent::SceneComponent(), EngineCore::SceneComponent::SceneComponent(), EngineCore::SceneComponent::SceneComponent(), EngineCore::SceneComponent::SceneComponent(), EngineCore::SceneComponent::SceneComponent(), EngineCore::SphereCollisionComponent::SphereCollisionComponent(), EngineCore::TestComponent::TestComponent(), and EngineCore::UniqueTestComponent::UniqueTestComponent().
|
private |
Definition at line 82 of file LogicComponent.h.
Referenced by canTick(), and setCanTick().