Hideandseeker
Based on game build 714014 | Last updated: 2026-03-03
Overview
Hideandseeker is a lightweight entity component that ensures a seeker entity remains within a designated range of the active hideandseekgame instance. It periodically validates the seeker’s position using Validate, which compares the seeker’s proximity to the game’s hiding_range and hiding_range_toofar thresholds. If the game is no longer active, it announces a message (via talker) and removes itself. If the seeker is too far away, it sets is_faraway to true and announces the condition; if returning within range, it clears the flag and announces re-entry.
This component is designed to work exclusively with the hideandseekgame component and relies on the talker component for localized speech.
Usage example
local inst = CreateEntity()
inst:AddComponent("hideandseeker")
local game = inst.entity:GetParent() -- or however the game instance is obtained
inst.components.hideandseeker:SetGame(game)
-- Validation runs automatically via periodic task; no further setup required
Dependencies & tags
Components used: hideandseekgame, talker
Tags: None identified.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | — | Reference to the entity owning this component (inherited from constructor). |
validate_task | Task | nil | Periodic task (every 1 second) that runs Validate; set in constructor. |
hideandseekgame | Component (optional) | nil | Reference to the hideandseekgame component instance; set via SetGame(). |
abort_game_msg | string (key) | nil | Localized string key for the abort announcement; derived from hideandseekgame.gameaborted_announce. |
is_faraway | boolean | false | Flag indicating whether the entity is currently outside the hiding_range_toofar threshold. |
Main functions
SetGame(hideandseekgame)
- Description: Attaches the component to a specific
hideandseekgameinstance and configures the abort message key. - Parameters:
hideandseekgame(Componentornil) — the game component to track; ifnil,abort_game_msgis set tonil. - Returns: Nothing.
GetDebugString()
- Description: Returns a debug-friendly string summarizing the current state: the
hideandseekgamereference (as string) andis_farawaystatus. - Parameters: None.
- Returns:
string— e.g.,"[Component hideandseekgame] @ 0x123456, is far away: false".
Events & listeners
- Listens to: Periodic task (
DoPeriodicTask(1, Validate)) — callsValidateevery 1 second. - Pushes: No events; relies on side effects (
talker:Say,inst:RemoveComponent).