RavEngine
Loading...
Searching...
No Matches
CheckedComponentHandle.hpp
1#pragma once
2#include "Entity.hpp"
3
4namespace RavEngine {
6 protected:
7 Entity owner;
8 public:
9 CheckedComponentHandleBase(decltype(owner) owner) : owner(owner) {}
10
11 inline operator bool() const {
12 return IsValid();
13 }
14
15 inline void reset() {
16 owner = Entity({ INVALID_ENTITY }, nullptr);
17 }
18
19 inline bool IsValid() const {
20 return owner.IsValid();
21 }
22 };
23
24 template<typename T>
26 CheckedComponentHandle(decltype(owner) owner) : CheckedComponentHandleBase(owner) {}
27
28 template<typename ValidatorType>
29 T* get(const ValidatorType& v) {
30 static_assert(ValidatorType::template IsValid<T>(), "Validator does not have the necessary types");
31 return &owner.GetComponent<T>();
32 }
33
34 bool operator==(const CheckedComponentHandle<T>& other) const {
35 return owner.id == other.owner.id;
36 }
37 };
38
39}
Definition CheckedComponentHandle.hpp:5
Definition concurrentqueue.h:747
Definition Animation.hpp:6
Definition CheckedComponentHandle.hpp:25
Definition Entity.hpp:11