Walkingplank
Overview
This component provides the logic for a walkable plank entity, enabling players (or other entities) to mount and dismount it, and supporting dynamic extension/retraction animations. It maintains a reference to the current mounting entity and coordinates state transitions via events.
Dependencies & Tags
- Adds the
"walkingplank"tag to its entity on initialization. - Removes the
"walkingplank"tag on removal from entity. - Assumes dependency on the following components being present on related entities (not added by this component itself):
doer.components.walkingplankuser(expected to be available on mounting entity)doer.Physics(expected to provideTeleport())
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | nil (passed to constructor) | Reference to the entity this component is attached to. |
doer | Entity? | nil | Reference to the entity currently mounted on the plank; nil when unoccupied. |
Main Functions
Extend()
- Description: Triggers the extension animation by pushing the
"start_extending"event immediately. - Parameters: None.
Retract()
- Description: Triggers the retraction animation by pushing the
"start_retracting"event immediately. - Parameters: None.
MountPlank(doer)
- Description: Attempts to mount the given entity (
doer) onto the plank. Teleports thedoerto the plank's world position, setsdoeras the active mount, and notifies related components via events. Returnstrueon success, orfalseif already occupied. - Parameters:
doer(Entity): The entity attempting to mount the plank.
StopMounting()
- Description: Cancels an ongoing mount attempt (if any), clearing the
doerreference and broadcasting"stop_mounting". - Parameters: None.
AbandonShip(doer)
- Description: Initiates dismount for the currently mounted entity (
doer). Validates ownership, triggers dismount logic viawalkingplankuser, and broadcasts"start_abandoning". Returnstrueon success, orfalseifdoeris invalid or mismatched. - Parameters:
doer(Entity): The entity that originally mounted and is now leaving the plank.
Events & Listeners
- Listens for entity removal to clean up the
"walkingplank"tag (viaOnRemoveFromEntity). - Pushes events:
"start_extending"(viaExtend)"start_retracting"(viaRetract)"start_mounting"(viaMountPlank)"stop_mounting"(viaStopMounting)"start_abandoning"(viaAbandonShip)