2#include "Engine/Entity/Entity.h"
3#include "Engine/World/SceneGraph.h"
36 template <
typename T,
typename... Args>
44 template <
typename T,
typename First,
typename... Rest>
46 : std::bool_constant<std::is_constructible_v<
51 std::shared_ptr<SceneNode>,
56 template <
typename T,
typename... Args>
58 std::is_base_of_v<Components::Logic, T> &&
60 std::is_constructible_v<T, Scene *, entt::entity &, std::shared_ptr<SceneNode>, Args...> ||
61 std::is_constructible_v<T,
Scene *, entt::entity &, Args..., std::shared_ptr<SceneNode>> ||
62 std::is_constructible_v<T, Scene *, std::shared_ptr<SceneNode>, Args...> ||
63 std::is_constructible_v<T,
Scene *, entt::entity &, Args...> ||
64 std::is_constructible_v<T,
Scene *, Args...> );
95 template <
typename T,
typename... Args>
103 else if constexpr ( std::is_constructible_v<
107 std::shared_ptr<SceneNode>,
114 else if constexpr ( std::is_constructible_v<
119 std::shared_ptr<SceneNode>> )
125 else if constexpr ( std::is_constructible_v<T, Scene *, std::shared_ptr<SceneNode>, Args...> )
131 else if constexpr ( std::is_constructible_v<T,
Scene *, entt::entity &, Args...> )
150 void tick(
double deltaTime )
override;
188 const std::shared_ptr<SceneNode>& parentNode,
314 template <
typename T,
typename First,
typename... Rest>
320 std::forward<First>( first ),
322 std::forward<Rest>( rest )...
A scene component has a transform.
Owns the Bullet dynamics world and dispatches engine collision events.
Owns the engine runtime and provides access to engine subsystems.
Actor(const SpawnContext &context)
Creates an actor from a scene spawn context.
glm::vec3 getUpVector() const
Gets the up world vector.
void setActorLocation(glm::vec3 newLocation) const
Set the new world location for this actor.
virtual void endPlay()
Gets executed when an actor is getting removed from the scene.
glm::vec3 getActorRotation() const
Gets the actors rotation in the world.
void setActorRotation(glm::vec3 newRotation) const
Sets the world rotation.
virtual void beginPlay()
Gets executed when the actor is spawned into the world.
glm::mat4 getWorldTransform() const
Gets the model matrix.
void attachTo(Actor &parent, AttachmentTransformRule rule=AttachmentTransformRule::KeepWorld)
Attaches this actor to another actor.
void destroyActor()
Queues this actor for destruction after the current tick finishes.
void destroyActorImmediate()
Destroys this actor immediately. Prefer destroyActor() during gameplay/tick code.
void rotateActor(glm::vec3 deltaRotation) const
Applies an incremental rotation to the actor using quaternion multiplication. Use this instead of get...
std::optional< std::shared_ptr< SceneNode > > sceneNode
Scene graph node owned by this actor.
void onEngineDestroyed() override
Handles actor cleanup when the entity is destroyed.
virtual bool drawImGui() const
Allows drawing custom Imgui panels for the editor.
static EngineKern * getEngine()
Gets the engine this actor belongs to.
void setActorScale(glm::vec3 newScale) const
sets the world scale for this actor
glm::vec3 getActorScale() const
Scales the actor to world scale.
Scene * getOwningScene() const
Get the pointer to the scene this entity is a part of.
glm::vec3 getRightVector() const
Gets the right.
glm::vec3 getActorLocation() const
Gets the actors location in the world.
void tick(double deltaTime) override
Executed every frame.
~Actor() override=default
Destroys the actor.
glm::vec3 getForwardVector() const
Gets the forward world vector.
std::shared_ptr< SceneNode > getSceneNode() const
Getter for the scene graph node for this object.
T * addComponentWithSceneEntityFirstNodeRest(First &&first, Rest &&... rest)
void onEngineEndPlay() override
Bridges the entity end-play lifecycle to Actor::endPlay().
std::weak_ptr< Components::Scene > rootComponent_
T * addComponent(Args &&... args)
Adds a component using this actor's scene, ECS entity and scene node where supported.
void onEngineBeginPlay() override
Bridges the entity begin-play lifecycle to Actor::beginPlay().
glm::quat getActorRotationQuat() const
Gets the actors world rotation.
void detach(AttachmentTransformRule rule=AttachmentTransformRule::KeepWorld)
Detaches this actor from its parent node.
virtual std::string getActorName() const
Returns the display name for this actor.
void attachTo(const std::shared_ptr< SceneNode > &parentNode, AttachmentTransformRule rule=AttachmentTransformRule::KeepWorld)
Attaches this actor to a scene node.
T * addComponent(Args &&... args)
Adds a component to the entity. Checks for uniqueness if the component defines 'static constexpr bool...
Entity()
Creates an entity in the constructed lifecycle state.
entt::entity data_
ECS entity handle associated with this entity.
Owns scene entities, actor lifetime, and the scene graph root.
AttachmentTransformRule
Controls which transform space is preserved when attaching or reparenting nodes.
@ KeepWorld
Preserve the node's world transform while recomputing its local transform.
Scene ownership data passed to actor and component constructors during spawning.
Detects component constructors that accept scene, entity, first user argument, node,...