ECSM v0.4.0
DoNotDestroySystem

Handles entities that should not be destroyed. More...

#include <ecsm.hpp>

Public Types

typedef DoNotDestroyComponent ComponentType
using Components
typedef DoNotDestroySystem ItemType
typedef Singleton< DoNotDestroySystem, true > Instance

Public Member Functions

const ComponentsgetComponents () const noexcept
 Returns system component pool.
std::type_index getComponentType () const override
 Returns specific component typeid() of the system.
View< ComponentgetComponent (ID< Component > instance) override
 Returns specific component View.
void disposeComponents () override
 Actually destroys system components.
bool hasComponent (ID< Entity > entity) const
 Returns true if entity has specific component.
View< DoNotDestroyComponenttryGetComponent (ID< Entity > entity) const
 Returns entity specific component view if exist.
void resetComponentData (ID< Entity > entity, bool full=true)
 Resets entity specific component data.

Static Public Member Functions

static bool has ()
 Returns true if class singleton or manager instance is exist.
static DoNotDestroySystemget ()
 Returns class singleton or manager instance.
static DoNotDestroySystemtryGet ()
 Returns class singleton or manager instance if exist.

Protected Member Functions

 DoNotDestroySystem (bool setSingleton=true)
 Creates a new do not destroy system instance.
 ~DoNotDestroySystem () override
 Destroys do not destroy system instance.
std::string_view getComponentName () const override
 Returns specific component name of the system.
ID< ComponentcreateComponent (ID< Entity > entity) override
 Creates a new component instance for the entity.
void destroyComponent (ID< Component > instance) override
 Destroys component instance.
void resetComponent (View< Component > component, bool full) override
 Resets component data.
void copyComponent (View< Component > source, View< Component > destination) override
 Copies component data from source to destination.
void setSingleton ()
 Sets a new class singleton instance.
void unsetSingleton () noexcept
 Unsets this class singleton instance.

Protected Attributes

Components components

Static Protected Attributes

static DoNotDestroySystemsingletonInstance

Friends

class ecsm::Manager

Detailed Description

Handles entities that should not be destroyed.

Member Typedef Documentation

◆ ComponentType

Type of the system component.

◆ Components

using Components
inherited

System component pool type.

◆ ItemType

typedef DoNotDestroySystem ItemType
inherited

Type of the singleton class.

◆ Instance

typedef Singleton<DoNotDestroySystem, true> Instance
inherited

Singleton instance class type.

Constructor & Destructor Documentation

◆ DoNotDestroySystem()

DoNotDestroySystem ( bool setSingleton = true)
protected

Creates a new do not destroy system instance.

Parameters
setSingletonset system singleton instance

Member Function Documentation

◆ getComponentName()

std::string_view getComponentName ( ) const
overrideprotectedvirtual

Returns specific component name of the system.

Reimplemented from ComponentSystem< DoNotDestroyComponent, false >.

◆ createComponent()

ID< Component > createComponent ( ID< Entity > entity)
inlineoverrideprotectedvirtualinherited

Creates a new component instance for the entity.

You should use Manager to add components to the entity.

Reimplemented from System.

◆ destroyComponent()

void destroyComponent ( ID< Component > instance)
inlineoverrideprotectedvirtualinherited

Destroys component instance.

You should use Manager to remove components from the entity.

Reimplemented from System.

◆ resetComponent()

void resetComponent ( View< Component > component,
bool full )
inlineoverrideprotectedvirtualinherited

Resets component data.

You should use Manager to remove components from the entity.

Reimplemented from System.

◆ copyComponent()

void copyComponent ( View< Component > source,
View< Component > destination )
inlineoverrideprotectedvirtualinherited

Copies component data from source to destination.

You should use Manager to copy component data of entities.

Reimplemented from System.

◆ getComponentType()

std::type_index getComponentType ( ) const
inlineoverridevirtualinherited

Returns specific component typeid() of the system.

Note
Override it to define a custom component of the system.

Reimplemented from System.

◆ getComponent()

View< Component > getComponent ( ID< Component > instance)
inlineoverridevirtualinherited

Returns specific component View.

Parameters
instancetarget system component instance

Reimplemented from System.

◆ disposeComponents()

void disposeComponents ( )
inlineoverridevirtualinherited

Actually destroys system components.

Components are not destroyed immediately, only after the dispose call.

Reimplemented from System.

◆ hasComponent()

bool hasComponent ( ID< Entity > entity) const
inlineinherited

Returns true if entity has specific component.

Parameters
entitytarget entity with component
Note
This function is faster than the Manager one.

◆ tryGetComponent()

View< DoNotDestroyComponent > tryGetComponent ( ID< Entity > entity) const
inlineinherited

Returns entity specific component view if exist.

Parameters
entitytarget entity with component
Note
This function is faster than the Manager one.

◆ resetComponentData()

void resetComponentData ( ID< Entity > entity,
bool full = true )
inlineinherited

Resets entity specific component data.

Parameters
entitytarget entity with component
fullreset all component data
Note
This function is faster than the Manager one.

Member Data Documentation

◆ components

Components components
protectedinherited

System component pool.

◆ singletonInstance

DoNotDestroySystem* singletonInstance
inlinestaticprotectedinherited

Singleton class instance.