Plasma Engine  2.0
Loading...
Searching...
No Matches
ActorManager.h
1#pragma once
2
3#include <Core/CoreDLL.h>
4
5#include <Foundation/Communication/Event.h>
6#include <Foundation/Configuration/Singleton.h>
7#include <Foundation/Reflection/Reflection.h>
8#include <Foundation/Types/UniquePtr.h>
9
10struct plActorManagerImpl;
11class plActor;
13
15{
16 enum class Type
17 {
18 AfterActorCreation,
20 BeforeActorDestruction,
21 };
22
23 Type m_Type;
24 plActor* m_pActor = nullptr;
25};
26
27class PL_CORE_DLL plActorManager final
28{
29 PL_DECLARE_SINGLETON(plActorManager);
30
31public:
34
36
38 void Update();
39
41 void Shutdown();
42
44 enum class DestructionMode
45 {
46 Immediate,
47 Queued
48 };
49
53 void AddActor(plUniquePtr<plActor>&& pActor);
54
56 void DestroyActor(plActor* pActor, DestructionMode mode = DestructionMode::Immediate);
57
62 void DestroyAllActors(const void* pCreatedBy, DestructionMode mode = DestructionMode::Immediate);
63
65 void GetAllActors(plHybridArray<plActor*, 8>& out_allActors);
66
69 void DestroyQueuedActors();
70
71 void AddApiService(plUniquePtr<plActorApiService>&& pService);
72 void DestroyApiService(plActorApiService* pService, DestructionMode mode = DestructionMode::Immediate);
73 void DestroyAllApiServices(DestructionMode mode = DestructionMode::Immediate);
74 void DestroyQueuedActorApiServices();
75
76 plActorApiService* GetApiService(const plRTTI* pType);
77
78 template <typename Type>
79 Type* GetApiService()
80 {
81 return static_cast<Type*>(GetApiService(plGetStaticRTTI<Type>()));
82 }
83
84private:
85 void ActivateQueuedApiServices();
86 void UpdateAllApiServices();
87 void UpdateAllActors();
88
89 // used during actor updates to force actor destruction to be queued until the actor updating is finished
90 bool m_bForceQueueActorDestruction = false;
92};
Definition ActorApiService.h:8
Definition Actor.h:9
Definition ActorManager.h:28
DestructionMode
Specifies whether something should be destroyed right now or delayed during the next Update()
Definition ActorManager.h:45
Definition Event.h:177
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
This class holds information about reflected types. Each instance represents one type that is known t...
Definition RTTI.h:30
A Unique ptr manages an object and destroys that object when it goes out of scope....
Definition UniquePtr.h:10
Definition ActorManager.h:15
Type
Definition ActorManager.h:17
@ AfterActorActivation
Sent after plActor::Activate() has been called.