STSharedAudioLib
A standalone Component storing Lists of AudioClips to access from different mods.
By SimonTendo
Date uploaded | 5 months ago |
Version | 0.0.1 |
Download link | SimonTendo-STSharedAudioLib-0.0.1.zip |
Downloads | 775 |
Dependency string | SimonTendo-STSharedAudioLib-0.0.1 |
This mod requires the following mods to function
BepInEx-BepInExPack
BepInEx pack for Mono Unity games. Preconfigured and ready to use.
Preferred version: 5.4.2100README
The Library
Introduction:
Have multiple mods that add AudioClips to an object that only takes one AudioClip at a time?
This library might be able to help bridge the gap between mods, by letting you add a component with lists of AudioClips to the object that can then be accessed from any mod that references this library's assembly. It also comes with a handful of methods to check for this library's SharedAudioComponent component, AudioList ScriptableObject, and to browse or shuffle through any given AudioList's weightedClipsList.
Simply follow the steps and methods listed under Usage and implement it with your own mods' code, and get the ability to patch multiple AudioClips to features that would otherwise only be able to store one AudioClip at a time.
Usage
I will be using the Thunderstore listing's Wiki page to keep the information about this library and its usage up-to-date, so I recommend looking there first. But there is also a notepad file called 'USAGE' in the package for this library, although that will only update every time the package itself gets updated (nor am I certain if it will show up on the Thunderstore listing).
Creation:
- I primarily made this for myself because I couldn't find a readily-available way of doing such a thing for my own mods after searching through the Lethal Company Thunderstore and its APIs & Libraries section.
- I also made it as an exercise to see if I'd learned programming well enough to be able to do something like this, to potentially demonstrate it professionally.
- So if I accidentally reinvented the wheel by making something someone else already had, then my apologies. I really was unable to find such a thing for a time, but I do not intend to freeload on or copy other people's work.
- And by no means did I intend to deliver a professional fool-proof solution to fill a gap in the market. I just wanted to get this kind of end-result and see if I could do it, so I'm sorry if this isn't as clear or efficient as it could be. But there will probably be updates to stamp out bugs, bring quality-of-life changes, or anything that would require attention.
- And I do realize this library is far more complicated to use than the simplicity of mods such as Lethal Company's CustomSounds mod made by Clementinise, that just add or replace sounds by dropping a file into an easily accessible folder. But, again, I made this to solve my own problems, and practice my own skills, my apologies.
- But by all means, feel free to make use of this library if you'd like to expand your own mods. If anyone wants to use it for other Unity games, I hope nobody then claims it then as their own. I just hope this kind of tool can help expand the possibilities for creating cool mods and modpacks, both for myself and for others.
Credits:
- My knowledge of libraries and coding were based on examples I saw and worked with while modding Lethal Company, made by Zeekerss (https://store.steampowered.com/search/?developer=Zeekerss), and using a library for that game called LethalLib made by Evaisa (https://github.com/EvaisaDev).
- Both of these also indirectly taught me about things such as default parameters and method overloading, so without those examples a lot of quality-of-life things in this library would not have happened.
- I also got help with a handful of methods and their implementation from a programmer at my college, and even though he probably won't see this, I'd still like to extend my thanks to him.
- Development of this library started with getting all loaded PluginInfo's from BepInEx's Chainloader, which I learned through a combination of decompiling the mod LethalExpansion and this websearch (https://github.com/BepInEx/BepInEx/discussions/320), so I would like to thank these people too for their indirect help.
- I found a method of removing elements from a list while searching it from this article (https://stackoverflow.com/questions/7340757/c-sharp-list-removing-items-while-looping-iterating), and would like to thank the people who provided the answer.
- And thank you for checking out or even downloading this library!
CHANGELOG
v0.0.1
- Release
v0.0.2
- Added method AudioListContainsAudioClip()
- This will check if the given AudioList, SharedAudioComponent, or GameObject contains the given AudioClip
- Optionally, a weight integer can be given to check if the found AudioClip's AudioClipWithWeight also has the given weight
- When performing AudioListGetRandom() or AudioListGetRandomByWeight() and passing a GameObject to search, the random AudioList will now also be picked from a random SharedAudioComponent on the GameObject instead of the first found SharedAudioComponent, in case the GameObject contains multiple SharedAudioComponents
- Fixed minor error that could occur with the GetRandomByWeight() methods in case the given AudioClips or AudioLists had no weight
- Included a LICENSE markdown file