Hideandseeker
Overview
The hideandseeker component monitors an entity's distance from an active Hide-and-Seek game instance. It uses a periodic task to check proximity thresholds and triggers speech announcements (e.g., if the entity strays too far or returns within range), or removes itself if the game is no longer valid.
Dependencies & Tags
- Component usage:
inst:RemoveComponent("hideandseeker")— may be removed dynamically during validation. - Dependencies:
talkercomponent: Required to trigger speech announcements viaSay().hideandseekgamecomponent (on the game entity): Provides configuration values such ashiding_range,hiding_range_toofar,seeker_too_far_announce,seeker_too_far_return_announce, andgameaborted_announce.
- No tags are added or removed by this component.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | GEntity | — | Reference to the entity the component is attached to. |
hideandseekgame | Component? | nil | Reference to the hideandseekgame component of the active game. Set via SetGame(). |
abort_game_msg | string? | nil | Localization key for the announcement when the game is aborted (set when SetGame() is called). |
is_faraway | boolean | false | Tracks whether the entity is currently too far from the game to participate. |
validate_task | Task? | nil | Periodic task (runs every 1 second) that calls the Validate() function. |
Main Functions
SetGame(hideandseekgame)
- Description: Assigns the active Hide-and-Seek game instance and preloads the abort-message localization key. Resets
abort_game_msgbased on the game’s configuration. - Parameters:
hideandseekgame(Component?): Thehideandseekgamecomponent of the game entity. Ifnil,abort_game_msgbecomesnil.
GetDebugString()
- Description: Returns a human-readable debug string showing the current game reference and
is_farawaystate. - Parameters: None.
OnRemoveFromEntity()
- Description: Cleans up by canceling the
validate_taskto prevent memory leaks or orphaned tasks when the component is removed. - Parameters: None.
Events & Listeners
None. This component does not use event listeners (inst:ListenForEvent) or explicitly push events (inst:PushEvent). All logic is driven by the periodic task.