Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
LogicComponent.h
Go to the documentation of this file.
1#pragma once
2#include <string>
3
4namespace Engine::Core
5{
6 class SceneManager;
7} // namespace Engine::Core
8
9namespace Engine::Entities
10{
11 class Entity;
12 class Scene;
13} // namespace Engine::Entities
14
15namespace Engine::Components {
16 class Entity;
17
22 class Logic {
23 public:
27 static constexpr bool IsUnique = false;
28
32 static constexpr const char* ComponentName = "Logic";
33
34 explicit Logic(Entities::Scene* owningScene);
35 virtual ~Logic() = default;
36
41 [[nodiscard]] virtual std::string getComponentName() const;
42
46 virtual void beginPlay();
47
52 virtual void tick(double deltaTime);
53
57 virtual void endPlay();
58
59 [[nodiscard]] bool hasBegunPlay() const;
60
65 [[nodiscard]] bool canTick() const;
66
71 void setCanTick(bool enable);
72
77 [[nodiscard]] Entities::Entity * getOwningEntity() const;
78
79 protected:
84 [[nodiscard]] Entities::Scene* getScene() const;
85
90 [[nodiscard]] Core::SceneManager* getSceneManager() const;
91
92 private:
93 friend class Entities::Entity;
94
100
103 bool tickEnabled = false;
104 bool hasBegunPlay_ = false;
105 };
106}
107
108
109
110
111
112
113
114
virtual void beginPlay()
Called when the component is added to the scene or the game starts.
static constexpr bool IsUnique
Defines whether multiple instances of this component can exist on the same entity....
bool canTick() const
Checks if the component is currently set to tick.
virtual ~Logic()=default
Entities::Scene * getScene() const
Gets the scene this component belongs to.
Logic(Entities::Scene *owningScene)
virtual std::string getComponentName() const
Gets the component type name for debugging/UI.
static constexpr const char * ComponentName
Fallback component type name. Derived classes may override getComponentName() for custom labels.
void setCanTick(bool enable)
Enables or disables ticking for this component.
Entities::Entity * getOwningEntity() const
Gets the entity this component belongs to.
Entities::Entity * owningEntity_
void setOwningEntity(Entities::Entity *entity)
Sets the owning entity. Called by Entity::addComponent().
virtual void endPlay()
Called when the component is removed or the game ends.
virtual void tick(double deltaTime)
Called every frame if ticking is enabled.
Core::SceneManager * getSceneManager() const
Helper to get the SceneManager from the owning scene.
Manages game objects within a scene, handling registration, ID allocation, and GPU buffer synchroniza...
The entity class is the base class of everything which is attached to a scene. If it is part of a sce...
Definition Entity.h:16
A scene is the overarching structure which can spawn, contain and destroy actors or entities.
Definition Scene.h:56
Core audio subsystem owning the miniaudio engine and managing playback.
Definition AudioConfig.h:9