Object State
This component belongs to the following package:
- com.yahaha.sdk.horrorgame
This Object State component manages an object's states as a list of strings and provides actions to set the current state. It can trigger events when the state changes, helping maintain and control various object conditions during gameplay.
Property | Description |
---|---|
States | A list of string identifiers representing the various states the object can be in. |
Default State | The initial state of the object when the game starts. |
Enable Debug Log | If enabled, the component will be running in debug mode and provide additional information for testing and troubleshooting purposes. |
Trigger
Events:
- com.yahaha.sdk.horrorgame.StateChanged
- Description:
- Fires when the object state changes.
- EventArgs:
- previousState: string
- newState: string
- Description:
Conditions:
- IsCurrentState
- Description:
- Checks if the current state is a specific one.
- Arguments:
- state: string state name
- Returns:
- value: boolean
- Description:
- IsPreviousState
- Description:
- Checks if a previous state is a specific one.
- Arguments:
- state: string state name
- Returns:
- value: boolean
- Description:
Actions:
- SetState
- Description:
- Set the object state
- Arguments:
- newState: string state name
- Description:
- GetCurrentState
- Returns:
- stateName: string|nil current state name; if there's no valid state, returns nil
- Returns:
- GetPreviousState
- Returns:
- stateName: string|nil Previous state name; if there's no valid state, returns nil
- Returns:
- TrySetState
- Description:
- if currentState is "fromState" then set it to "toSate"
- Arguments:
- fromState: string state name
- toState: string state name
- Returns:
- value: boolean
- Description:
Related Components
This component is usually used with Event Trigger, which sets conditions and actions in response to an event or trigger.