TetherPullComponent - acrimi/Raven GitHub Wiki
Extends StatefulComponent
TetherPullComponent
is an extension of StatefulComponent that defines an entity's ability to pull another entity indirectly through a tether. If the entity has a child that holds a TetherComponent, and that component is linked to another entity via its targetId
, this component's tetherEntityId
will be set to the child's id, indicating a holding behavior. If tension is then applied to this component, an attempt will be made to activate the component to start a pulling action in one of two ways:
- If the pulling entity is on an entity holding both a SurfaceComponent and PullableComponent, that entity will be pulled towards the entity linked by the child's TetherComponent
- If the child's TetherComponent target holds a PullableComponent, that entity will be pulled towards the pulling entity
The appropriate entity will be pulled in increments of the map's tile size.
In addition to the standard state events, two special events, "tetherHeld"
and "tetherReleased"
, will be emitted when tetherEntityId
is set or unset, respectively.
When used inside the components
block, the initial state of the component can be configured with the following parameters:
Key | Type | Description |
---|---|---|
pullSpeed | float | The speed at which the targeted entity or surface will be moved when the component activates |
duration* | float | The duration, in seconds, of the "active" state for this component. Defaults to -1 , which is treated as infinite duration. |
enterStates* | (string|object)[] | An array of states that will be passed through when going from the "inactive" state to the "active" state. Each state can be defined as either an object with a single key value pair corresponding the state's name and duration, or as a string representing the state name. States defined as a string will have an infinite duration. The array values can be heterogenous. |
[stateName]* | float | The key represents the name of this state and the value is the duration, in seconds. For infinite duration, use a value of -1
|
exitStates* | (string|object)[] | An array of states that will be passed through when going from the "active" state to the "inactive" state. Each state can be defined as either an object with a single key value pair corresponding the state's name and duration, or as a string representing the state name. States defined as a string will have an infinite duration. The array values can be heterogenous. |
[stateName]* | float | The key represents the name of this state and the value is the duration, in seconds. For infinite duration, use a value of -1
|
initialState* | string | The state the component will start in. Must be one of "inactive" , "active" , or any of the custom states provided via enterStates or exitStates . By default, the component will start in the "inactive" state. Setting a different initial state will not cause events to fire for entering that state. |
isActive* | boolean | Equivalent to passing "active" to initialState . Defaults to false . |
* from StatefulComponent
Example:
"TetherPullComponent": {
"pullSpeed": 20
}
The following properties are readable by property accessors (eg render state and persistence definitions):
Key | Type | Description |
---|---|---|
hasTether | boolean | Whether or not the component's tetherEntityId is set, indicating the entity's holding state |
isActive* | boolean | Whether or not the current state is "active"
|
isInactive* | boolean | Whether or not the current state is "inactive"
|
state* | string | The name of the current state |
progress* | float | The percentage, from 0 to 1 , of how much time has elapsed for the current state relative to its duration (elapsedTime / duration). If the current state has an infinite duration, this value is always 0 . |
* from StatefulComponent