Add "indoor" and "night" fields for sound effects #55633
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
None
Purpose of change
Fixes #55095.
Sort of a follow up to #52308.
Describe the solution
Adds the JSON fields
"is_indoors"
and"is_night"
tosound_effect
type objects:Using the field
"is_indoors"
will make it so that the sound only plays if the player is indoors (true) or outdoors (false). If the field is omitted, the sound plays whether the player is indoors or not.Likewise for
"is_night"
, except for nighttime (true) and daytime (false).SFX search pattern optimization
Previously, each individual combination of sound parameters was queried individually. This meant that adding a new parameter effectively doubled the search space, growing exponentially. With just
variant
andseason
, the search space was("the # of sound effects" x 4) + 1
. Now thatis_indoors
andis_night
are added, the search space would grow tox 16
.I refactored the search pattern to grow linearly with the number of parameters, which improves the worst case from
O(2^n)
toO(n)
. A benefit of the new pattern is that the search order no longer matters (ex:season
can be queried beforevariant
without changing the results).Describe alternatives you've considered
I could have kept the original search pattern, but as explained above it just wasn't scalable.
Testing
Tested using the soundpack from Fris0uman's repository: https://github.com/Fris0uman/CDDA-Soundpacks
Additional context
TODO: