Vault Floor Helper
Overview
This component enables the game to dynamically track and query whether a point lies inside the currently active vault floor region. It stores networked state—such as whether the vault is active and its origin coordinates—via vault_active, vault_origin_x, and vault_origin_z network variables, and maintains a reference to a marker entity that defines the vault’s center. The core functionality is implemented in IsPointInVaultRoom_Internal, which performs an axis-aligned bounding box check against three overlapping rectangular/square zones (horizontal, vertical, and central square) based on predefined tile-scale dimensions.
Dependencies & Tags
- Uses
net_bool,net_floatnetwork variable constructors tied toinst.GUID. - Does not add or remove any entity tags.
- Does not declare or require any other components on
self.inst. - Relies on external constants:
TILE_SCALE,TheWorld,TheWorld.Map.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | — | The entity this component is attached to (typically a world or map entity). |
vault_active | net_bool | false | Networked boolean indicating whether the vault floor is currently active. |
vault_origin_x | net_float | 0.0 | Networked float storing the X world-coordinate of the vault’s origin (center point). |
vault_origin_z | net_float | 0.0 | Networked float storing the Z world-coordinate of the vault’s origin. |
marker | Entity? | nil | Optional reference to the marker entity currently defining the vault origin. |
Main Functions
self:IsPointInVaultRoom_Internal(x, y, z)
- Description: Determines whether the given world position
(x, y, z)lies inside the vault’s active area. The Y coordinate is unused; only X and Z are considered. This method is intended to be called indirectly viaMap:IsPointInVaultRoom, not directly. - Parameters:
x(number): World X coordinate of the point to test.y(number): World Y coordinate (ignored in current implementation).z(number): World Z coordinate of the point to test.
Returns:trueif the point falls within any of the three defined vault regions (horizontal bar, vertical bar, or central square); otherwisefalse.
self:TryToSetMarker(inst)
- Description: Assigns or replaces the vault marker entity. If a marker already exists, it removes the new one; if none exists, it sets the new marker as active, records its world position as the new origin, marks the vault as active, and attaches an
onremovelistener to reset state when the marker is removed. - Parameters:
inst(Entity): The candidate marker entity (usually a vault marker prefab instance).
Events & Listeners
- Listens for
"onremove"event on themarkerentity viainst:ListenForEvent("onremove", self.OnRemove_Marker).- When triggered, invokes
self.OnRemove_Marker(ent, data)to clearself.markerand deactivate the vault (resettingvault_active,vault_origin_x, andvault_origin_zto default values).
- When triggered, invokes