Nightmarerock
Based on game build 714014 | Last updated: 2026-03-06
Overview
Nightmarerock is a functional obstacle that toggles between active (rising) and inactive (lowered) states based on the sanity status of nearby players. It implements dynamic collision and pathfinding behavior: when active and not concealed, it blocks characters, items, and obstacles; when concealed or inactive, its collision profile changes accordingly. Two prefabs are defined: sanityrock (active when players are sane) and insanityrock (active when players are insane). It interacts with the inspectable and sanity components for status reporting and logic evaluation, and with the pathfinding system via shared walls to avoid overlapping region conflicts.
Usage example
-- Example: Create and configure a sanity rock prefab instance
local inst = CreateEntity()
inst:AddTag("sanityrock")
-- (In practice, prefabs are instantiated via Prefab() system, not CreateEntity())
-- The component logic is embedded in the prefab definition itself.
Dependencies & tags
Components used: inspectable (for status reporting), sanity (via external call on players)
Tags added: antlion_sinkhole_blocker, plus either "sanityrock" or "insanityrock" depending on prefab variant.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
active | boolean | false | Current physical state (true = rock is up/rising). |
active_queue | boolean | false | Target state determined during refresh; may differ from active during transition. |
conceal | boolean | nil (treated as false) | Whether the rock is visually hidden/concealed (e.g., during minigames). |
conceal_queued | boolean | nil | Target concealment state; triggers conceal or reveal state transition. |
activeonsane | boolean | true (sanityrock) / false (insanityrock) | Determines whether the rock activates when players are sane (true) or insane (false). |
_pftable | table | nil | Stores grid coordinates of pathfinding walls added/removed by this entity. |
_ispathfinding | net_bool | false | Networked flag indicating whether pathfinding walls should be active. |
Main functions
refresh(inst)
- Description: Recalculates whether the rock should be active based on proximity and player sanity state. Compares each valid player’s sanity (
IsSaneorIsInsane) withinst.activeonsane, and activates if any player is withinNEAR_DIST_SQorFAR_DIST_SQ. Triggers a state transition if needed. - Parameters:
inst(Entity instance) — the rock instance to evaluate. - Returns: Nothing.
- Error states: Skips evaluation entirely if rock is currently concealed (
inst.concealorinst.conceal_queued).
OnIsPathFindingDirty(inst)
- Description: Synchronizes pathfinding walls with the rock’s current
_ispathfindingstate. Adds walls when becoming pathfinding-dirty (active + not concealed), removes them when inactive. Handles shared wall logic to prevent conflicts in overlapping obstacle regions. - Parameters:
inst(Entity instance). - Returns: Nothing.
ConcealForMinigame(inst, conceal)
- Description: Temporarily forces the rock into a concealed state for minigames or special events. Sets
conceal_queued, clearsactive_queue, and triggers aconcealorrevealstate transition. - Parameters:
conceal(boolean) —trueto conceal,falseornilto reveal. - Returns: Nothing.
getstatus(inst)
- Description: Returns a status string for the
inspectablecomponent (e.g.,"ACTIVE"or"INACTIVE"). - Parameters:
inst(Entity instance). - Returns:
"ACTIVE"ifinst.activeistrue, otherwise"INACTIVE".
updatephysics(inst)
- Description: Updates physics collision group and mask based on
inst.concealandinst.active. Configures collision to includeCHARACTERSonly when active and not concealed. - Parameters:
inst(Entity instance). - Returns: Nothing.
Events & listeners
- Listens to:
onispathfindingdirty— triggersOnIsPathFindingDirtyto manage pathfinding walls when_ispathfindingstate changes. - Pushes: None — this component does not fire custom events, but integrates with
inst.sgstate graph transitions (raise,lower,conceal,reveal).