ezEngine  Release 25.03
ezOnComponentFinishedAction Struct Reference

Certain components may delete themselves or their owner when they are finished with their main purpose. More...

#include <Declarations.h>

Inheritance diagram for ezOnComponentFinishedAction:

Public Types

enum  Enum : StorageType { None, DeleteComponent, DeleteGameObject, Default = None }
 
using StorageType = ezUInt8
 

Static Public Member Functions

static void HandleFinishedAction (ezComponent *pComponent, ezOnComponentFinishedAction::Enum action)
 Call this when a component is 'finished' with its work. More...
 
static void HandleDeleteObjectMsg (ezMsgDeleteGameObject &ref_msg, ezEnum< ezOnComponentFinishedAction > &ref_action)
 Call this function in a message handler for ezMsgDeleteGameObject messages. More...
 

Detailed Description

Certain components may delete themselves or their owner when they are finished with their main purpose.

Member Enumeration Documentation

◆ Enum

Enumerator
None 

Nothing happens after the action is finished.

DeleteComponent 

The component deletes only itself, but its game object stays.

DeleteGameObject 

When finished the component deletes its owner game object. If there are multiple objects with this mode, the component instead deletes itself, and only the last such component deletes the game object.

Member Function Documentation

◆ HandleDeleteObjectMsg()

void ezOnComponentFinishedAction::HandleDeleteObjectMsg ( ezMsgDeleteGameObject ref_msg,
ezEnum< ezOnComponentFinishedAction > &  ref_action 
)
static

Call this function in a message handler for ezMsgDeleteGameObject messages.

This is needed to coordinate object deletion across multiple components that use the ezOnComponentFinishedAction mechanism. Depending on the state of this component, the function will either execute the object deletion, or delay it, until its own work is done.

◆ HandleFinishedAction()

void ezOnComponentFinishedAction::HandleFinishedAction ( ezComponent pComponent,
ezOnComponentFinishedAction::Enum  action 
)
static

Call this when a component is 'finished' with its work.

Pass in the desired action (usually configured by the user) and the 'this' pointer of the component. The helper function will delete this component and maybe also attempt to delete the entire object. For that it will coordinate with other components, and delay the object deletion, if necessary, until the last component has finished it's work.


The documentation for this struct was generated from the following files: