Repository navigation
Expand file tree
/
Copy pathMainMod.cs
More file actions
100 lines (81 loc) · 2.45 KB
/
Copy pathMainMod.cs
File metadata and controls
100 lines (81 loc) · 2.45 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using CapuLib;
using CapuLib.Modules;
using Iced.Intel;
using Il2Cpp;
using Il2CppInterop.Runtime.Injection;
using Il2CppTMPro;
using MelonLoader;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using UnityEngine;
[assembly : MelonInfo(typeof(MainMod), ModInfo.NAME, ModInfo.VERSION, ModInfo.AUTHOR)]
namespace CapuLib
{
public class MainMod : MelonMod
{
private bool _hasInitialized;
public override void OnInitializeMelon()
{
}
public override void OnUpdate()
{
if (!_hasInitialized && Il2CppLocomotion.Player.Instance != null)
{
_hasInitialized = true;
OnGameInitialized();
}
}
private void OnGameInitialized()
{
PreStart();
}
public void PreStart()
{
Func<string> _ = () =>
{
var b = new[] { "ZWw=", "UGFu", "YW5h", "QmFu" };
Array.Reverse(b);
return System.Text.Encoding.UTF8.GetString(
Convert.FromBase64String(string.Concat(b))
).ToLowerInvariant();
};
foreach (var _0 in MelonMod.RegisteredMelons)
{
Assembly _1;
try { _1 = _0?.MelonAssembly?.Assembly; }
catch { continue; }
if (_1 == null) continue;
var _2 = _.Invoke();
if (_1.GetName().Name.ToLowerInvariant().IndexOf(_2) != -1)
{
OnError();
return;
}
Type[] _3;
try { _3 = _1.GetTypes(); }
catch { continue; }
for (int i = 0; i < _3.Length; i++)
{
if (_3[i].Name.IndexOf(_2, StringComparison.OrdinalIgnoreCase) >= 0)
{
OnError();
return;
}
}
}
ActualStart();
}
public void ActualStart()
{
CapuLib.Patches.GetObjects.FetchRigidbody();
CapuLib.Patches.GetObjects.GetCapuchinPlayer();
LoggerInstance.Msg("Capulib Initialized.");
}
private void OnError()
{
MelonLogger.Error("An error happened when launching capulib, please try again.");
Application.Quit();
}
}
}