Sharklistener
Overview
This component monitors sharks in the world and manages player-specific shark audio intensity by calculating the distance to the nearest shark within a 30-unit radius. It uses periodic updates to adjust a sound parameter on each player entity, fading the shark threat sound based on proximity or triggering a delayed fade-out after sharks have moved away.
Dependencies & Tags
- Relies on the
instentity being valid and capable of listening to server-side events (ms_playerjoined,ms_playerleft,sharkspawned). - Does not add or remove any tags on entities.
- Assumes tracked entities (players and sharks) have:
GetDistanceSqToInst(other)method (standard forGOAPEntity/SimEntity).IsValid()method.HasTag(tag)method (for sharks, checks"walking"tag).
- Assumes players expose
killtask(a task handle) and_sharksoundparam(a sound parameter object with.set(value)).
Properties
The component initializes no public properties beyond self.inst in the constructor. _players and _sharks are private tables used internally.
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | (passed to constructor) | The owning instance (typically the world root, "TheWorld"). |
Note: All tracking tables (_players, _sharks) are private and not exposed as public properties.
Main Functions
GetDebugString()
- Description: Returns a human-readable string indicating how many sharks are currently being tracked.
- Parameters: None.
Events & Listeners
- Listens for:
"ms_playerjoined"→ triggersOnPlayerJoined"ms_playerleft"→ triggersOnPlayerLeft"sharkspawned"→ triggersStartTrackingShark"onremove"(on individual shark entities) → triggersStopTrackingShark
- Periodic Task:
- Runs
processsharksevery 3 seconds (server-side only, as enforced by the commented-out master/sim check).
- Runs
- Pushes no custom events.