Nui Engine
A game engine framework
Loading...
Searching...
No Matches
Common.h
1#pragma once
2#include "Core/Common/CommonHeaders.h"
3#include <bitset>
4
5namespace Nui::Components
6{
10 enum ComponentFlags
11 {
12 CF_None,
13 CF_IsDirty,
14 CF_IsActive,
15
16 CF_COUNT
17 };
18
23 {
24 public:
29 {
30 SetDirty(); // All components are dirty by default and will need update on frame 1
31 }
32
37 [[nodiscard]] inline bool IsDirty() const { return m_flags.test(ComponentFlags::CF_IsDirty); }
38
43 [[nodiscard]] inline bool IsActive() const { return m_flags.test(ComponentFlags::CF_IsActive); }
44
49 [[noreturn]] inline void SetActive(bool isActive) { m_flags.set(ComponentFlags::CF_IsActive, isActive); }
50
51 protected:
56 [[noreturn]] inline void SetDirty(bool isDirty = true) { m_flags.set(ComponentFlags::CF_IsDirty, isDirty); }
57
58 protected:
62 std::bitset<ComponentFlags::CF_COUNT> m_flags;
63 };
64}
Base class for all components.
Definition Common.h:23
std::bitset< ComponentFlags::CF_COUNT > m_flags
Bitset of component flags.
Definition Common.h:62
bool IsDirty() const
Checks if the component is dirty.
Definition Common.h:37
void SetDirty(bool isDirty=true)
Sets the dirty flag.
Definition Common.h:56
void SetActive(bool isActive)
Sets the active flag.
Definition Common.h:49
ComponentBase()
Constructor (sets dirty flag to true)
Definition Common.h:28
bool IsActive() const
Checks if the component is active.
Definition Common.h:43