mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2026-08-29 16:18:35 +01:00
Merge pull request #5791 from Neerti/looping_sounds
Adds Various Sounds, Looping Sound System
This commit is contained in:
@@ -22,12 +22,18 @@
|
||||
var/lastgen2 = 0
|
||||
var/effective_gen = 0
|
||||
var/lastgenlev = 0
|
||||
var/datum/looping_sound/generator/soundloop
|
||||
|
||||
/obj/machinery/power/generator/New()
|
||||
..()
|
||||
/obj/machinery/power/generator/Initialize()
|
||||
soundloop = new(list(src), FALSE)
|
||||
desc = initial(desc) + " Rated for [round(max_power/1000)] kW."
|
||||
spawn(1)
|
||||
reconnect()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/generator/Destroy()
|
||||
QDEL_NULL(soundloop)
|
||||
return ..()
|
||||
|
||||
//generators connect in dir and reverse_dir(dir) directions
|
||||
//mnemonic to determine circulator/generator directions: the cirulators orbit clockwise around the generator
|
||||
@@ -124,6 +130,13 @@
|
||||
stored_energy -= lastgen1
|
||||
effective_gen = (lastgen1 + lastgen2) / 2
|
||||
|
||||
// Sounds.
|
||||
if(effective_gen > (max_power * 0.05)) // More than 5% and sounds start.
|
||||
soundloop.start()
|
||||
soundloop.volume = LERP(1, 40, effective_gen / max_power)
|
||||
else
|
||||
soundloop.stop()
|
||||
|
||||
// update icon overlays and power usage only if displayed level has changed
|
||||
var/genlev = max(0, min( round(11*effective_gen / max_power), 11))
|
||||
if(effective_gen > 100 && genlev == 0)
|
||||
|
||||
@@ -88,9 +88,15 @@
|
||||
|
||||
var/debug = 0
|
||||
|
||||
var/datum/looping_sound/supermatter/soundloop
|
||||
|
||||
/obj/machinery/power/supermatter/Initialize()
|
||||
soundloop = new(list(src), TRUE)
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/supermatter/Destroy()
|
||||
. = ..()
|
||||
QDEL_NULL(soundloop)
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/supermatter/proc/explode()
|
||||
message_admins("Supermatter exploded at ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
||||
@@ -196,6 +202,11 @@
|
||||
if(grav_pulling)
|
||||
supermatter_pull(src)
|
||||
|
||||
if(power)
|
||||
// Volume will be 1 at no power, ~12.5 at ENERGY_NITROGEN, and 20+ at ENERGY_PHORON.
|
||||
// Capped to 20 volume since higher volumes get annoying and it sounds worse.
|
||||
soundloop.volume = min(round(power/10)+1, 20)
|
||||
|
||||
//Ok, get the air from the turf
|
||||
var/datum/gas_mixture/removed = null
|
||||
var/datum/gas_mixture/env = null
|
||||
|
||||
Reference in New Issue
Block a user