Switch¶
class Switch : public Asset<AmSwitchID>
Amplitude Switch Asset.
A switch is a collection of states which can change the sounds played from a SwitchContainer.
For example, you can have a switch named SurfaceType which have wood, grass, metal and water as states. A SwitchContainer using this switch can group sounds per switch states, so when a state is active, all the sounds of that state are played. Changing the state of a Switch will update ALL the SwitchContainer objects that use this Switch.
The Switch is a shared object between sound sources. They are used only by SwitchContainer objects.
Functions¶
| Name | Description |
|---|---|
| GetState | Gets the current state of the switch. |
| SetState | Sets the current state of the switch. |
| SetState | Sets the current state of the switch using the state ID. |
| SetState | Sets the current state of the switch using the state name. |
| GetSwitchStates | Gets the list of available SwitchStates in this Switch. |
Function Details¶
GetState¶
[[nodiscard]] virtual const SwitchState& GetState() const = 0
Gets the current state of the switch.
- Return
- The current state of the switch.
GetSwitchStates¶
[[nodiscard]] virtual const std::vector<SwitchState>& GetSwitchStates() const = 0
Gets the list of available SwitchStates in this Switch.
- Return
- The list of available SwitchStates.
SetState¶
virtual void SetState(const SwitchState& state) = 0
Sets the current state of the switch.
Note
Changing the state of a Switch will update ALL the SwitchContainer objects that use this Switch.
- Parameter
state - The state to apply to the switch.
virtual void SetState(AmObjectID id) = 0
Sets the current state of the switch using the state ID.
Note
Changing the state of a Switch will update ALL the SwitchContainer objects that use this Switch.
- Parameter
id - The ID of the state to apply. This ID should exist in the list of registered switch states.
virtual void SetState(const AmString& name) = 0
Sets the current state of the switch using the state name.
Note
Changing the state of a Switch will update ALL the SwitchContainer objects that use this Switch.
- Parameter
name - The name of the state to apply. This name should exist in the list of registered switch states.