Skip to main content

EngineWorld Class

Top-level aggregate world that dispatches entity operations to the correct domain-specific TypedHandleWorld based on the handle type. More...

Declaration

class helios::engine::runtime::world::EngineWorld { ... }

Public Member Functions Index

GameObjectWorld &gameObjectWorld ()

Returns the game-object and scene sub-world. More...

PlatformWorld &platformWorld ()

Returns the platform (window, environment) sub-world. More...

RenderResourceWorld &renderResourceWorld ()

Returns the render-resource (shader, material, mesh) sub-world. More...

RenderTargetWorld &renderTargetWorld ()

Returns the render-target and viewport sub-world. More...

template <typename THandle>
autoclone (THandle source) noexcept

Clones an entity within the sub-world appropriate for THandle. More...

template <typename THandle>
auto &entityManager () noexcept

Returns the entity manager responsible for THandle. More...

template <typename THandle, typename TComponent>
auto *sparseSet () noexcept

Returns the SparseSet<TComponent> from the entity manager for THandle. More...

template <typename THandle>
boolisValid (THandle handle) noexcept

Returns whether handle refers to a living entity. More...

template <typename THandle>
autofind (THandle handle) noexcept

Finds and returns an Entity wrapper for handle. More...

template <typename THandle>
autoadd (typename THandle::StrongId_type strongId=typename THandle::StrongId_type{})

Creates a new entity in the sub-world appropriate for THandle. More...

template <typename THandle, typename... TComponents>
autoview ()

Returns a View over entities with TComponents in the sub-world for THandle. More...

template <typename THandle>
autodestroy (const THandle handle)

Destroys an entity in the sub-world appropriate for THandle. More...

template <typename THandle = void, typename... TComponents>
voidclearDirtySets ()

Clears dirty sets across all sub-worlds or for a specific handle and component list. More...

Private Member Functions Index

template < ... >
voidclearDirtySetsForHandles (TWorld &world, type_list< THandles... >)

Clears all dirty sets for every handle type in THandles inside world. More...

Private Member Attributes Index

GameObjectWorldgameObjectWorld_ {}
RenderResourceWorldrenderResourceWorld_ {}
PlatformWorldplatformWorld_ {}
RenderTargetWorldrenderTargetWorld_ {}

Description

Top-level aggregate world that dispatches entity operations to the correct domain-specific TypedHandleWorld based on the handle type.

Routes add, find, view, destroy, clone, clearDirtySets, etc. to one of four sub-worlds: game objects, render resources, platform, or render targets.

Definition at line 133 of file EngineWorld.ixx.

Public Member Functions

add()

template <typename THandle>
auto helios::engine::runtime::world::EngineWorld::add (typename THandle::StrongId_type strongId=typename THandle::StrongId_type{})
inline

Creates a new entity in the sub-world appropriate for THandle.

Template Parameters
THandle

Handle type that determines the target sub-world.

Parameters
strongId

Optional strong identifier for the new entity.

Returns

Entity wrapper for the newly created entity.

Definition at line 303 of file EngineWorld.ixx.

303 [[nodiscard]] auto add(typename THandle::StrongId_type strongId = typename THandle::StrongId_type{}) {
304 if constexpr(IsGameplaySystemHandle<THandle>) {
305 return gameObjectWorld_.addEntity<THandle>(strongId);
306 } else if constexpr(IsAnyPlatformHandle<THandle>) {
307 return platformWorld_.addEntity<THandle>(strongId);
308 } else if constexpr(IsRenderResourceHandle<THandle>) {
309 return renderResourceWorld_.addEntity<THandle>(strongId);
310 } else if constexpr(IsRenderTargetHandle<THandle>) {
311 return renderTargetWorld_.addEntity<THandle>(strongId);
312 } else {
313 static_assert(typed_false<THandle>, "Unsupported handle type for adding");
314 }
315 }

clearDirtySets()

template <typename THandle = void, typename... TComponents>
void helios::engine::runtime::world::EngineWorld::clearDirtySets ()
inline

Clears dirty sets across all sub-worlds or for a specific handle and component list.

When called as clearDirtySets<>() (no template args), clears all dirty sets in every sub-world. When called as clearDirtySets<THandle, TComponents...>(), only the matching sub-world and component types are affected.

Template Parameters
THandle

Handle type selecting the sub-world (void = all worlds).

TComponents

Component types whose dirty sets are cleared (empty = all).

Definition at line 372 of file EngineWorld.ixx.

373
374 if constexpr (std::is_same_v<THandle, void>) {
375
380
381 } else if constexpr(IsGameplaySystemHandle<THandle>) {
382 gameObjectWorld_.template clearDirtySets<THandle, TComponents...>();
383 } else if constexpr(IsAnyPlatformHandle<THandle>) {
384 platformWorld_.template clearDirtySets<THandle, TComponents...>();
385 } else if constexpr(IsRenderResourceHandle<THandle>) {
386 renderResourceWorld_.template clearDirtySets<THandle, TComponents...>();
387 } else if constexpr(IsRenderTargetHandle<THandle>) {
388 renderTargetWorld_.template clearDirtySets<THandle, TComponents...>();
389 } else {
390 static_assert(typed_false<THandle>, "Unsupported handle type for clearDirtySets()");
391 }
392
393 }

References clearDirtySets and helios::engine::runtime::registerComponents.

Referenced by clearDirtySets and helios::engine::runtime::world::UpdateContext::clearDirtySets.

clone()

template <typename THandle>
auto helios::engine::runtime::world::EngineWorld::clone (THandle source)
inline noexcept

Clones an entity within the sub-world appropriate for THandle.

Template Parameters
THandle

Handle type of the entity to clone.

Parameters
source

Handle of the source entity.

Returns

Entity wrapper for the newly cloned entity.

Definition at line 190 of file EngineWorld.ixx.

190 [[nodiscard]] auto clone(THandle source) noexcept {
191
192 if constexpr(IsGameplaySystemHandle<THandle>) {
193 return gameObjectWorld_.cloneEntity<THandle>(source);
194 } else if constexpr(IsAnyPlatformHandle<THandle>){
195 return platformWorld_.cloneEntity<THandle>(source);
196 } else if constexpr(IsRenderResourceHandle<THandle>) {
197 return renderResourceWorld_.cloneEntity<THandle>(source);
198 } else if constexpr(IsRenderTargetHandle<THandle>) {
199 return renderTargetWorld_.cloneEntity<THandle>(source);
200 } else {
201 static_assert(typed_false<THandle>, "Unsupported handle type for cloning");
202 }
203 }

Reference helios::engine::runtime::registerComponents.

destroy()

template <typename THandle>
auto helios::engine::runtime::world::EngineWorld::destroy (const THandle handle)
inline

Destroys an entity in the sub-world appropriate for THandle.

Template Parameters
THandle

Deduced handle type.

Parameters
handle

Handle of the entity to destroy.

Returns

true if destroyed, false if the handle was already invalid.

Definition at line 347 of file EngineWorld.ixx.

347 [[nodiscard]] auto destroy(const THandle handle) {
348 if constexpr(IsGameplaySystemHandle<THandle>) {
349 return gameObjectWorld_.destroy<THandle>(handle);
350 } else if constexpr(IsAnyPlatformHandle<THandle>) {
351 return platformWorld_.destroy<THandle>(handle);
352 } else if constexpr(IsRenderResourceHandle<THandle>) {
353 return renderResourceWorld_.destroy<THandle>(handle);
354 } else if constexpr(IsRenderTargetHandle<THandle>) {
355 return renderTargetWorld_.destroy<THandle>(handle);
356 } else {
357 static_assert(typed_false<THandle>, "Unsupported handle type for destroying");
358 }
359 }

Reference helios::engine::runtime::registerComponents.

entityManager()

template <typename THandle>
auto & helios::engine::runtime::world::EngineWorld::entityManager ()
inline noexcept

Returns the entity manager responsible for THandle.

Template Parameters
THandle

Handle type whose manager is requested.

Returns

Reference to the matching entity manager.

Definition at line 212 of file EngineWorld.ixx.

213
214 if constexpr(IsGameplaySystemHandle<THandle>) {
215 return gameObjectWorld_.entityManager<THandle>();
216 } else if constexpr(IsAnyPlatformHandle<THandle>){
217 return platformWorld_.entityManager<THandle>();
218 } else if constexpr(IsRenderResourceHandle<THandle>) {
219 return renderResourceWorld_.entityManager<THandle>();
220 } else if constexpr(IsRenderTargetHandle<THandle>) {
221 return renderTargetWorld_.entityManager<THandle>();
222 } else {
223 static_assert(typed_false<THandle>, "Unsupported handle type for entityManager");
224 }
225 }

Reference helios::engine::runtime::registerComponents.

find()

template <typename THandle>
auto helios::engine::runtime::world::EngineWorld::find (THandle handle)
inline noexcept

Finds and returns an Entity wrapper for handle.

Template Parameters
THandle

Deduced handle type.

Parameters
handle

Handle to look up.

Returns

Entity wrapper, or an invalid wrapper if not found.

Definition at line 280 of file EngineWorld.ixx.

280 [[nodiscard]] auto find(THandle handle) noexcept {
281
282 if constexpr(IsGameplaySystemHandle<THandle>) {
283 return gameObjectWorld_.findEntity<THandle>(handle);
284 } else if constexpr(IsAnyPlatformHandle<THandle>) {
285 return platformWorld_.findEntity<THandle>(handle);
286 } else if constexpr(IsRenderResourceHandle<THandle>) {
287 return renderResourceWorld_.findEntity<THandle>(handle);
288 } else if constexpr(IsRenderTargetHandle<THandle>) {
289 return renderTargetWorld_.findEntity<THandle>(handle);
290 } else {
291 static_assert(typed_false<THandle>, "Unsupported handle type for searching");
292 }
293 }

Reference helios::engine::runtime::registerComponents.

Referenced by helios::engine::runtime::pooling::EntityPoolManager< TEntity >::acquire and helios::engine::runtime::pooling::EntityPoolManager< TEntity >::release.

gameObjectWorld()

GameObjectWorld & helios::engine::runtime::world::EngineWorld::gameObjectWorld ()
inline

Returns the game-object and scene sub-world.

Definition at line 157 of file EngineWorld.ixx.

158 return gameObjectWorld_;
159 }

Referenced by helios::engine::runtime::world::GameWorld::gameObjectWorld.

isValid()

template <typename THandle>
bool helios::engine::runtime::world::EngineWorld::isValid (THandle handle)
inline noexcept

Returns whether handle refers to a living entity.

Template Parameters
THandle

Deduced handle type.

Parameters
handle

Handle to validate.

Definition at line 257 of file EngineWorld.ixx.

257 [[nodiscard]] bool isValid(THandle handle) noexcept {
258
259 if constexpr(IsGameplaySystemHandle<THandle>) {
260 return gameObjectWorld_.entityManager<THandle>().isValid(handle);
261 } else if constexpr(IsAnyPlatformHandle<THandle>){
262 return platformWorld_.entityManager<THandle>().isValid(handle);
263 } else if constexpr(IsRenderResourceHandle<THandle>) {
264 return renderResourceWorld_.entityManager<THandle>().isValid(handle);
265 } else if constexpr(IsRenderTargetHandle<THandle>) {
266 return renderTargetWorld_.entityManager<THandle>().isValid(handle);
267 } else {
268 static_assert(typed_false<THandle>, "Unsupported handle type for storage");
269 }
270 }

References isValid and helios::engine::runtime::registerComponents.

Referenced by isValid.

platformWorld()

PlatformWorld & helios::engine::runtime::world::EngineWorld::platformWorld ()
inline

Returns the platform (window, environment) sub-world.

Definition at line 164 of file EngineWorld.ixx.

165 return platformWorld_;
166 }

Referenced by helios::engine::runtime::world::GameWorld::platformWorld.

renderResourceWorld()

RenderResourceWorld & helios::engine::runtime::world::EngineWorld::renderResourceWorld ()
inline

Returns the render-resource (shader, material, mesh) sub-world.

Definition at line 171 of file EngineWorld.ixx.

172 return renderResourceWorld_;
173 }

Referenced by helios::engine::runtime::world::GameWorld::renderResourceWorld.

renderTargetWorld()

RenderTargetWorld & helios::engine::runtime::world::EngineWorld::renderTargetWorld ()
inline

Returns the render-target and viewport sub-world.

Definition at line 178 of file EngineWorld.ixx.

179 return renderTargetWorld_;
180 }

Referenced by helios::engine::runtime::world::GameWorld::renderTargetWorld.

sparseSet()

template <typename THandle, typename TComponent>
auto * helios::engine::runtime::world::EngineWorld::sparseSet ()
inline noexcept

Returns the SparseSet<TComponent> from the entity manager for THandle.

Template Parameters
THandle

Handle type identifying the sub-world.

TComponent

Component type whose storage is requested.

Returns

Non-owning pointer to the sparse set, or nullptr if not allocated.

Definition at line 235 of file EngineWorld.ixx.

236
237 if constexpr(IsGameplaySystemHandle<THandle>) {
238 return gameObjectWorld_.entityManager<THandle>().template sparseSet<TComponent>();
239 } else if constexpr(IsAnyPlatformHandle<THandle>){
240 return platformWorld_.entityManager<THandle>().template sparseSet<TComponent>();
241 } else if constexpr(IsRenderResourceHandle<THandle>) {
242 return renderResourceWorld_.entityManager<THandle>().template sparseSet<TComponent>();
243 } else if constexpr(IsRenderTargetHandle<THandle>) {
244 return renderTargetWorld_.entityManager<THandle>().template sparseSet<TComponent>();
245 } else {
246 static_assert(typed_false<THandle>, "Unsupported handle type for storage");
247 }
248 }

Reference helios::engine::runtime::registerComponents.

view()

template <typename THandle, typename... TComponents>
auto helios::engine::runtime::world::EngineWorld::view ()
inline

Returns a View over entities with TComponents in the sub-world for THandle.

Template Parameters
THandle

Handle type identifying the sub-world.

TComponents

Required component types.

Definition at line 324 of file EngineWorld.ixx.

324 [[nodiscard]] auto view() {
325 if constexpr(IsGameplaySystemHandle<THandle>) {
326 return gameObjectWorld_.template view<THandle, TComponents...>();
327 } else if constexpr(IsAnyPlatformHandle<THandle>) {
328 return platformWorld_.template view<THandle, TComponents...>();
329 } else if constexpr(IsRenderResourceHandle<THandle>) {
330 return renderResourceWorld_.template view<THandle, TComponents...>();
331 } else if constexpr(IsRenderTargetHandle<THandle>) {
332 return renderTargetWorld_.template view<THandle, TComponents...>();
333 } else {
334 static_assert(typed_false<THandle>, "Unsupported handle type for viewing");
335 }
336
337 }

References helios::engine::runtime::registerComponents and view.

Referenced by helios::engine::runtime::pooling::EntityPoolManager< TEntity >::init, view, helios::engine::runtime::world::GameWorld::view and helios::engine::runtime::world::UpdateContext::view.

Private Member Functions

clearDirtySetsForHandles()

template <typename TWorld, typename... TComponents, typename... THandles>
void helios::engine::runtime::world::EngineWorld::clearDirtySetsForHandles (TWorld & world, type_list< THandles... >)
inline

Clears all dirty sets for every handle type in THandles inside world.

Template Parameters
TWorld

Sub-world type.

TComponents

Component types to clear (empty = clear all).

THandles

Handle types derived from the world's entity managers.

Definition at line 148 of file EngineWorld.ixx.

148 void clearDirtySetsForHandles(TWorld& world, type_list<THandles...>) {
149 (world.template clearDirtySets<THandles, TComponents...>(), ...);
150 }

Private Member Attributes

gameObjectWorld_

GameObjectWorld helios::engine::runtime::world::EngineWorld::gameObjectWorld_ {}

Definition at line 135 of file EngineWorld.ixx.

135 GameObjectWorld gameObjectWorld_{};

platformWorld_

PlatformWorld helios::engine::runtime::world::EngineWorld::platformWorld_ {}

Definition at line 137 of file EngineWorld.ixx.

137 PlatformWorld platformWorld_{};

renderResourceWorld_

RenderResourceWorld helios::engine::runtime::world::EngineWorld::renderResourceWorld_ {}

Definition at line 136 of file EngineWorld.ixx.

136 RenderResourceWorld renderResourceWorld_{};

renderTargetWorld_

RenderTargetWorld helios::engine::runtime::world::EngineWorld::renderTargetWorld_ {}

Definition at line 138 of file EngineWorld.ixx.

138 RenderTargetWorld renderTargetWorld_{};

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.