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 struct SpawnContext;
14} // namespace Engine::Entities
15
16namespace Engine::Components
17{
18 class Entity;
19
24 class Logic
25 {
26 public:
32 static constexpr bool IsUnique = false;
33
38 static constexpr const char * ComponentName = "Logic";
39
40 explicit Logic( Entities::Scene * owningScene );
41 explicit Logic( const Entities::SpawnContext & context );
42 virtual ~Logic() = default;
43
48 [[nodiscard]] virtual std::string getComponentName() const;
49
54 virtual bool drawImGui();
55
60 virtual bool drawImGuiName();
61
65 virtual void beginPlay();
66
71 virtual void tick( double deltaTime );
72
76 virtual void endPlay();
77
78 [[nodiscard]] bool hasBegunPlay() const;
79
84 [[nodiscard]] bool canTick() const;
85
90 void setCanTick( bool enable );
91
96 [[nodiscard]] Entities::Entity * getOwningEntity() const;
97
98 protected:
103 [[nodiscard]] Entities::Scene * getScene() const;
104
109 [[nodiscard]] Core::SceneManager * getSceneManager() const;
110
111 private:
112 friend class Entities::Entity;
113
119
122 bool tickEnabled = false;
123 bool hasBegunPlay_ = false;
124 };
125} // namespace Engine::Components
virtual bool drawImGui()
Draws component-specific ImGui inspector controls.
Logic(const Entities::SpawnContext &context)
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.
virtual bool drawImGuiName()
Used to alter the name of the entity in the outliner.
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:17
A scene is the overarching structure which can spawn, contain and destroy actors or entities.
Definition Scene.h:62
Manages IBL (Image-Based Lighting) resources for specular reflections.
Scene ownership data passed to actor and component constructors during spawning.