-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.cs
44 lines (40 loc) · 1.79 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
using AiDisabler.Config;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Il2CppInterop.Runtime.Injection;
using UnityEngine;
namespace AiDisabler {
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
public class Plugin : BasePlugin {
internal new static ManualLogSource Log;
static public DisablerConfig disablerConfig;
static public ConfigEntry<bool> configPrintAi;
public override void Load() {
Log = base.Log;
configPrintAi = Config.Bind("General.Toggles", "PrintOutAi", true, "Whether to print out the Ai when it's loaded/spawned.");
disablerConfig = new DisablerConfig();
Log.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");
//InjectInGameObject();
Patches.Patcher.DoPatching();
}
private void InjectInGameObject() {
bool isEnabled = false;
try {
ClassInjector.RegisterTypeInIl2Cpp<AiDisabler.AiDisablerBehaviour>();
GameObject val = new GameObject("AiDisabler");
val.AddComponent<AiDisabler.AiDisablerBehaviour>();
((UnityEngine.Object)val).hideFlags = (HideFlags)61;
UnityEngine.Object.DontDestroyOnLoad((UnityEngine.Object)val);
} catch {
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(48, 0, out isEnabled);
if (isEnabled) {
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("FAILED to Register Il2Cpp Type: AiDisablerBehaviour!");
}
Log.LogError(val2);
}
}
}
}