-
Notifications
You must be signed in to change notification settings - Fork 3
/
Plugin.cs
311 lines (258 loc) · 11.5 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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
using BepInEx;
using Comfort.Common;
using EFT;
using MTGA.Menus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine.SceneManagement;
using MTGA.Utilities.Bundles;
using MTGA.Patches.FileChecker;
using MTGA.Patches.AntiCheat;
using MTGA.Patches.Bundles;
using MTGA.Patches.Raid.Menus;
using MTGA.Patches.Raid.Fixes;
using MTGA.Patches.Player.Health;
using MTGA.Patches.Player.Fixes;
using MTGA.Patches.ScavMode;
using MTGA.Patches.Raid.Airdrops;
using MTGA.Patches.AI.Fixes;
using MTGA.Patches.AI;
using MTGA.Patches.Menus;
using MTGA.Patches.Player;
using MTGA.Patches.Raid.FromServer;
using MTGA.Patches.Misc;
using MTGA.Patches.Hideout;
namespace MTGA
{
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
public class Plugin : BaseUnityPlugin
{
void Awake()
{
try
{
PatchConstants.GetBackendUrl();
new Utilities.Core.Request();
// - TURN OFF FileChecker and BattlEye -----
new ConsistencySinglePatch().Enable();
new ConsistencyMultiPatch().Enable();
new BattlEyePatch().Enable();
new SslCertificatePatch().Enable();
new UnityWebRequestPatch().Enable();
// - Loading Bundles from Server. Working Aki version with some tweaks by me -----
var enableBundles = Config.Bind("Bundles", "Enable", true);
if (enableBundles.Value)
{
//BundleSetup.Init();
BundleManager.GetBundles(); // Crash happens here
new EasyAssetsPatch().Enable();
new EasyBundlePatch().Enable();
}
new QTE().Enable();
// --------- Container Id Debug ------------
var enableLootableContainerDebug = Config.Bind("Debug", "Lootable Container Debug", false, "Description: Print Lootable Container information");
if (enableLootableContainerDebug.Value)
new LootableContainerInteractPatch().Enable();
// --------- PMC Dogtags -------------------
new UpdateDogtagPatch().Enable();
// --------- On Dead -----------------------
new OnDeadPatch(Config).Enable();
// --------- Player Init -------------------
new PlayerInitPatch().Enable();
// --------- SCAV MODE ---------------------
new DisableScavModePatch().Enable();
// --------- Airdrop (THANKS TO AKI) -----------------------
new AirdropPatch().Enable();
new AirdropFlarePatch().Enable();
// --------- AI -----------------------
var enabledMTGAAISystem = Config.Bind("AI", "AI System", true, "Description: Enable MTGA AI???????");
if (enabledMTGAAISystem.Value)
{
new IsPlayerEnemyPatch().Enable();
new IsPlayerEnemyByRolePatch().Enable();
new BotBrainActivatePatch().Enable();
new BotSelfEnemyPatch().Enable();
}
new RemoveUsedBotProfile().Enable();
// --------- Matchmaker ----------------
new DisableReadyButtonOnFirstScreen().Enable();
// -------------------------------------
// Progression
new OfflineSaveProfile().Enable();
new ExperienceGainFix().Enable();
new OfflineDisplayProgressPatch().Enable();
// -------------------------------------
// Quests
new ItemDroppedAtPlace_Beacon().Enable();
new MidRaidQuestChangePatch().Enable();
// -------------------------------------
// Raid
new LoadBotDifficultyFromServer().Enable();
new ForceMuteVoIP().Enable();
new SkipLocationLootCaching().Enable();
// --------------------------------------
// Health stuff
new ReplaceInPlayer().Enable();
new ChangeHealthPatch().Enable();
new ChangeEnergyPatch().Enable();
new ChangeHydrationPatch().Enable();
new LootContainerInitPatch().Enable();
new CollectLootPointsDataPatch().Enable();
new InstantItemsMoving().Enable();
// Plugin startup logic
Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
SceneManager.sceneLoaded += SceneManager_sceneLoaded;
SceneManager.sceneUnloaded += SceneManager_sceneUnloaded;
SetupMoreGraphicsMenuOptions();
}
catch (Exception ex)
{
Logger.LogError($"{GetType().Name}: {ex}");
throw;
}
}
void SceneManager_sceneUnloaded(Scene arg0)
{
}
GameWorld gameWorld = null;
public void GetGameWorld()
{
gameWorld = Singleton<GameWorld>.Instance;
}
void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
{
GetPoolManager();
GetGameWorld();
}
public void SetupMoreGraphicsMenuOptions()
{
Logger.LogInfo("Adjusting sliders for Overall Visibility and LOD Quality");
var TypeOfGraphicsSettingsTab = typeof(EFT.UI.Settings.GraphicsSettingsTab);
var readOnlyCollection_0 = TypeOfGraphicsSettingsTab.GetField(
"readOnlyCollection_0",
BindingFlags.Static |
BindingFlags.NonPublic
);
var readOnlyCollection_3 = TypeOfGraphicsSettingsTab.GetField(
"readOnlyCollection_3",
BindingFlags.Static |
BindingFlags.NonPublic
);
List<float> overallVisibility = new();
for (int i = 0; i <= 11; i++)
{
overallVisibility.Add(400 + (i * 50));
}
for (int i = 0; i <= 4; i++)
{
overallVisibility.Add(1000 + (i * 500));
}
List<float> lodQuality = new();
for (int i = 0; i <= 9; i++)
{
lodQuality.Add((float)(2 + (i * 0.25)));
}
var Collection_0 = Array.AsReadOnly<float>(overallVisibility.ToArray());
var Collection_3 = Array.AsReadOnly<float>(lodQuality.ToArray());
readOnlyCollection_0.SetValue(null, Collection_0);
readOnlyCollection_3.SetValue(null, Collection_3);
Logger.LogInfo("Adjusted sliders for Overall Visibility and LOD Quality");
}
void GetPoolManager()
{
if (PatchConstants.PoolManagerType == null)
{
PatchConstants.PoolManagerType = PatchConstants.EftTypes.Single(x => PatchConstants.GetAllMethodsForType(x).Any(x => x.Name == "LoadBundlesAndCreatePools"));
//Logger.LogInfo($"Loading PoolManagerType:{ PatchConstants.PoolManagerType.FullName}");
//Logger.LogInfo($"Getting PoolManager Instance");
Type generic = typeof(Comfort.Common.Singleton<>);
Type[] typeArgs = { PatchConstants.PoolManagerType };
ConstructedBundleAndPoolManagerSingletonType = generic.MakeGenericType(typeArgs);
//Logger.LogInfo(PatchConstants.PoolManagerType.FullName);
//Logger.LogInfo(ConstructedBundleAndPoolManagerSingletonType.FullName);
}
}
Type ConstructedBundleAndPoolManagerSingletonType { get; set; }
public static object BundleAndPoolManager { get; set; }
public static Type PoolsCategoryType { get; set; }
public static Type AssemblyTypeType { get; set; }
public static MethodInfo LoadBundlesAndCreatePoolsMethod { get; set; }
public static async Task LoadBundlesAndCreatePoolsAsync(ResourceKey[] resources)
{
try
{
if (BundleAndPoolManager == null)
{
PatchConstants.Logger.LogInfo("LoadBundlesAndCreatePoolsAsync: BundleAndPoolManager is missing");
return;
}
var poolManager = Singleton<PoolManager>.Instance;
await poolManager.LoadBundlesAndCreatePools(
PoolManager.PoolsCategory.Raid, PoolManager.AssemblyType.Local, resources, JobPriority.General, null, CancellationToken.None);
}
catch (Exception ex)
{
PatchConstants.Logger.LogError("LoadBundlesAndCreatePoolsAsync - ERROR");
PatchConstants.Logger.LogError(ex.ToString());
// You may choose to rethrow the exception here if needed.
}
}
public static Task LoadBundlesAndCreatePools(ResourceKey[] resources)
{
try
{
if (BundleAndPoolManager == null)
{
PatchConstants.Logger.LogInfo("LoadBundlesAndCreatePools: BundleAndPoolManager is missing");
return null;
}
var raidEnum = Enum.Parse(PoolsCategoryType, "Raid");
var localEnum = Enum.Parse(AssemblyTypeType, "Local");
var generalProp = PatchConstants.GetPropertyFromType(PatchConstants.JobPriorityType, "General").GetValue(null, null);
return PatchConstants.InvokeAsyncStaticByReflection(
LoadBundlesAndCreatePoolsMethod,
BundleAndPoolManager,
raidEnum,
localEnum,
resources,
generalProp
);
}
catch (Exception ex)
{
PatchConstants.Logger.LogInfo("LoadBundlesAndCreatePools -- ERROR ->>>");
PatchConstants.Logger.LogInfo(ex.ToString());
}
return null;
}
void FixedUpdate()
{
if (PatchConstants.PoolManagerType != null && ConstructedBundleAndPoolManagerSingletonType != null && BundleAndPoolManager == null)
{
BundleAndPoolManager = PatchConstants.GetPropertyFromType(ConstructedBundleAndPoolManagerSingletonType, "Instance").GetValue(null, null); //Activator.CreateInstance(PatchConstants.PoolManagerType);
if (BundleAndPoolManager != null)
{
PoolsCategoryType = BundleAndPoolManager.GetType().GetNestedType("PoolsCategory");
if (PoolsCategoryType != null)
{
Logger.LogInfo(PoolsCategoryType.FullName);
}
AssemblyTypeType = BundleAndPoolManager.GetType().GetNestedType("AssemblyType");
if (AssemblyTypeType != null)
{
Logger.LogInfo(AssemblyTypeType.FullName);
}
LoadBundlesAndCreatePoolsMethod = PatchConstants.GetMethodForType(BundleAndPoolManager.GetType(), "LoadBundlesAndCreatePools");
if (LoadBundlesAndCreatePoolsMethod != null)
{
Logger.LogInfo(LoadBundlesAndCreatePoolsMethod.Name);
}
}
}
}
}
}