17 EntityHandle entityId = entt::null;
21 Entity(
const Entity& other) =
default;
23 : entityId(entityId), scene(scene) {}
33 virtual bool IsChildOf(
const Entity& other)
const;
34 virtual Entity GetParent()
const;
35 virtual bool SetParent(Entity);
38 virtual Math::Matrix4 GetLocalMatrix()
const;
39 virtual Math::Matrix4 GetWorldMatrix()
const;
53 virtual void Destroy();
54 virtual entt::registry& GetSceneEntityRegistry()
const;
56 template<
typename ComponentType,
typename... Args>
57 ComponentType& AddComponent(Args&&... args) {
58 return GetSceneEntityRegistry().emplace<ComponentType>(entityId, std::forward<Args>(args)...);
61 template<
typename ComponentType>
62 bool HasComponent()
const {
63 return GetSceneEntityRegistry().all_of<ComponentType>(entityId);
66 template<
typename ComponentType>
67 ComponentType& GetComponent()
const {
68 return GetSceneEntityRegistry().get<ComponentType>(entityId);
71 template<
typename ComponentType>
72 bool TryGetComponent(ComponentType*& outComponent)
const {
73 ComponentType* testComponent = GetSceneEntityRegistry().try_get<ComponentType>(entityId);
74 if (testComponent !=
nullptr) {
75 outComponent = testComponent;
82 template<
typename ComponentType>
83 void RemoveComponent() {
84 GetSceneEntityRegistry().remove<ComponentType>(entityId);
87 virtual EntityHandle GetHandle()
const {
95 explicit operator bool()
const {
96 return entityId != entt::null && scene !=
nullptr && GetSceneEntityRegistry().valid(entityId);
99 bool operator==(
const Entity& other)
const {
100 return (entityId == other.entityId) && (scene == other.scene);
103 bool operator!=(
const Entity& other)
const {
104 return !(*
this == other);