LeviLamina
Loading...
Searching...
No Matches
EntityContext.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/deps/ecs/EntityId.h"
5
6// auto generated inclusion list
7#include "mc/deps/ecs/EntityId.h"
8#include "mc/deps/game_refs/EnableGetWeakRef.h"
9#include "mc/deps/game_refs/WeakRef.h"
10
11// auto generated forward declare list
12// clang-format off
13class EntityRegistry;
15// clang-format on
16
17class EntityContext : public ::EnableGetWeakRef<::EntityContext> {
18public:
19 // EntityContext inner types declare
20 // clang-format off
21 struct Hash;
22 // clang-format on
23
24 // EntityContext inner types define
25 struct Hash {
26 public:
27 // member functions
28 // NOLINTBEGIN
29 MCNAPI uint64 operator()(::EntityContext const& entity) const;
30 // NOLINTEND
31 };
32
33public:
34 [[nodiscard]] inline entt::basic_registry<EntityId>& getRegistry() noexcept { return mEnTTRegistry; }
35
36 [[nodiscard]] inline entt::basic_registry<EntityId> const& getRegistry() const noexcept { return mEnTTRegistry; }
37
38 template <class T>
39 [[nodiscard]] inline optional_ref<T const> tryGetComponent() const {
40 return getRegistry().try_get<T>(mEntity);
41 }
42
43 template <class T>
44 [[nodiscard]] inline optional_ref<T> tryGetComponent() {
45 return const_cast<T*>(std::as_const(getRegistry()).try_get<T>(mEntity));
46 }
47
48 template <class T>
49 [[nodiscard]] inline bool hasComponent() const {
50 return getRegistry().all_of<T>(mEntity);
51 }
52
53 template <class T>
54 inline bool removeComponent() {
55 return getRegistry().remove<T>(mEntity);
56 }
57
58 template <class T, typename... Args>
59 [[nodiscard]] inline T& getOrAddComponent(Args&&... args) {
60 return getRegistry().get_or_emplace<T>(mEntity, std::forward<Args>(args)...);
61 }
62
63public:
64 // member variables
65 // NOLINTBEGIN
66 ::EntityRegistry& mRegistry;
67 ::entt::basic_registry<::EntityId>& mEnTTRegistry;
68 ::EntityId const mEntity;
69 // NOLINTEND
70
71public:
72 // member functions
73 // NOLINTBEGIN
74#ifdef LL_PLAT_C
75 MCAPI EntityContext(::EntityRegistry& registry, ::StrictEntityContext const& entity);
76#endif
77
78 MCAPI EntityContext(::EntityRegistry& registry, ::EntityId entity);
79
80 MCAPI ::EntityId _getEntityId() const;
81
82 MCFOLD ::EntityRegistry& _registry() const;
83
84 MCAPI ::WeakRef<::EntityContext> getWeakRef() const;
85
86 MCAPI bool isValid() const;
87
88 MCAPI bool operator==(::EntityContext const& other) const;
89 // NOLINTEND
90
91public:
92 // constructor thunks
93 // NOLINTBEGIN
94#ifdef LL_PLAT_C
95 MCAPI void* $ctor(::EntityRegistry& registry, ::StrictEntityContext const& entity);
96#endif
97
98 MCAPI void* $ctor(::EntityRegistry& registry, ::EntityId entity);
99 // NOLINTEND
100};
Definition EnableGetWeakRef.h:6
Definition EntityRegistry.h:11
Definition StrictEntityContext.h:14
Definition EntityContext.h:25
MCAPI uint64 operator()(::EntityContext const &entity) const