Plasma Engine  2.0
Loading...
Searching...
No Matches
SettingsComponentManager_inl.h
1
2template <typename ComponentType>
5{
6}
7
8template <typename ComponentType>
10{
11 for (auto& component : m_Components)
12 {
13 DeinitializeComponent(component.Borrow());
14 }
15}
16
17template <typename ComponentType>
19{
20 for (const auto& pComponent : m_Components)
21 {
22 // retrieve the first component that is active
23 if (pComponent->IsActive())
24 return pComponent.Borrow();
25 }
26
27 return nullptr;
30template <typename ComponentType>
31PL_ALWAYS_INLINE const ComponentType* plSettingsComponentManager<ComponentType>::GetSingletonComponent() const
32{
33 for (const auto& pComponent : m_Components)
34 {
35 // retrieve the first component that is active
36 if (pComponent->IsActive())
37 return pComponent.Borrow();
38 }
39
40 return nullptr;
41}
42
43// static
44template <typename ComponentType>
45PL_ALWAYS_INLINE plWorldModuleTypeId plSettingsComponentManager<ComponentType>::TypeId()
46{
47 return ComponentType::TypeId();
48}
49
50template <typename ComponentType>
52{
53 for (auto& component : m_Components)
54 {
55 if (!bOnlyActive || component->IsActive())
56 {
57 out_allComponents.PushBack(component->GetHandle());
58 }
59 }
60}
61
62template <typename ComponentType>
64{
65 for (auto& component : m_Components)
66 {
67 if (!bOnlyActive || component->IsActive())
68 {
69 out_allComponents.PushBack(component.Borrow());
70 }
71 }
72}
73
74template <typename ComponentType>
76{
77 if (!m_Components.IsEmpty())
78 {
79 plLog::Warning("A component of type '{0}' is already present in this world. Having more than one is not allowed.", plGetStaticRTTI<ComponentType>()->GetTypeName());
80 }
81
82 m_Components.PushBack(PL_NEW(GetAllocator(), ComponentType));
83 return m_Components.PeekBack().Borrow();
84}
85
86template <typename ComponentType>
88{
89 out_pMovedComponent = pComponent;
90
91 for (plUInt32 i = 0; i < m_Components.GetCount(); ++i)
92 {
93 if (m_Components[i].Borrow() == pComponent)
94 {
95 m_Components.RemoveAtAndCopy(i);
96 break;
97 }
98 }
99}
void PushBack(const T &value)
Pushes value at the end of the array.
Definition ArrayBase_inl.h:333
Base class of all component types.
Definition Component.h:25
Base class for all component managers. Do not derive directly from this class, but derive from plComp...
Definition ComponentManager.h:21
Definition DynamicArray.h:81
static void Warning(plLogInterface *pInterface, const plFormatString &string)
A potential problem or a performance warning. Might be possible to ignore it.
Definition Log.cpp:391
A component manager that does no update at all on components and expects only a single instance to be...
Definition SettingsComponentManager.h:14
virtual void CollectAllComponents(plDynamicArray< plComponentHandle > &out_allComponents, bool bOnlyActive) override
Adds all components that this manager handles to the given array (array is not cleared)....
Definition SettingsComponentManager_inl.h:51
ComponentType * GetSingletonComponent()
Returns the first component of this type that has been created.
Definition SettingsComponentManager_inl.h:18
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22