-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.cs
50 lines (42 loc) · 1.33 KB
/
Plugin.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
using System.Linq;
using System.Reflection;
using HarmonyLib;
using IPA;
using IPA.Config.Stores;
using OverswingCounter.Configuration;
using OverswingCounter.Harmony_Patches;
using UnityEngine;
using UnityEngine.SceneManagement;
using IPALogger = IPA.Logging.Logger;
namespace OverswingCounter {
[Plugin(RuntimeOptions.SingleStartInit)]
public class Plugin {
internal static Plugin Instance { get; private set; }
internal static IPALogger Log { get; private set; }
internal static Harmony Harmony;
internal static SaberManager SaberManager;
[Init]
public void Init(IPALogger logger, IPA.Config.Config config) {
Instance = this;
Log = logger;
Config.Instance = config.Generated<Config>();
Harmony = new Harmony("Kinsi55.BeatSaber.OverswingCounter");
}
[OnEnable]
public void OnEnable() {
SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
Harmony.PatchAll(Assembly.GetExecutingAssembly());
}
private void SceneManager_activeSceneChanged(Scene oldScene, Scene newScene) {
if(oldScene.name != "GameCore" && newScene.name != "GameCore")
return;
SaberManager = Resources.FindObjectsOfTypeAll<SaberManager>().First();
CutHandler.Clear();
}
[OnDisable]
public void OnDisable() {
SceneManager.activeSceneChanged -= SceneManager_activeSceneChanged;
Harmony.UnpatchSelf();
}
}
}