forked from danielchim/SIT.Tarkov.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.cs
More file actions
298 lines (250 loc) · 12.1 KB
/
Plugin.cs
File metadata and controls
298 lines (250 loc) · 12.1 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
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
using Aki.Custom.Patches;
using BepInEx;
using BepInEx.Configuration;
using Comfort.Common;
using EFT;
using SIT.Core.AkiSupport.Airdrops;
using SIT.Core.AkiSupport.Custom;
using SIT.Core.AkiSupport.Singleplayer;
using SIT.Core.AkiSupport.SITFixes;
using SIT.Core.Configuration;
using SIT.Core.Coop;
using SIT.Core.Core;
using SIT.Core.Core.Web;
using SIT.Core.Misc;
using SIT.Core.Other;
using SIT.Core.SP.Menus;
using SIT.Core.SP.PlayerPatches;
using SIT.Core.SP.PlayerPatches.Health;
using SIT.Core.SP.Raid;
using SIT.Core.SP.ScavMode;
using SIT.Tarkov.Core;
using SIT.Tarkov.Core.AI;
using System;
using UnityEngine.SceneManagement;
namespace SIT.Core
{
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
//[BepInDependency("com.spt-aki.core")] // Should probably be dependant on Aki right?
//IDK how to add a configuration file from PluginConfigSettings.cs. I can only add it here. Sorry! :P -w123456w30w
[BepInProcess("EscapeFromTarkov.exe")]
public class Plugin : BaseUnityPlugin
{
public static Plugin Instance;
public static PluginConfigSettings Settings { get; private set; }
private void Awake()
{
Instance = this;
Settings = new PluginConfigSettings(Logger, Config);
EnableCorePatches();
EnableSPPatches();
EnableCoopPatches();
OtherPatches.Run(Config, this);
Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
SceneManager.sceneLoaded += SceneManager_sceneLoaded;
}
private void EnableCorePatches()
{
var enabled = Config.Bind<bool>("SIT Core Patches", "Enable", true);
if (!enabled.Value) // if it is disabled. stop all SIT Core Patches.
{
Logger.LogInfo("SIT Core Patches has been disabled! Ignoring Patches.");
return;
}
// SIT Legal Game Checker
LegalGameCheck.LegalityCheck();
// File Checker
new ConsistencySinglePatch().Enable();
new ConsistencyMultiPatch().Enable();
// BattlEye
new BattlEyePatch().Enable();
new BattlEyePatchFirstPassRun().Enable();
new BattlEyePatchFirstPassUpdate().Enable();
// Web Requests
new SslCertificatePatch().Enable();
new UnityWebRequestPatch().Enable();
new TransportPrefixPatch().Enable();
new WebSocketPatch().Enable();
new TarkovTransportWSInstanceHookPatch().Enable();
new TarkovTransportHttpInstanceHookPatch().Enable();
}
private void EnableSPPatches()
{
var enabled = Config.Bind<bool>("SIT.SP", "Enable", true);
if (!enabled.Value) // if it is disabled. stop all SIT SP Patches.
{
Logger.LogInfo("SIT SP Patches has been disabled! Ignoring Patches.");
return;
}
//// --------- PMC Dogtags -------------------
new UpdateDogtagPatch().Enable();
//// --------- Player Init & Health -------------------
EnableSPPatches_PlayerHealth(Config);
//// --------- SCAV MODE ---------------------
new DisableScavModePatch().Enable();
//// --------- Airdrop -----------------------
new AirdropPatch().Enable();
//// --------- Screens ----------------
EnableSPPatches_Screens(Config);
//// --------- Progression -----------------------
EnableSPPatches_PlayerProgression();
//// --------------------------------------
// Bots
EnableSPPatches_Bots(Config);
new QTEPatch().Enable();
new TinnitusFixPatch().Enable();
try
{
BundleManager.GetBundles();
new EasyAssetsPatch().Enable();
new EasyBundlePatch().Enable();
}
catch (Exception ex)
{
Logger.LogError("// --- ERROR -----------------------------------------------");
Logger.LogError("Bundle System Failed!!");
Logger.LogError(ex.ToString());
Logger.LogError("// --- ERROR -----------------------------------------------");
}
new WavesSpawnScenarioInitPatch(Config).Enable();
new WavesSpawnScenarioMethodPatch().Enable();
}
private static void EnableSPPatches_Screens(BepInEx.Configuration.ConfigFile config)
{
//new OfflineRaidMenuPatch().Enable();
new OfflineSettingsScreenPatch().Enable();
new InsuranceScreenPatch().Enable();
new MatchmakerLocationScreen_DisableReadyButton_Patch().Enable();
new VersionLabelPatch(config).Enable();
//try
//{
// new MatchmakerLocationScreen_DisableLevelLock_Patch().Enable();
//}
//catch(Exception ex) { Plugin.Instance.Logger.LogError(ex.Message); }
new LighthouseBridgePatch().Enable();
new LighthouseTransmitterPatch().Enable();
}
private static void EnableSPPatches_PlayerProgression()
{
new OfflineSaveProfile().Enable();
new ExperienceGainFix().Enable();
}
private void EnableSPPatches_PlayerHealth(BepInEx.Configuration.ConfigFile config)
{
var enabled = config.Bind<bool>("SIT.SP", "EnableHealthPatches", true);
if (!enabled.Value)
return;
new Player_Init_SP_Patch().Enable();
new ChangeHealthPatch().Enable();
new ChangeHydrationPatch().Enable();
new ChangeEnergyPatch().Enable();
new OnDeadPatch(Config).Enable();
}
private static void EnableSPPatches_Bots(BepInEx.Configuration.ConfigFile config)
{
new CoreDifficultyPatch().Enable();
new BotDifficultyPatch().Enable();
new GetNewBotTemplatesPatch().Enable();
new BotSettingsRepoClassIsFollowerFixPatch().Enable();
new BossSpawnChancePatch().Enable();
var enabled = config.Bind<bool>("SIT.SP", "EnableBotPatches", true);
if (!enabled.Value)
return;
//new BotSelfEnemyPatch().Enable();
//new AkiSupport.Singleplayer.RemoveUsedBotProfilePatch().Enable();
//new AkiSupport.Custom.AddEnemyToAllGroupsInBotZonePatch().Enable();
//new CheckAndAddEnemyPatch().Enable();
//new AddEnemyPatch().Enable();
}
private void EnableCoopPatches()
{
Logger.LogInfo("Enabling Coop Patches");
CoopPatches.Run(Config);
}
public static GameWorld gameWorld { get; private set; }
private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
{
//GetPoolManager();
GetBackendConfigurationInstance();
if (Singleton<GameWorld>.Instantiated)
gameWorld = Singleton<GameWorld>.Instance;
}
private void GetBackendConfigurationInstance()
{
if (
PatchConstants.BackendStaticConfigurationType != null &&
PatchConstants.BackendStaticConfigurationConfigInstance == null)
{
PatchConstants.BackendStaticConfigurationConfigInstance = ReflectionHelpers.GetPropertyFromType(PatchConstants.BackendStaticConfigurationType, "Config").GetValue(null);
//Logger.LogInfo($"BackendStaticConfigurationConfigInstance Type:{ PatchConstants.BackendStaticConfigurationConfigInstance.GetType().Name }");
}
if (PatchConstants.BackendStaticConfigurationConfigInstance != null
&& PatchConstants.CharacterControllerSettings.CharacterControllerInstance == null
)
{
PatchConstants.CharacterControllerSettings.CharacterControllerInstance
= ReflectionHelpers.GetFieldOrPropertyFromInstance<object>(PatchConstants.BackendStaticConfigurationConfigInstance, "CharacterController", false);
Logger.LogInfo($"PatchConstants.CharacterControllerInstance Type:{PatchConstants.CharacterControllerSettings.CharacterControllerInstance.GetType().Name}");
}
if (PatchConstants.CharacterControllerSettings.CharacterControllerInstance != null
&& PatchConstants.CharacterControllerSettings.ClientPlayerMode == null
)
{
PatchConstants.CharacterControllerSettings.ClientPlayerMode
= ReflectionHelpers.GetFieldOrPropertyFromInstance<CharacterControllerSpawner.Mode>(PatchConstants.CharacterControllerSettings.CharacterControllerInstance, "ClientPlayerMode", false);
PatchConstants.CharacterControllerSettings.ObservedPlayerMode
= ReflectionHelpers.GetFieldOrPropertyFromInstance<CharacterControllerSpawner.Mode>(PatchConstants.CharacterControllerSettings.CharacterControllerInstance, "ObservedPlayerMode", false);
PatchConstants.CharacterControllerSettings.BotPlayerMode
= ReflectionHelpers.GetFieldOrPropertyFromInstance<CharacterControllerSpawner.Mode>(PatchConstants.CharacterControllerSettings.CharacterControllerInstance, "BotPlayerMode", false);
}
}
//private void GetPoolManager()
//{
// if (PatchConstants.PoolManagerType == null)
// {
// PatchConstants.PoolManagerType = PatchConstants.EftTypes.Single(x => ReflectionHelpers.GetAllMethodsForType(x).Any(x => x.Name == "LoadBundlesAndCreatePools"));
// Type generic = typeof(Singleton<>);
// Type[] typeArgs = { PatchConstants.PoolManagerType };
// ConstructedBundleAndPoolManagerSingletonType = generic.MakeGenericType(typeArgs);
// }
//}
//private 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 Task LoadBundlesAndCreatePools(ResourceKey[] resources)
// {
// try
// {
// if (BundleAndPoolManager == null)
// {
// PatchConstants.Logger.LogInfo("LoadBundlesAndCreatePools: BundleAndPoolManager is missing");
// return null;
// }
// var raidE = Enum.Parse(poolsCategoryType, "Raid");
// //PatchConstants.Logger.LogInfo("LoadBundlesAndCreatePools: raidE is " + raidE.ToString());
// var localE = Enum.Parse(assemblyTypeType, "Local");
// //PatchConstants.Logger.LogInfo("LoadBundlesAndCreatePools: localE is " + localE.ToString());
// var GenProp = ReflectionHelpers.GetPropertyFromType(PatchConstants.JobPriorityType, "General").GetValue(null, null);
// //PatchConstants.Logger.LogInfo("LoadBundlesAndCreatePools: GenProp is " + GenProp.ToString());
// return PatchConstants.InvokeAsyncStaticByReflection(
// LoadBundlesAndCreatePoolsMethod,
// BundleAndPoolManager
// , raidE
// , localE
// , resources
// , GenProp
// , (object o) => { PatchConstants.Logger.LogInfo("LoadBundlesAndCreatePools: Progressing!"); }
// , default(CancellationToken)
// );
// }
// catch (Exception ex)
// {
// PatchConstants.Logger.LogInfo("LoadBundlesAndCreatePools -- ERROR ->>>");
// PatchConstants.Logger.LogInfo(ex.ToString());
// }
// return null;
// }
}
}