This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMainMod.cs
123 lines (116 loc) · 4.81 KB
/
MainMod.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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using BepInEx;
using BepInEx.Configuration;
using BepInEx.IL2CPP;
using HarmonyLib;
using System.IO;
using UnhollowerRuntimeLib;
using UnityEngine;
using Item;
namespace BmMod
{
[BepInPlugin("me.bmm.plugin.GunfireReborn", "Bmm GunfireReborn Plugin", "1.0")]
public class MainMod : BasePlugin
{
public static new BepInEx.Logging.ManualLogSource Log { get; } = BepInEx.Logging.Logger.CreateLogSource("BmMod");
readonly Harmony Harmony = new Harmony("me.bmm.plugin.GunfireReborn");
//配置文件绑定
public static new ConfigFile Config = new ConfigFile(Path.Combine(Paths.ConfigPath, "BmMod.cfg"), true);
public static ConfigEntry<int> SuperRunSet = Config.Bind("config", "SuperRunSet", BmMod.SuperRunSet);
public static ConfigEntry<float> AimBotSightRange = Config.Bind("config", "AimBotSightRange", BmMod.AimBotSightRange);
public static ConfigEntry<bool> AimBotMagneticState = Config.Bind("config", "AimBotMagneticState", BmMod.AimBotMagneticState);
public static ConfigEntry<bool> AimBotForceState = Config.Bind("config", "AimBotForceState", BmMod.AimBotForceState);
public static ConfigEntry<string> AimBotKeyConfig = Config.Bind("config", "AimBotKeyConfig", BoolArray2String(BmMod.AimBotKeyConfig));
public static ConfigEntry<float> BulletSpeedNum = Config.Bind("config", "BulletSpeedNum", BmMod.BulletSpeedNum);
public static ConfigEntry<int> AttSpeedNum = Config.Bind("config", "AttSpeedNum", BmMod.AttSpeedNum);
public static ConfigEntry<float> AimBotForceDistance = Config.Bind("config", "AimBotForceDistance", BmMod.AimBotForceDistance);
public static ConfigEntry<bool> AimBotShieldState = Config.Bind("config", "AimBotShieldState", BmMod.AimBotShieldState);
public override void Load()
{
//配置内容传递给BmMod
BmMod.SuperRunSet = SuperRunSet.Value;
BmMod.AimBotSightRange = AimBotSightRange.Value;
BmMod.AimBotMagneticState = AimBotMagneticState.Value;
BmMod.AimBotForceState = AimBotForceState.Value;
BmMod.AimBotKeyConfig = String2BoolArray(AimBotKeyConfig.Value);
BmMod.BulletSpeedNum = BulletSpeedNum.Value;
BmMod.AttSpeedNum = AttSpeedNum.Value;
BmMod.AimBotForceDistance = AimBotForceDistance.Value;
BmMod.AimBotShieldState = AimBotShieldState.Value;
ClassInjector.RegisterTypeInIl2Cpp<BmMod>();
Harmony.PatchAll();
}
//保存配置
public static void SaveConfig()
{
SuperRunSet.Value = BmMod.SuperRunSet;
AimBotSightRange.Value = BmMod.AimBotSightRange;
AimBotMagneticState.Value = BmMod.AimBotMagneticState;
AimBotForceState.Value = BmMod.AimBotForceState;
AimBotKeyConfig.Value = BoolArray2String(BmMod.AimBotKeyConfig);
BulletSpeedNum.Value = BmMod.BulletSpeedNum;
AttSpeedNum.Value = BmMod.AttSpeedNum;
AimBotForceDistance.Value = BmMod.AimBotForceDistance;
AimBotShieldState.Value = BmMod.AimBotShieldState;
Config.Save();
}
public static string BoolArray2String(bool[] arg)
{
return string.Join(",", arg);
}
public static bool[] String2BoolArray(string arg)
{
string[] Str = arg.Split(',');
bool[] Res = new bool[Str.Length];
for (int i = 0; i < Str.Length; i++)
{
if (Str[i] == "True")
Res[i] = true;
else
Res[i] = false;
}
return Res;
}
}
//注入脚本
[HarmonyPatch(typeof(MainManager), "Start")]
class Inject
{
static void Prefix()
{
GameObject GameObject = new GameObject("BmMod");
GameObject.AddComponent<BmMod>();
Object.DontDestroyOnLoad(GameObject);
}
}
//不耗子弹
[HarmonyPatch(typeof(WeaponPerformanceObj), "WeaponConsumeBullet")]
class WeaponConsumeBullet
{
static bool Prefix() { return !BmMod.NoBulletConsumeState; }
}
[HarmonyPatch(typeof(WeaponPerformanceObj), "ConsumeBulletFromMag")]
class ConsumeBulletFromMag
{
static bool Prefix() { return !BmMod.NoBulletConsumeState; }
}
[HarmonyPatch(typeof(WeaponPerformanceObj), "ConsumeBulletFromPack")]
class ConsumeBulletFromPack
{
static bool Prefix() { return !BmMod.NoBulletConsumeState; }
}
//无后座
[HarmonyPatch(typeof(CameraCtrl), "Recoil")]
class NoRecoil
{
static bool Prefix() { return !BmMod.NoRecoilState; }
}
//测试
//[HarmonyPatch(typeof(), "")]
//class test
//{
// static bool Prefix()
// {
// return true;
// }
//}
}