XII Release 0.1.0
Loading...
Searching...
No Matches
xiiStateMachineState_SwitchObject Class Reference

A state machine state that sets the enabled flag on a game object and disables all other objects in the same group. More...

#include <StateMachineComponent.h>

Inheritance diagram for xiiStateMachineState_SwitchObject:
[legend]

Public Member Functions

 xiiStateMachineState_SwitchObject (xiiStringView sName=xiiStringView())
 
virtual void OnEnter (xiiStateMachineInstance &ref_instance, void *pInstanceData, const xiiStateMachineState *pFromState) const override
 
virtual xiiResult Serialize (xiiStreamWriter &inout_stream) const override
 
virtual xiiResult Deserialize (xiiStreamReader &inout_stream) override
 
- Public Member Functions inherited from xiiStateMachineState
 xiiStateMachineState (xiiStringView sName=xiiStringView())
 
void SetName (xiiStringView sName)
 
xiiStringView GetName () const
 
const xiiHashedStringGetNameHashed () const
 
virtual void OnExit (xiiStateMachineInstance &ref_instance, void *pInstanceData, const xiiStateMachineState *pToState) const
 
virtual void Update (xiiStateMachineInstance &ref_instance, void *pInstanceData, xiiTime deltaTime) const
 
virtual bool GetInstanceDataDesc (xiiInstanceDataDesc &out_desc)
 Returns whether this state needs additional instance data and if so fills the out_desc.
 
- Public Member Functions inherited from xiiReflectedClass
virtual const xiiRTTIGetDynamicRTTI () const
 
bool IsInstanceOf (const xiiRTTI *pType) const
 Returns whether the type of this instance is of the given type or derived from it.
 
template<typename T>
XII_ALWAYS_INLINE bool IsInstanceOf () const
 Returns whether the type of this instance is of the given type or derived from it.
 

Public Attributes

xiiString m_sGroupPath
 
xiiString m_sObjectToEnable
 
bool m_bDeactivateOthers = true
 

Additional Inherited Members

- Static Public Member Functions inherited from xiiNoBase
static const xiiRTTIGetStaticRTTI ()
 

Detailed Description

A state machine state that sets the enabled flag on a game object and disables all other objects in the same group.

This state allows to easily switch the representation of a game object. For instance you may have two objects states: normal and burning You can basically just build two objects, one in the normal state, and one with all the effects needed for the fire. Then you group both objects under a shared parent (e.g. with name 'visuals'), give both of them a name ('normal', 'burning') and disable one of them.

When the state machine transitions from the normal state to the burning state, you can then use this type of state to say that from the 'visuals' group you want to activate the 'burning' object and deactivate all other objects in the same group.

Because the state activates one object and deactivates all others, you can have many different visuals and switch between them. You can also only activate an object and keep the rest in the group as they are (e.g. to enable more and more effects). If you only give a group path, but no object name, you can also use it to just disable all objects in a group. If multiple objects in the same group have the same name, they will all get activated simultaneously.

Make sure that essential other objects (like the physics representation or other scripts) are located on other objects, that don't get deactivated.

Member Function Documentation

◆ Deserialize()

xiiResult xiiStateMachineState_SwitchObject::Deserialize ( xiiStreamReader & inout_stream)
overridevirtual

Reimplemented from xiiStateMachineState.

◆ OnEnter()

void xiiStateMachineState_SwitchObject::OnEnter ( xiiStateMachineInstance & ref_instance,
void * pInstanceData,
const xiiStateMachineState * pFromState ) const
overridevirtual

Implements xiiStateMachineState.

◆ Serialize()

xiiResult xiiStateMachineState_SwitchObject::Serialize ( xiiStreamWriter & inout_stream) const
overridevirtual

Reimplemented from xiiStateMachineState.


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