Walkingplankuser
Overview
This component tracks whether an entity is currently mounted on a walking plank, maintains a reference to that plank, and handles cleanup (including event unsubscription) when the entity dismounts or the plank is removed.
Dependencies & Tags
This component does not directly add or remove tags from the entity. It relies on the presence of a walkingplank component on the plank entity (used internally via self.current_plank.components.walkingplank:StopMounting()), but does not enforce or declare this dependency programmatically. No explicit AddComponent calls or tag manipulations are present.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | nil (assigned in _ctor) | Reference to the owning entity instance. |
current_plank | Entity? | nil | Reference to the walking plank the entity is currently mounted on. May be nil. |
_plank_remove_event | EventCallback? | nil | Stored event listener callback used to detect when the current plank is removed from the world. |
Note:
current_plankand_plank_remove_eventare initialized tonilimplicitly (not explicitly in_ctor), as the constructor body contains only comments.
Main Functions
SetCurrentPlank(plank)
- Description: Assigns a new walking plank as the current one. Cancels any existing removal listener on the previous plank and, if a new plank is provided, registers a new
"onremove"listener to automatically clearcurrent_plankif the plank is removed from the world. - Parameters:
plank(Entity?) — The walking plank entity to mount on. Ifnil, clearscurrent_plankand removes any pending listener.
Dismount()
- Description: Handles dismounting the current walking plank. Informs the plank’s
walkingplankcomponent that mounting has stopped, then clearscurrent_plank, and cancels the removal event listener. - Parameters: None.
Events & Listeners
- Listens for
"onremove"event on the current plank (viainst:ListenForEvent("onremove", ...)), triggeringself.current_plank = nilwhen the plank is removed from the world. - Cancels the above event listener (via
:Cancel()) upon dismount or when assigning a new plank.