mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-24 21:48:39 +01:00
Light dreaming refactor + new dream (#78996)
## About The Pull Request Makes it so new dream types can be more easily added to the game with effects within them beyond just some text being displayed if you want. I added a dream that plays a random sound file available in the game files to demonstrate how it's used. Mainly I wanted this out of the way for another thing I'm working on. I also made it so if the sound subsystem fails to reserve a channel it throws a runtime since this happening is likely always going to result in a bug, like it did while I was testing this. ## Changelog 🆑 add: New dream that plays sound at you /🆑
This commit is contained in:
@@ -23,8 +23,12 @@ SUBSYSTEM_DEF(sounds)
|
||||
/// higher reserve position - decremented and incremented to reserve sound channels, anything above this is reserved. The channel at this index is the highest unreserved channel.
|
||||
var/channel_reserve_high
|
||||
|
||||
/// All valid sound files in the sound directory
|
||||
var/list/all_sounds
|
||||
|
||||
/datum/controller/subsystem/sounds/Initialize()
|
||||
setup_available_channels()
|
||||
find_all_available_sounds()
|
||||
return SS_INIT_SUCCESS
|
||||
|
||||
/datum/controller/subsystem/sounds/proc/setup_available_channels()
|
||||
@@ -37,6 +41,26 @@ SUBSYSTEM_DEF(sounds)
|
||||
channel_random_low = 1
|
||||
channel_reserve_high = length(channel_list)
|
||||
|
||||
/datum/controller/subsystem/sounds/proc/find_all_available_sounds()
|
||||
all_sounds = list()
|
||||
// Put more common extensions first to speed this up a bit
|
||||
var/static/list/valid_file_extensions = list(
|
||||
".ogg",
|
||||
".wav",
|
||||
".mid",
|
||||
".midi",
|
||||
".mod",
|
||||
".it",
|
||||
".s3m",
|
||||
".xm",
|
||||
".oxm",
|
||||
".raw",
|
||||
".wma",
|
||||
".aiff",
|
||||
)
|
||||
|
||||
all_sounds = pathwalk("sound/", valid_file_extensions)
|
||||
|
||||
/// Removes a channel from using list.
|
||||
/datum/controller/subsystem/sounds/proc/free_sound_channel(channel)
|
||||
var/text_channel = num2text(channel)
|
||||
@@ -78,7 +102,7 @@ SUBSYSTEM_DEF(sounds)
|
||||
CRASH("Attempted to reserve sound channel without datum using the managed proc.")
|
||||
.= reserve_channel()
|
||||
if(!.)
|
||||
return FALSE
|
||||
CRASH("No more sound channels can be reserved")
|
||||
var/text_channel = num2text(.)
|
||||
using_channels[text_channel] = D
|
||||
LAZYINITLIST(using_channels_by_datum[D])
|
||||
|
||||
Reference in New Issue
Block a user