Looping sounds, competently. (#14709)

This commit is contained in:
Wowzewow (Wezzy)
2022-10-13 06:30:14 +08:00
committed by GitHub
parent 1628e5d2d6
commit 318df630a5
116 changed files with 349 additions and 34 deletions
@@ -46,7 +46,7 @@
working = hard_drive && processor_unit && damage < broken_damage && computer_use_power()
check_update_ui_need()
if(!is_portable && working && enabled && world.time > ambience_last_played_time + 30 SECONDS && prob(3))
if(looping_sound && working && enabled && world.time > ambience_last_played_time + 30 SECONDS && prob(3))
playsound(get_turf(src), /decl/sound_category/computerbeep_sound, 30, 1, 10, required_preferences = ASFX_AMBIENCE)
ambience_last_played_time = world.time
@@ -93,6 +93,8 @@
install_default_programs()
handle_verbs()
update_icon()
if(looping_sound)
soundloop = new(src, enabled)
initial_name = name
/obj/item/modular_computer/Destroy()
@@ -105,6 +107,7 @@
listening_objects -= src
STOP_PROCESSING(SSprocessing, src)
QDEL_NULL(listener)
QDEL_NULL(soundloop)
return ..()
/obj/item/modular_computer/CouldUseTopic(var/mob/user)
@@ -231,10 +234,14 @@
visible_message(SPAN_NOTICE("\The [src] shuts down."))
SSvueui.close_uis(src)
enabled = FALSE
if(looping_sound)
soundloop.stop(src)
update_icon()
/obj/item/modular_computer/proc/enable_computer(var/mob/user, var/ar_forced=FALSE)
enabled = TRUE
if(looping_sound)
soundloop.start(src)
update_icon()
// Autorun feature
@@ -15,6 +15,8 @@
var/last_battery_percent = 0 // Used for deciding if battery percentage has chandged
var/last_world_time = "00:00"
var/list/last_header_icons
var/datum/looping_sound/computer/soundloop // Looping sound for when the computer is on
var/looping_sound = TRUE // Whether or not this modular computer uses the looping sound. Also handles ambience beeps.
var/computer_emagged = FALSE // Whether the computer is emagged.
var/apc_powered = FALSE // Set automatically. Whether the computer used APC power last tick.
var/base_active_power_usage = 50 // Power usage when the computer is open (screen is active) and can be interacted with. Remember hardware can use power too.
@@ -30,7 +32,6 @@
var/doorcode = "smindicate"
var/hidden = FALSE
var/initial_name
var/is_portable = FALSE // Used to prevent the ambient beeps from playing.
// Modular computers can run on various devices. Each DEVICE (Laptop, Console, Tablet,..)
// must have it's own DMI file. Icon states must be called exactly the same in all files, but may look differently