CoriEngine
Loading...
Searching...
No Matches
Hierarchy.hpp
Go to the documentation of this file.
1#pragma once
2#include "System.hpp"
3
4namespace Cori {
5 namespace World {
6 namespace Systems {
7 class Hierarchy final : public System {
8 public:
9
10 bool Create();
11
12 static constexpr SystemPriority Priority = 50;
13 protected:
14 friend Entity;
15
16 static std::expected<void, Core::CoriError<>> SetParent(Entity subject, Entity parent);
17
18 static std::expected<void, Core::CoriError<>> LinkToParent(Entity subject, Entity parent);
19
20 static void UnlinkFromParent(Entity subject);
21
22 static std::expected<std::vector<Entity>, Core::CoriError<>> GetSiblings(Entity subject);
23
24 static std::expected<std::vector<Entity>, Core::CoriError<>> GetChildren(Entity subject);
25
26 static std::expected<Entity, Core::CoriError<>> GetParent(Entity subject);
27
28 static std::expected<Entity, Core::CoriError<>> FindChildByName(Entity subject, const char* name);
29
30 static std::expected<Entity, Core::CoriError<>> FindChildByName(Entity subject, const std::string_view name);
31
32 static std::expected<Entity, Core::CoriError<>> FindChildByName(Entity subject, const std::string& name);
33
34 static void DestroyChildren(Entity subject);
35
36 static void PrintHierarchy(Entity subject);
37
38 static void DrawHierarchyRecursive(const Entity& entity, const std::string& prefix, const bool isLast);
39
40 private:
41 void OnHierarchyComponentDestroyed(entt::registry& registry, entt::entity entity);
42 };
43 }
44 }
45}
Custom error class mainly used in std::expected.
Definition Error.hpp:27
System(const System &)=delete
static std::expected< std::vector< Entity >, Core::CoriError<> > GetSiblings(Entity subject)
Definition Hierarchy.cpp:90
static void DrawHierarchyRecursive(const Entity &entity, const std::string &prefix, const bool isLast)
static std::expected< void, Core::CoriError<> > LinkToParent(Entity subject, Entity parent)
Definition Hierarchy.cpp:20
static std::expected< Entity, Core::CoriError<> > GetParent(Entity subject)
static std::expected< Entity, Core::CoriError<> > FindChildByName(Entity subject, const char *name)
static std::expected< void, Core::CoriError<> > SetParent(Entity subject, Entity parent)
Definition Hierarchy.cpp:11
static void UnlinkFromParent(Entity subject)
Definition Hierarchy.cpp:50
static constexpr SystemPriority Priority
Definition Hierarchy.hpp:12
static void DestroyChildren(Entity subject)
static std::expected< std::vector< Entity >, Core::CoriError<> > GetChildren(Entity subject)
static void PrintHierarchy(Entity subject)
Anything connected to WorldSystem (ECS) is in this namespace.
uint16_t SystemPriority
Definition Concept.hpp:5
Global engine namespace.