Plasma Engine  2.0
Loading...
Searching...
No Matches
World_inl.h
1
2PL_ALWAYS_INLINE plStringView plWorld::GetName() const
3{
4 return m_Data.m_sName;
5}
6
7PL_ALWAYS_INLINE plUInt32 plWorld::GetIndex() const
8{
9 return m_uiIndex;
10}
11
13{
14 plGameObject* pNewObject;
15 return CreateObject(desc, pNewObject);
16}
17
19{
20 return m_Data.m_ObjectDeletionEvent;
21}
22
23PL_FORCE_INLINE bool plWorld::IsValidObject(const plGameObjectHandle& hObject) const
24{
25 CheckForReadAccess();
26 PL_ASSERT_DEV(hObject.IsInvalidated() || hObject.m_InternalId.m_WorldIndex == m_uiIndex,
27 "Object does not belong to this world. Expected world id {0} got id {1}", m_uiIndex, hObject.m_InternalId.m_WorldIndex);
28
29 return m_Data.m_Objects.Contains(hObject);
30}
31
32PL_FORCE_INLINE bool plWorld::TryGetObject(const plGameObjectHandle& hObject, plGameObject*& out_pObject)
33{
34 CheckForReadAccess();
35 PL_ASSERT_DEV(hObject.IsInvalidated() || hObject.m_InternalId.m_WorldIndex == m_uiIndex,
36 "Object does not belong to this world. Expected world id {0} got id {1}", m_uiIndex, hObject.m_InternalId.m_WorldIndex);
37
38 return m_Data.m_Objects.TryGetValue(hObject, out_pObject);
39}
40
41PL_FORCE_INLINE bool plWorld::TryGetObject(const plGameObjectHandle& hObject, const plGameObject*& out_pObject) const
42{
43 CheckForReadAccess();
44 PL_ASSERT_DEV(hObject.IsInvalidated() || hObject.m_InternalId.m_WorldIndex == m_uiIndex,
45 "Object does not belong to this world. Expected world id {0} got id {1}", m_uiIndex, hObject.m_InternalId.m_WorldIndex);
46
47 plGameObject* pObject = nullptr;
48 bool bResult = m_Data.m_Objects.TryGetValue(hObject, pObject);
49 out_pObject = pObject;
50 return bResult;
51}
52
53PL_FORCE_INLINE bool plWorld::TryGetObjectWithGlobalKey(const plTempHashedString& sGlobalKey, plGameObject*& out_pObject)
54{
55 CheckForReadAccess();
57 if (m_Data.m_GlobalKeyToIdTable.TryGetValue(sGlobalKey.GetHash(), id))
58 {
59 out_pObject = m_Data.m_Objects[id];
60 return true;
61 }
62
63 return false;
64}
65
66PL_FORCE_INLINE bool plWorld::TryGetObjectWithGlobalKey(const plTempHashedString& sGlobalKey, const plGameObject*& out_pObject) const
67{
68 CheckForReadAccess();
70 if (m_Data.m_GlobalKeyToIdTable.TryGetValue(sGlobalKey.GetHash(), id))
71 {
72 out_pObject = m_Data.m_Objects[id];
73 return true;
74 }
75
76 return false;
77}
78
79PL_FORCE_INLINE plUInt32 plWorld::GetObjectCount() const
80{
81 CheckForReadAccess();
82 // Subtract one to exclude dummy object with instance index 0
83 return static_cast<plUInt32>(m_Data.m_Objects.GetCount() - 1);
84}
85
87{
88 CheckForWriteAccess();
89 return plInternal::WorldData::ObjectIterator(m_Data.m_ObjectStorage.GetIterator(0));
90}
91
93{
94 CheckForReadAccess();
95 return plInternal::WorldData::ConstObjectIterator(m_Data.m_ObjectStorage.GetIterator(0));
96}
97
98PL_FORCE_INLINE void plWorld::Traverse(VisitorFunc visitorFunc, TraversalMethod method /*= DepthFirst*/)
99{
100 CheckForWriteAccess();
101
102 if (method == DepthFirst)
103 {
104 m_Data.TraverseDepthFirst(visitorFunc);
105 }
106 else // method == BreadthFirst
107 {
108 m_Data.TraverseBreadthFirst(visitorFunc);
109 }
110}
111
112template <typename ModuleType>
113PL_ALWAYS_INLINE ModuleType* plWorld::GetOrCreateModule()
114{
115 static_assert(PL_IS_DERIVED_FROM_STATIC(plWorldModule, ModuleType), "Not a valid module type");
116
117 return plStaticCast<ModuleType*>(GetOrCreateModule(plGetStaticRTTI<ModuleType>()));
118}
119
120template <typename ModuleType>
121PL_ALWAYS_INLINE void plWorld::DeleteModule()
122{
123 static_assert(PL_IS_DERIVED_FROM_STATIC(plWorldModule, ModuleType), "Not a valid module type");
124
125 DeleteModule(plGetStaticRTTI<ModuleType>());
126}
127
128template <typename ModuleType>
129PL_ALWAYS_INLINE ModuleType* plWorld::GetModule()
130{
131 static_assert(PL_IS_DERIVED_FROM_STATIC(plWorldModule, ModuleType), "Not a valid module type");
132
133 return plStaticCast<ModuleType*>(GetModule(plGetStaticRTTI<ModuleType>()));
134}
135
136template <typename ModuleType>
137PL_ALWAYS_INLINE const ModuleType* plWorld::GetModule() const
138{
139 static_assert(PL_IS_DERIVED_FROM_STATIC(plWorldModule, ModuleType), "Not a valid module type");
140
141 return plStaticCast<const ModuleType*>(GetModule(plGetStaticRTTI<ModuleType>()));
142}
143
144template <typename ModuleType>
145PL_ALWAYS_INLINE const ModuleType* plWorld::GetModuleReadOnly() const
146{
147 return GetModule<ModuleType>();
148}
149
150template <typename ManagerType>
152{
153 static_assert(PL_IS_DERIVED_FROM_STATIC(plComponentManagerBase, ManagerType), "Not a valid component manager type");
154
155 CheckForWriteAccess();
156
157 const plWorldModuleTypeId uiTypeId = ManagerType::TypeId();
158 m_Data.m_Modules.EnsureCount(uiTypeId + 1);
159
160 ManagerType* pModule = static_cast<ManagerType*>(m_Data.m_Modules[uiTypeId]);
161 if (pModule == nullptr)
162 {
163 pModule = PL_NEW(&m_Data.m_Allocator, ManagerType, this);
164 static_cast<plWorldModule*>(pModule)->Initialize();
165
166 m_Data.m_Modules[uiTypeId] = pModule;
167 m_Data.m_ModulesToStartSimulation.PushBack(pModule);
168 }
169
170 return pModule;
171}
172
174{
175 PL_ASSERT_DEV(pComponentRtti->IsDerivedFrom<plComponent>(), "Invalid component type '%s'", pComponentRtti->GetTypeName());
176
177 return plStaticCast<plComponentManagerBase*>(GetOrCreateModule(pComponentRtti));
178}
179
180template <typename ManagerType>
182{
183 static_assert(PL_IS_DERIVED_FROM_STATIC(plComponentManagerBase, ManagerType), "Not a valid component manager type");
184
185 CheckForWriteAccess();
186
187 const plWorldModuleTypeId uiTypeId = ManagerType::TypeId();
188 if (uiTypeId < m_Data.m_Modules.GetCount())
189 {
190 if (ManagerType* pModule = static_cast<ManagerType*>(m_Data.m_Modules[uiTypeId]))
191 {
192 m_Data.m_Modules[uiTypeId] = nullptr;
193
194 static_cast<plWorldModule*>(pModule)->Deinitialize();
195 DeregisterUpdateFunctions(pModule);
196 PL_DELETE(&m_Data.m_Allocator, pModule);
197 }
198 }
199}
200
201template <typename ManagerType>
202PL_FORCE_INLINE ManagerType* plWorld::GetComponentManager()
203{
204 static_assert(PL_IS_DERIVED_FROM_STATIC(plComponentManagerBase, ManagerType), "Not a valid component manager type");
205
206 CheckForWriteAccess();
207
208 const plWorldModuleTypeId uiTypeId = ManagerType::TypeId();
209 if (uiTypeId < m_Data.m_Modules.GetCount())
210 {
211 return plStaticCast<ManagerType*>(m_Data.m_Modules[uiTypeId]);
212 }
213
214 return nullptr;
215}
216
217template <typename ManagerType>
218PL_FORCE_INLINE const ManagerType* plWorld::GetComponentManager() const
219{
220 static_assert(PL_IS_DERIVED_FROM_STATIC(plComponentManagerBase, ManagerType), "Not a valid component manager type");
221
222 CheckForReadAccess();
223
224 const plWorldModuleTypeId uiTypeId = ManagerType::TypeId();
225 if (uiTypeId < m_Data.m_Modules.GetCount())
226 {
227 return plStaticCast<const ManagerType*>(m_Data.m_Modules[uiTypeId]);
228 }
229
230 return nullptr;
231}
232
234{
235 PL_ASSERT_DEV(pComponentRtti->IsDerivedFrom<plComponent>(), "Invalid component type '{0}'", pComponentRtti->GetTypeName());
236
237 return plStaticCast<plComponentManagerBase*>(GetModule(pComponentRtti));
238}
239
240PL_ALWAYS_INLINE const plComponentManagerBase* plWorld::GetManagerForComponentType(const plRTTI* pComponentRtti) const
241{
242 PL_ASSERT_DEV(pComponentRtti->IsDerivedFrom<plComponent>(), "Invalid component type '{0}'", pComponentRtti->GetTypeName());
243
244 return plStaticCast<const plComponentManagerBase*>(GetModule(pComponentRtti));
245}
246
247inline bool plWorld::IsValidComponent(const plComponentHandle& hComponent) const
248{
249 CheckForReadAccess();
250 const plWorldModuleTypeId uiTypeId = hComponent.m_InternalId.m_TypeId;
251
252 if (uiTypeId < m_Data.m_Modules.GetCount())
253 {
254 if (const plWorldModule* pModule = m_Data.m_Modules[uiTypeId])
255 {
256 return static_cast<const plComponentManagerBase*>(pModule)->IsValidComponent(hComponent);
257 }
258 }
259
260 return false;
261}
262
263template <typename ComponentType>
264inline bool plWorld::TryGetComponent(const plComponentHandle& hComponent, ComponentType*& out_pComponent)
265{
266 CheckForWriteAccess();
267 static_assert(PL_IS_DERIVED_FROM_STATIC(plComponent, ComponentType), "Not a valid component type");
268
269 const plWorldModuleTypeId uiTypeId = hComponent.m_InternalId.m_TypeId;
270
271 if (uiTypeId < m_Data.m_Modules.GetCount())
272 {
273 if (plWorldModule* pModule = m_Data.m_Modules[uiTypeId])
274 {
275 plComponent* pComponent = nullptr;
276 bool bResult = static_cast<plComponentManagerBase*>(pModule)->TryGetComponent(hComponent, pComponent);
277 out_pComponent = plDynamicCast<ComponentType*>(pComponent);
278 return bResult && out_pComponent != nullptr;
279 }
280 }
281
282 return false;
283}
284
285template <typename ComponentType>
286inline bool plWorld::TryGetComponent(const plComponentHandle& hComponent, const ComponentType*& out_pComponent) const
287{
288 CheckForReadAccess();
289 static_assert(PL_IS_DERIVED_FROM_STATIC(plComponent, ComponentType), "Not a valid component type");
290
291 const plWorldModuleTypeId uiTypeId = hComponent.m_InternalId.m_TypeId;
292
293 if (uiTypeId < m_Data.m_Modules.GetCount())
294 {
295 if (const plWorldModule* pModule = m_Data.m_Modules[uiTypeId])
296 {
297 const plComponent* pComponent = nullptr;
298 bool bResult = static_cast<const plComponentManagerBase*>(pModule)->TryGetComponent(hComponent, pComponent);
299 out_pComponent = plDynamicCast<const ComponentType*>(pComponent);
300 return bResult && out_pComponent != nullptr;
301 }
302 }
303
304 return false;
305}
306
307PL_FORCE_INLINE void plWorld::SendMessage(const plGameObjectHandle& hReceiverObject, plMessage& ref_msg)
308{
309 CheckForWriteAccess();
310
311 plGameObject* pReceiverObject = nullptr;
312 if (TryGetObject(hReceiverObject, pReceiverObject))
313 {
314 pReceiverObject->SendMessage(ref_msg);
315 }
316 else
317 {
318#if PL_ENABLED(PL_COMPILE_FOR_DEBUG)
319 if (ref_msg.GetDebugMessageRouting())
320 {
321 plLog::Warning("plWorld::SendMessage: The receiver plGameObject for message of type '{0}' does not exist.", ref_msg.GetId());
322 }
323#endif
324 }
325}
326
327PL_FORCE_INLINE void plWorld::SendMessageRecursive(const plGameObjectHandle& hReceiverObject, plMessage& ref_msg)
328{
329 CheckForWriteAccess();
330
331 plGameObject* pReceiverObject = nullptr;
332 if (TryGetObject(hReceiverObject, pReceiverObject))
333 {
334 pReceiverObject->SendMessageRecursive(ref_msg);
335 }
336 else
337 {
338#if PL_ENABLED(PL_COMPILE_FOR_DEBUG)
339 if (ref_msg.GetDebugMessageRouting())
340 {
341 plLog::Warning("plWorld::SendMessageRecursive: The receiver plGameObject for message of type '{0}' does not exist.", ref_msg.GetId());
342 }
343#endif
344 }
345}
346
347PL_ALWAYS_INLINE void plWorld::PostMessage(
348 const plGameObjectHandle& hReceiverObject, const plMessage& msg, plTime delay, plObjectMsgQueueType::Enum queueType) const
349{
350 // This method is allowed to be called from multiple threads.
351 PostMessage(hReceiverObject, msg, queueType, delay, false);
352}
353
354PL_ALWAYS_INLINE void plWorld::PostMessageRecursive(
355 const plGameObjectHandle& hReceiverObject, const plMessage& msg, plTime delay, plObjectMsgQueueType::Enum queueType) const
356{
357 // This method is allowed to be called from multiple threads.
358 PostMessage(hReceiverObject, msg, queueType, delay, true);
359}
360
361PL_FORCE_INLINE void plWorld::SendMessage(const plComponentHandle& hReceiverComponent, plMessage& ref_msg)
362{
363 CheckForWriteAccess();
364
365 plComponent* pReceiverComponent = nullptr;
366 if (TryGetComponent(hReceiverComponent, pReceiverComponent))
367 {
368 pReceiverComponent->SendMessage(ref_msg);
369 }
370 else
371 {
372#if PL_ENABLED(PL_COMPILE_FOR_DEBUG)
373 if (ref_msg.GetDebugMessageRouting())
374 {
375 plLog::Warning("plWorld::SendMessage: The receiver plComponent for message of type '{0}' does not exist.", ref_msg.GetId());
376 }
377#endif
378 }
379}
380
381PL_ALWAYS_INLINE void plWorld::SetWorldSimulationEnabled(bool bEnable)
382{
383 m_Data.m_bSimulateWorld = bEnable;
384}
385
386PL_ALWAYS_INLINE bool plWorld::GetWorldSimulationEnabled() const
387{
388 return m_Data.m_bSimulateWorld;
389}
390
392{
393 return m_pUpdateTask;
394}
395
396PL_ALWAYS_INLINE plUInt32 plWorld::GetUpdateCounter() const
397{
398 return m_Data.m_uiUpdateCounter;
399}
400
402{
403 CheckForWriteAccess();
404
405 return m_Data.m_pSpatialSystem.Borrow();
406}
407
408PL_FORCE_INLINE const plSpatialSystem* plWorld::GetSpatialSystem() const
409{
410 CheckForReadAccess();
411
412 return m_Data.m_pSpatialSystem.Borrow();
413}
414
415PL_ALWAYS_INLINE void plWorld::GetCoordinateSystem(const plVec3& vGlobalPosition, plCoordinateSystem& out_coordinateSystem) const
416{
417 m_Data.m_pCoordinateSystemProvider->GetCoordinateSystem(vGlobalPosition, out_coordinateSystem);
418}
419
421{
422 return *(m_Data.m_pCoordinateSystemProvider.Borrow());
423}
424
426{
427 return *(m_Data.m_pCoordinateSystemProvider.Borrow());
428}
429
430PL_ALWAYS_INLINE plClock& plWorld::GetClock()
431{
432 return m_Data.m_Clock;
433}
434
435PL_ALWAYS_INLINE const plClock& plWorld::GetClock() const
436{
437 return m_Data.m_Clock;
438}
439
441{
442 return m_Data.m_Random;
443}
444
446{
447 return &m_Data.m_Allocator;
448}
449
451{
452 return &m_Data.m_BlockAllocator;
453}
454
456{
457 return &m_Data.m_StackAllocator;
458}
459
461{
462 return m_Data.m_ReadMarker;
463}
464
466{
467 return m_Data.m_WriteMarker;
468}
469
470PL_FORCE_INLINE void plWorld::SetUserData(void* pUserData)
471{
472 CheckForWriteAccess();
473
474 m_Data.m_pUserData = pUserData;
475}
476
477PL_FORCE_INLINE void* plWorld::GetUserData() const
478{
479 CheckForReadAccess();
480
481 return m_Data.m_pUserData;
482}
483
484constexpr plUInt64 plWorld::GetMaxNumGameObjects()
485{
486 return plGameObjectId::MAX_INSTANCES - 2;
487}
488
489constexpr plUInt64 plWorld::GetMaxNumHierarchyLevels()
490{
491 return 1 << (sizeof(plGameObject::m_uiHierarchyLevel) * 8);
492}
493
494constexpr plUInt64 plWorld::GetMaxNumComponentsPerType()
495{
496 return plComponentId::MAX_INSTANCES - 1;
497}
498
499constexpr plUInt64 plWorld::GetMaxNumWorldModules()
500{
501 return PL_MAX_WORLD_MODULE_TYPES;
502}
503
504constexpr plUInt64 plWorld::GetMaxNumComponentTypes()
505{
506 return PL_MAX_COMPONENT_TYPES;
507}
508
509constexpr plUInt64 plWorld::GetMaxNumWorlds()
510{
511 return PL_MAX_WORLDS;
512}
513
514// static
515PL_ALWAYS_INLINE plUInt32 plWorld::GetWorldCount()
516{
517 return s_Worlds.GetCount();
518}
519
520// static
521PL_ALWAYS_INLINE plWorld* plWorld::GetWorld(plUInt32 uiIndex)
522{
523 return s_Worlds[uiIndex];
524}
525
526// static
527PL_ALWAYS_INLINE plWorld* plWorld::GetWorld(const plGameObjectHandle& hObject)
528{
529 return s_Worlds[hObject.GetInternalID().m_WorldIndex];
530}
531
532// static
533PL_ALWAYS_INLINE plWorld* plWorld::GetWorld(const plComponentHandle& hComponent)
534{
535 return s_Worlds[hComponent.GetInternalID().m_WorldIndex];
536}
537
538PL_ALWAYS_INLINE void plWorld::CheckForReadAccess() const
539{
540 PL_ASSERT_DEV(m_Data.m_iReadCounter > 0, "Trying to read from World '{0}', but it is not marked for reading.", GetName());
541}
542
543PL_ALWAYS_INLINE void plWorld::CheckForWriteAccess() const
544{
545 PL_ASSERT_DEV(
546 m_Data.m_WriteThreadID == plThreadUtils::GetCurrentThreadID(), "Trying to write to World '{0}', but it is not marked for writing.", GetName());
547}
548
549PL_ALWAYS_INLINE plGameObject* plWorld::GetObjectUnchecked(plUInt32 uiIndex) const
550{
551 return m_Data.m_Objects.GetValueUnchecked(uiIndex);
552}
553
554PL_ALWAYS_INLINE bool plWorld::ReportErrorWhenStaticObjectMoves() const
555{
556 return m_Data.m_bReportErrorWhenStaticObjectMoves;
557}
558
559PL_ALWAYS_INLINE float plWorld::GetInvDeltaSeconds() const
560{
561 const float fDelta = (float)m_Data.m_Clock.GetTimeDiff().GetSeconds();
562 if (fDelta > 0.0f)
563 {
564 return 1.0f / fDelta;
565 }
566
567 // when the clock is paused just use zero
568 return 0.0f;
569}
Base class for all memory allocators.
Definition Allocator.h:23
void PushBack(const T &value)
Pushes value at the end of the array.
Definition ArrayBase_inl.h:333
void EnsureCount(plUInt32 uiCount)
Ensures the container has at least uiCount elements. Ie. calls SetCount() if the container has fewer ...
Definition ArrayBase_inl.h:144
plUInt32 GetCount() const
Returns the number of active elements in the array.
Definition ArrayBase_inl.h:172
A clock that can be speed up, slowed down, paused, etc. Useful for updating game logic,...
Definition Clock.h:15
plTime GetTimeDiff() const
Returns the time difference between the last two calls to Update().
Definition Clock_inl.h:52
Base class of all component types.
Definition Component.h:25
PL_ALWAYS_INLINE bool SendMessage(plMessage &ref_msg)
Sends a message to this component.
Definition Component.h:117
Base class for all component managers. Do not derive directly from this class, but derive from plComp...
Definition ComponentManager.h:21
Definition CoordinateSystem.h:18
A double buffered stack allocator.
Definition FrameAllocator.h:7
Definition Event.h:177
This class represents an object inside the world.
Definition GameObject.h:32
bool SendMessage(plMessage &ref_msg)
Sends a message to all components of this object.
Definition GameObject_inl.h:545
bool SendMessageRecursive(plMessage &ref_msg)
Sends a message to all components of this object and then recursively to all children.
Definition GameObject_inl.h:555
bool TryGetValue(const CompatibleKeyType &key, ValueType &out_value) const
Returns whether an entry with the given key was found and if found writes out the corresponding value...
IndexType GetCount() const
Returns the number of active entries in the table.
Definition IdTable_inl.h:168
bool TryGetValue(const IdType id, ValueType &out_value) const
Returns if an entry with the given id was found and if found writes out the corresponding value to ou...
Definition IdTable_inl.h:267
const ValueType & GetValueUnchecked(const IndexType index) const
Returns the value at the given index. Does bounds checks in debug builds but does not check for stale...
Definition IdTable_inl.h:314
bool Contains(const IdType id) const
Returns if the table contains an entry corresponding to the given id.
Definition IdTable_inl.h:328
Definition WorldData.h:75
Definition WorldData.h:273
Definition WorldData.h:286
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
Base class for all message types. Each message type has it's own id which is used to dispatch message...
Definition Message.h:22
PL_ALWAYS_INLINE plMessageId GetId() const
Returns the id for this message type.
Definition Message.h:48
This class holds information about reflected types. Each instance represents one type that is known t...
Definition RTTI.h:30
PL_ALWAYS_INLINE plStringView GetTypeName() const
Returns the name of this type.
Definition RTTI.h:48
PL_ALWAYS_INLINE bool IsDerivedFrom(const plRTTI *pBaseType) const
Returns true if this type is derived from the given type (or of the same type).
Definition RTTI.h:60
A random number generator. Currently uses the WELL512 algorithm.
Definition Random.h:9
A Shared ptr manages a shared object and destroys that object when no one references it anymore....
Definition SharedPtr.h:10
T * Borrow() const
Borrows the managed object. The shared ptr stays unmodified.
Definition SharedPtr_inl.h:168
Definition SpatialSystem.h:10
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
A class to use together with plHashedString for quick comparisons with temporary strings that need no...
Definition HashedString.h:151
plUInt64 GetHash() const
Returns the hash of the stored string.
Definition HashedString_inl.h:204
static plThreadID GetCurrentThreadID()
Returns an identifier for the currently running thread.
Definition ThreadUtils_Posix.h:42
T * Borrow() const
Borrows the managed object. The unique ptr stays unmodified.
Definition UniquePtr_inl.h:102
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
plGameObjectHandle CreateObject(const plGameObjectDesc &desc)
Create a new game object from the given description and returns a handle to it.
Definition World_inl.h:12
plUInt32 GetIndex() const
Returns the index of this world.
Definition World_inl.h:7
plClock & GetClock()
Returns the clock that is used for all updates in this game world.
Definition World_inl.h:430
void DeleteComponentManager()
Deletes the component manager of the given type and all its components.
Definition World_inl.h:181
ModuleType * GetModule()
Returns the instance to the given module type or derived types.
const plEvent< const plGameObject * > & GetObjectDeletionEvent() const
Returns the event that is triggered before an object is deleted. This can be used for external system...
Definition World_inl.h:18
const ModuleType * GetModuleReadOnly() const
Returns the instance to the given module type or derived types.
void Traverse(VisitorFunc visitorFunc, TraversalMethod method=DepthFirst)
Traverses the game object tree starting at the top level objects and then recursively all children....
Definition World_inl.h:98
plComponentManagerBase * GetOrCreateManagerForComponentType(const plRTTI *pComponentRtti)
Returns the component manager that handles the given rtti component type.
Definition World_inl.h:173
bool TryGetObjectWithGlobalKey(const plTempHashedString &sGlobalKey, plGameObject *&out_pObject)
Returns whether an object with the given global key exists and if so writes out the corresponding poi...
Definition World_inl.h:53
static plWorld * GetWorld(plUInt32 uiIndex)
Returns the world with the given index.
Definition World_inl.h:521
plUInt32 GetUpdateCounter() const
Returns the number of update calls. Can be used to determine whether an operation has already been do...
Definition World_inl.h:396
ManagerType * GetOrCreateComponentManager()
Creates an instance of the given component manager type or returns a pointer to an already existing i...
Definition World_inl.h:151
plInternal::WorldData::WriteMarker & GetWriteMarker()
Mark the world for writing by using PL_LOCK(world.GetWriteMarker()). Only one thread can write at a t...
Definition World_inl.h:465
void GetCoordinateSystem(const plVec3 &vGlobalPosition, plCoordinateSystem &out_coordinateSystem) const
Returns the coordinate system for the given position. By default this always returns a coordinate sys...
Definition World_inl.h:415
void DeleteModule()
Deletes the module of the given type or derived types.
bool IsValidObject(const plGameObjectHandle &hObject) const
Returns whether the given handle corresponds to a valid object.
Definition World_inl.h:23
plRandom & GetRandomNumberGenerator()
Accesses the default random number generator. If more control is desired, individual components shoul...
Definition World_inl.h:440
void SetWorldSimulationEnabled(bool bEnable)
If enabled, the full simulation should be executed, otherwise only the rendering related updates shou...
Definition World_inl.h:381
plSpatialSystem * GetSpatialSystem()
Returns the spatial system that is associated with this world.
Definition World_inl.h:401
plInternal::WorldData::ObjectIterator GetObjects()
Returns an iterator over all objects in this world in no specific order.
Definition World_inl.h:86
plInternal::WorldLargeBlockAllocator * GetBlockAllocator()
Returns the block allocator used by this world.
Definition World_inl.h:450
plInternal::WorldData::ReadMarker & GetReadMarker() const
Mark the world for reading by using PL_LOCK(world.GetReadMarker()). Multiple threads can read simulta...
Definition World_inl.h:460
ModuleType * GetOrCreateModule()
Creates an instance of the given module type or derived type or returns a pointer to an already exist...
plAllocator * GetAllocator()
Returns the allocator used by this world.
Definition World_inl.h:445
static plUInt32 GetWorldCount()
Returns the number of active worlds.
Definition World_inl.h:515
plCoordinateSystemProvider & GetCoordinateSystemProvider()
Returns the coordinate system provider that is associated with this world.
Definition World_inl.h:420
plStringView GetName() const
Returns the name of this world.
Definition World_inl.h:2
void SendMessageRecursive(const plGameObjectHandle &hReceiverObject, plMessage &ref_msg)
Sends a message to all components of the receiverObject and all its children.
Definition World_inl.h:327
bool GetWorldSimulationEnabled() const
If enabled, the full simulation should be executed, otherwise only the rendering related updates shou...
Definition World_inl.h:386
void PostMessage(const plGameObjectHandle &hReceiverObject, const plMessage &msg, plTime delay, plObjectMsgQueueType::Enum queueType=plObjectMsgQueueType::NextFrame) const
Queues the message for the given phase. The message is send to the receiverObject after the given del...
Definition World_inl.h:347
bool IsValidComponent(const plComponentHandle &hComponent) const
Checks whether the given handle references a valid component.
Definition World_inl.h:247
plDoubleBufferedLinearAllocator * GetStackAllocator()
Returns the stack allocator used by this world.
Definition World_inl.h:455
plComponentManagerBase * GetManagerForComponentType(const plRTTI *pComponentRtti)
Returns the component manager that handles the given rtti component type.
Definition World_inl.h:233
void SendMessage(const plGameObjectHandle &hReceiverObject, plMessage &ref_msg)
Sends a message to all components of the receiverObject.
Definition World_inl.h:307
void SetUserData(void *pUserData)
Associates the given user data with the world. The user is responsible for the life time of user data...
Definition World_inl.h:470
ManagerType * GetComponentManager()
Returns the instance to the given component manager type.
bool TryGetComponent(const plComponentHandle &hComponent, ComponentType *&out_pComponent)
Returns whether a component with the given handle exists and if so writes out the corresponding point...
Definition World_inl.h:264
void PostMessageRecursive(const plGameObjectHandle &hReceiverObject, const plMessage &msg, plTime delay, plObjectMsgQueueType::Enum queueType=plObjectMsgQueueType::NextFrame) const
Queues the message for the given phase. The message is send to the receiverObject and all its childre...
Definition World_inl.h:354
void * GetUserData() const
Returns the associated user data.
Definition World_inl.h:477
bool TryGetObject(const plGameObjectHandle &hObject, plGameObject *&out_pObject)
Returns whether an object with the given handle exists and if so writes out the corresponding pointer...
Definition World_inl.h:32
const plSharedPtr< plTask > & GetUpdateTask()
Returns a task implementation that calls Update on this world.
Definition World_inl.h:391
plUInt32 GetObjectCount() const
Returns the total number of objects in this world.
Definition World_inl.h:79
Definition WorldModule.h:10
A handle to a component.
Definition Declarations.h:138
Definition CoordinateSystem.h:9
Describes the initial state of a game object.
Definition GameObjectDesc.h:11
A handle to a game object.
Definition Declarations.h:76
Internal game object id used by plGameObjectHandle.
Definition Declarations.h:43
Enum
Definition Declarations.h:274
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12
constexpr double GetSeconds() const
Returns the seconds value.
Definition Time_inl.h:30