93 lines
2.9 KiB
C#
93 lines
2.9 KiB
C#
using System.IO;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using BepInEx;
|
|
using BepInEx.Logging;
|
|
using UnityEngine;
|
|
using HarmonyLib;
|
|
using CUCoreLib.Helpers;
|
|
|
|
namespace VangersMusic;
|
|
|
|
[BepInPlugin(MOD_CUSTOM_ID, MOD_CUSTOM_NAME, MOD_CUSTOM_VER)]
|
|
[BepInDependency("net.cucorelib", BepInDependency.DependencyFlags.HardDependency)]
|
|
public class Plugin : BaseUnityPlugin
|
|
{
|
|
internal static new ManualLogSource Logger;
|
|
private readonly Harmony _harmony = new(MOD_CUSTOM_ID);
|
|
|
|
const string MOD_CUSTOM_ID = "org.rendo.vangersmusic";
|
|
const string MOD_CUSTOM_NAME = "VangersMusic";
|
|
const string MOD_CUSTOM_VER = "0.1";
|
|
|
|
private AudioClip _mainMenu;
|
|
private AudioClip[] _location;
|
|
private AudioClip _death;
|
|
private AudioClip _dying;
|
|
private AudioClip _infernals;
|
|
|
|
private SongList GenerateSongList(AudioClip forClip) {
|
|
SongList list = new SongList();
|
|
list.songs = new AudioClip[] {forClip};
|
|
return list;
|
|
}
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
// Plugin startup logic
|
|
Logger = base.Logger;
|
|
|
|
_mainMenu = AssetLoader.LoadEmbeddedAudio("Audio.MainTheme.wav");
|
|
|
|
_location = new AudioClip[] {
|
|
AssetLoader.LoadEmbeddedAudio("Audio.Fostral.wav"),
|
|
AssetLoader.LoadEmbeddedAudio("Audio.Necross.wav"),
|
|
AssetLoader.LoadEmbeddedAudio("Audio.Glorx.wav"),
|
|
AssetLoader.LoadEmbeddedAudio("Audio.Xplo.wav"),
|
|
AssetLoader.LoadEmbeddedAudio("Audio.OuterWorlds.wav"),
|
|
};
|
|
|
|
_death = AssetLoader.LoadEmbeddedAudio("Audio.Death.wav");
|
|
_dying = AssetLoader.LoadEmbeddedAudio("Audio.VangersForever.wav");
|
|
_infernals = AssetLoader.LoadEmbeddedAudio("Audio.Infernals.wav");
|
|
|
|
Logger.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");
|
|
StartCoroutine(OverrideMenuMusic());
|
|
StartCoroutine(OverrideMusicManager());
|
|
|
|
}
|
|
private void Start() {
|
|
PreRunScript.instance.menuSongs = new List<AudioClip>(){_mainMenu};
|
|
}
|
|
private IEnumerator OverrideMusicManager() {
|
|
while (true) {
|
|
Logger.LogInfo("Waiting for music player to load");
|
|
yield return new WaitUntil(()=> MusicManager.main != null);
|
|
Logger.LogInfo("Started overriding music");
|
|
|
|
MusicManager.main.deadClip = _death;
|
|
MusicManager.main.dyingClip = _dying;
|
|
MusicManager.main.biomeMusic = new SongList[] {
|
|
GenerateSongList(_location[0]),
|
|
GenerateSongList(_location[1]),
|
|
GenerateSongList(_location[2]),
|
|
GenerateSongList(_location[3]),
|
|
GenerateSongList(_location[4]),
|
|
};
|
|
foreach(var droneTrack in MusicManager.main.droneTracks) {
|
|
droneTrack.clip = _infernals;
|
|
}
|
|
Logger.LogInfo("Ended overriding music");
|
|
yield return new WaitUntil(()=> MusicManager.main == null);
|
|
}
|
|
}
|
|
private IEnumerator OverrideMenuMusic() {
|
|
while (true) {
|
|
yield return new WaitUntil(()=> PreRunScript.instance != null);
|
|
|
|
PreRunScript.instance.menuSongs = new List<AudioClip>(){_mainMenu};
|
|
yield return new WaitUntil(()=> PreRunScript.instance == null);
|
|
}
|
|
}
|
|
}
|