Skip to main content

Lavaarenamusic

Overview

This audio component dynamically controls background music in the Lava Arena by playing tracks when a player enters the arena and stopping when they exit. It listens for player activation/deactivation events, manages network synchronization of the arena level, and plays the appropriate music track (fight_1) when the level changes.

Dependencies & Tags

  • Relies on TheWorld.SoundEmitter for sound playback (TheFocalPoint.SoundEmitter).
  • Requires the playeractivated and playerdeactivated events on TheWorld.
  • Uses TheWorld.ismastersim to determine server-side initialization logic.
  • Registers a network variable via net_tinybyte tied to inst.GUID.
  • Calls event_server_data("lavaarena", "components/lavaarenamusic").master_postinit(...) on the master sim only.

Properties

PropertyTypeDefault ValueDescription
instEntityinst (constructor param)The entity this component is attached to.
_worldWorldTheWorldReference to the current world instance.
_soundemitterSoundEmitter or nilnilActive sound emitter used to play/kill music; assigned when a player activates.
_activatedplayerEntity or nilnilCache of the currently active arena player; used only for activation/deactivation tracking.
_levelplayingnumber or nilnilTracks the last music level that was played to detect changes.
_netvars.levelnet_tinybytenet_tinybyte(inst.GUID, "lavaarenamusic._netvars.level", "leveldirty")Network variable reflecting the arena's current level (value sourced from leveldirty events).

Main Functions

No public methods are exposed by this component — all functionality is event-driven and internal.

Events & Listeners

  • Listens for "playeractivated" on TheWorld → Triggers OnPlayerActivated(src, player).
  • Listens for "playerdeactivated" on TheWorld → Triggers OnPlayerDeactivated(src, player).
  • Listens for "leveldirty" on inst (only when a player is active) → Triggers OnLevelDirty(inst) to reload music if the level changed.