Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
Hierarchy.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
14#pragma once
15
16// =============================================================================
17// Includes
18// =============================================================================
19
20#include "../../core/Types.hpp"
22
23#include <vector>
24
25namespace esengine::ecs {
26
27// =============================================================================
28// Parent Component
29// =============================================================================
30
45ES_COMPONENT(stability=public)
46struct Parent {
48 ES_PROPERTY(entity_ref)
50
51 Parent() = default;
52 explicit Parent(Entity e) : entity(e) {}
53};
54
55// =============================================================================
56// Children Component
57// =============================================================================
58
65ES_COMPONENT(stability=public)
66struct Children {
68 ES_PROPERTY(entity_ref)
70
71 Children() = default;
72
77 [[nodiscard]] bool empty() const { return entities.empty(); }
78
83 [[nodiscard]] usize count() const { return entities.size(); }
84
86 bool operator==(const Children&) const = default;
87};
88
89} // namespace esengine::ecs
Reflection and metadata system for automatic binding generation.
#define ES_COMPONENT(...)
Mark a struct/class as a component that should be exposed to scripts.
#define ES_PROPERTY(...)
Mark a field as a property that should be exposed to scripts.
Core type definitions and utilities for ESEngine.
std::size_t usize
Size type for indexing and sizes.
Definition Types.hpp:64
constexpr Entity INVALID_ENTITY
Invalid entity sentinel value.
Definition Types.hpp:174
Entity identifier with packed index + generation.
Definition Types.hpp:135
bool operator==(const Children &) const =default
Compared member by member: what the change audit checks a write of this component against (Registry::...
bool empty() const
Check if entity has any children.
Definition Hierarchy.hpp:77
usize count() const
Get number of children.
Definition Hierarchy.hpp:83
std::vector< Entity > entities
List of child entity IDs.
Definition Hierarchy.hpp:69
Entity entity
Parent entity ID.
Definition Hierarchy.hpp:49