-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cs
More file actions
55 lines (42 loc) · 1.9 KB
/
Main.cs
File metadata and controls
55 lines (42 loc) · 1.9 KB
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
using System.Reflection;
using FieldInjector;
using MelonLoader.Logging;
using WeatherElectric.MelonUserData;
namespace WeatherElectric.VoidSpeaker;
public class Main : MelonMod
{
internal const string Name = "VoidSpeaker";
internal const string Description = "A music player for BONELAB";
internal const string Author = "Mabel Amber";
internal const string Company = "Weather Electric";
internal const string Version = "2.4.0";
internal const string DownloadLink = "https://thunderstore.io/c/bonelab/p/WeatherElectric/VoidSpeaker/";
private static bool _hasRanSetup;
internal static UserData Data;
internal static LoggerInstance Logger;
public override void OnInitializeMelon()
{
Logger = new LoggerInstance(LoggerInstance);
// would just use the Name field for this, but the old versions had a space and I don't want to make users move all their files
Data = new UserData("Void Speaker");
var bytes = HelperMethods.GetResourceBytes(Assembly.GetExecutingAssembly(), "WeatherElectric.VoidSpeaker.Resources.Default.mp3");
File.WriteAllBytes(Path.Combine(Data.Path, "Don't Fence Me In.mp3"), bytes);
Preferences.Init();
BoneMenu.Init();
MusicLoader.Load();
SerialisationHandler.Inject<MetadataListener>();
Hooking.OnLevelLoaded += OnLevelLoad;
#if DEBUG
Logger.Log("This is a debug build! It may be unstable!", LogLevel.Warning);
#endif
}
private static void OnLevelLoad(LevelInfo levelInfo)
{
if (_hasRanSetup) return;
_hasRanSetup = true;
var gameObj = new GameObject("MusicPlayer");
gameObj.AddComponent<MusicPlayer>();
// if i do this earlier, it does nothing, prob since unityengine hasnt loaded anything yet lol
if (Preferences.UseTagLib.Value) MusicList.CacheValues();
}
}