Files
burrow-server/swf-src/SBSound.as
T
Burrowdev 33f56074a4 feat: discord linking, @tags, music and sfx sliders, required device ids
- Discord: the account page links a player's Discord account through
  Discord's sign-in (lib/discord.js); only linked names are shown on cards
  (typed ones are cleared). A bot keeps the Server Booster badge on linked
  accounts that boost. The game tells the client where the player is, for
  the client's Discord rich presence (flashvars discordAppId).
- @username tags in chat, chat balloons and wall posts: only real players'
  names (asked of the server, "xmn"), names with spaces too, drawn on a
  blue box; a click opens the player's card.
- Settings: separate Music and SFX volume sliders for the old one.
- Device ids required: a launcher that sends none (before 1.3.0) is told
  at the game's login "Your client is outdated. Update at
  https://burrow.moe/download". AJ_REQUIRE_DEVICE=0 turns it off.
- Panels: clear a player's Jammer Wall posts; turning away masterpieces
  and player items asks first.
- Item Giver: negative colour ids (the same colour written signed).
- buildVersion 71; the client rebuilt with Snipzil's sitting fix.
2026-10-18 19:35:51 +03:00

185 lines
4.2 KiB
ActionScript

package com.sbi.corelib.audio
{
import flash.events.Event;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.utils.Dictionary;
public class SBSound
{
public var paused:Boolean = false;
public var playVolume:Number = 1;
public var s:Sound;
public var sc:SoundChannel;
private var _soundPlaying:Boolean;
private var _onSoundComplete:Function;
// every sound effect, for the sound effects setting (AJClient.sfxLevel):
// each plays at the volume the game gives it times that setting, and
// again so when the setting changes (refreshAll).
private static var _all:Dictionary = new Dictionary(true);
private var _setVolume:Number = 1;
public static function refreshAll() : void
{
var _loc1_:Object = null;
var _loc2_:SBSound = null;
for(_loc1_ in _all)
{
_loc2_ = _loc1_ as SBSound;
if(_loc2_ != null && _loc2_.sc != null)
{
_loc2_.setTransformVolume(_loc2_._setVolume);
}
}
}
public function SBSound(param1:Class, param2:Boolean = true, param3:Number = 1)
{
super();
_all[this] = true;
s = new param1();
volume = param3;
if(param2)
{
play();
}
else
{
stop();
}
SBAudio.addSound(this);
}
public function play(param1:Number = 0, param2:int = 0, param3:SoundTransform = null, param4:Function = null) : void
{
if(param2 == -1)
{
param2 = 2147483647;
}
if(s == null)
{
return;
}
sc = s.play(param1,param2,param3);
if(sc == null)
{
return;
}
_soundPlaying = true;
_onSoundComplete = param4;
sc.addEventListener("soundComplete",soundStoppedHandler,false,0,true);
setTransformVolume(playVolume);
}
public function destroy() : void
{
stop();
sc = null;
s = null;
SBAudio.removeSound(this);
}
// the game's own volume for it, before the sound effects setting
public function get volume() : Number
{
return sc ? _setVolume : -1;
}
public function set volume(param1:Number) : void
{
playVolume = param1;
if(sc)
{
setTransformVolume(param1);
}
}
public function get isPlaying() : Boolean
{
return _soundPlaying;
}
public function togglePause() : void
{
if(paused)
{
unpause();
}
else
{
pause();
}
}
public function pause() : void
{
if(sc && !paused)
{
sc.stop();
paused = true;
_soundPlaying = false;
}
}
public function unpause() : void
{
if(s && sc && paused)
{
sc = s.play(sc.position);
if(sc == null)
{
return;
}
_soundPlaying = true;
sc.addEventListener("soundComplete",soundStoppedHandler,false,0,true);
setTransformVolume(playVolume);
paused = false;
}
}
public function stop() : void
{
if(sc)
{
sc.stop();
}
paused = false;
_soundPlaying = false;
}
private function setTransformVolume(param1:Number) : void
{
_setVolume = param1;
var _loc2_:SoundTransform = sc.soundTransform;
if(SBAudio.isMusicMuted)
{
_loc2_.volume = 0;
}
else
{
_loc2_.volume = param1 * AJClient.sfxLevel();
}
sc.soundTransform = _loc2_;
}
private function soundStoppedHandler(param1:Event) : void
{
_soundPlaying = false;
if(_onSoundComplete != null)
{
_onSoundComplete();
}
}
}
}