-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLAIMusicManager.cs
56 lines (52 loc) · 2.39 KB
/
LAIMusicManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using LobbyAppearanceImprovements.Scenes;
using RoR2;
namespace LobbyAppearanceImprovements
{
internal static class LAIMusicManager
{
public static MusicTrackOverride musicTrackOverride;
public static void Init()
{
On.RoR2.UI.CharacterSelectController.Awake += CharacterSelectController_Awake;
}
private static void CharacterSelectController_Awake(On.RoR2.UI.CharacterSelectController.orig_Awake orig, RoR2.UI.CharacterSelectController self)
{
musicTrackOverride = self.gameObject.AddComponent<MusicTrackOverride>();
musicTrackOverride.priority = 99999;
musicTrackOverride.track = UnityEngine.AddressableAssets.Addressables.LoadAssetAsync<MusicTrackDef>("RoR2/Base/Common/muLogbook").WaitForCompletion();
musicTrackOverride.enabled = false;
orig(self);
}
public static void OnSceneLoaded(LAIScene scene = null)
{
var choice = ConfigSetup.MusicChoice.Value;
scene ??= LAISceneManager.chosenScene;
LAILogging.LogMessage($"Changing music track to \"{choice}\"", ConfigSetup.LoggingStyle.ObscureSoOnlyDevSees);
if (choice.ToLower() == "default")
{
musicTrackOverride.enabled = false;
}
else if (choice.ToLower() == "auto")
{
musicTrackOverride.enabled = true;
LAILogging.LogMessage($"Changing music track to {scene}'s \"{scene.MusicTrackName}\"", ConfigSetup.LoggingStyle.ObscureSoOnlyDevSees);
var musicTrack = MusicTrackCatalog.FindMusicTrackDef(scene.MusicTrackName);
if (musicTrack == null) musicTrackOverride.enabled = false;
musicTrackOverride.track = musicTrack;
}
else
{
musicTrackOverride.enabled = true;
var musicTrack = MusicTrackCatalog.FindMusicTrackDef(choice);
if (musicTrack == null)
{
//musicTrack = LAIScene.defaultMusicTrackDef;
LAILogging.LogWarning("Couldn't find music choice \"{choice}\", defaulting...", ConfigSetup.LoggingStyle.ObscureSoOnlyDevSees);
musicTrackOverride.enabled = false;
return;
}
musicTrackOverride.track = musicTrack;
}
}
}
}