-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathPatchConstants.cs
615 lines (521 loc) · 26.8 KB
/
PatchConstants.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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using BepInEx.Logging;
using Comfort.Common;
using EFT;
using EFT.Communications;
using FilesChecker;
using Newtonsoft.Json;
using SIT.A.Tarkov.Core.Web;
using SIT.Tarkov.Core.AI;
using UnityEngine;
namespace SIT.Tarkov.Core
{
public static class PatchConstants
{
public static BindingFlags PrivateFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly;
private static Type[] _eftTypes;
public static Type[] EftTypes
{
get
{
if( _eftTypes == null)
{
_eftTypes = typeof(AbstractGame).Assembly.GetTypes().OrderBy(t => t.Name).ToArray();
}
return _eftTypes;
}
}
public static Type[] FilesCheckerTypes { get; private set; }
public static Type LocalGameType { get; private set; }
public static Type ExfilPointManagerType { get; private set; }
public static Type BackendInterfaceType { get; private set; }
public static Type SessionInterfaceType { get; private set; }
public static Type StartWithTokenType { get; private set; }
public static Type PoolManagerType { get; set; }
public static Type JobPriorityType { get; set; }
public static Type PlayerInfoType { get; set; }
public static Type PlayerCustomizationType { get; set; }
public static Type SpawnPointSystemInterfaceType { get; set; }
public static Type SpawnPointArrayInterfaceType { get; set; }
public static Type SpawnPointSystemClassType { get; set; }
public static Type BackendStaticConfigurationType { get; set; }
public static object BackendStaticConfigurationConfigInstance { get; set; }
public static class CharacterControllerSettings
{
public static object CharacterControllerInstance { get; set; }
public static CharacterControllerSpawner.Mode ObservedPlayerMode { get; set; }
public static CharacterControllerSpawner.Mode ClientPlayerMode { get; set; }
public static CharacterControllerSpawner.Mode BotPlayerMode { get; set; }
}
/// <summary>
/// A Key/Value dictionary of storing & obtaining an array of types by name
/// </summary>
public static readonly Dictionary<string, Type[]> TypesDictionary = new Dictionary<string, Type[]>();
/// <summary>
/// A Key/Value dictionary of storing & obtaining a type by name
/// </summary>
public static Dictionary<string, Type> TypeDictionary { get; } = new Dictionary<string, Type>();
/// <summary>
/// A Key/Value dictionary of storing & obtaining a method by type and name
/// </summary>
public static readonly Dictionary<(Type, string), MethodInfo> MethodDictionary = new Dictionary<(Type, string), MethodInfo>();
private static string backendUrl;
/// <summary>
/// Method that returns the Backend Url (Example: https://127.0.0.1)
/// </summary>
public static string GetBackendUrl()
{
if (string.IsNullOrEmpty(backendUrl))
{
backendUrl = BackendConnection.GetBackendConnection().BackendUrl;
}
return backendUrl;
//return GClassXXX.Config.BackendUrl;
//if (_backendUrl == null)
//{
// try
// {
// var ConfigInstance = Constants.Instance.TargetAssemblyTypes
// .Where(type => type.GetField("DEFAULT_BACKEND_URL", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) != null)
// .FirstOrDefault().GetProperty("Config", BindingFlags.Static | BindingFlags.Public).GetValue(null);
// _backendUrl = HarmonyLib.Traverse.Create(ConfigInstance).Field("BackendUrl").GetValue() as string;
// }
// catch (Exception e)
// {
// Logger.LogError("GetBackendUrl():" + e);
// }
// Logger.LogInfo(_backendUrl);
//}
//if (_backendUrl == null)
//{
// _backendUrl = "https://127.0.0.1";
// Logger.LogInfo("GetBackendUrl is defaulting to " + _backendUrl);
//}
//return _backendUrl;
}
public static string GetPHPSESSID()
{
return BackendConnection.GetBackendConnection().PHPSESSID;
}
public static void DisplayMessageNotification(string message)
{
if (MessageNotificationType == null)
{
Logger.LogError("MessageNotificationType not found");
return;
}
var o = MessageNotificationType.GetMethod("DisplayMessageNotification", BindingFlags.Static | BindingFlags.Public);
if (o != null)
{
o.Invoke("DisplayMessageNotification", new object[] { message, ENotificationDurationType.Default, ENotificationIconType.Default, null });
}
}
public static ManualLogSource Logger { get; private set; }
public static Type MessageNotificationType { get; private set; }
public static Type GroupingType { get; }
public static Type JsonConverterType { get; }
public static JsonConverter[] JsonConverterDefault { get; }
private static ISession _backEndSession;
public static ISession BackEndSession
{
get
{
if (_backEndSession == null)
{
_backEndSession = Singleton<ClientApplication>.Instance.GetClientBackEndSession();
}
return _backEndSession;
}
}
public static T DoSafeConversion<T>(object o)
{
var json = o.SITToJson();
return json.SITParseJson<T>();
}
public static object GetSingletonInstance(Type singletonInstanceType)
{
Type generic = typeof(Comfort.Common.Singleton<>);
Type[] typeArgs = { singletonInstanceType };
var genericType = generic.MakeGenericType(typeArgs);
return PatchConstants.GetPropertyFromType(genericType, "Instance").GetValue(null, null);
}
public static PropertyInfo GetPropertyFromType(Type t, string name)
{
var properties = t.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
PropertyInfo property = properties.FirstOrDefault(x => x.Name.ToLower() == name.ToLower());
if (property != null)
return property;
return null;
}
public static FieldInfo GetFieldFromType(Type t, string name)
{
var fields = t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
return fields.FirstOrDefault(x => x.Name.ToLower() == name.ToLower());
}
public static FieldInfo GetFieldFromTypeByFieldType(Type objectType, Type fieldType)
{
var fields = objectType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
//foreach(var f in fields)
//{
// Logger.LogInfo("Field:" + f.Name);
//}
return fields.FirstOrDefault(x => x.FieldType == fieldType);
}
public static PropertyInfo GetPropertyFromTypeByPropertyType(Type objectType, Type propertyType)
{
var fields = objectType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
//foreach (var f in fields)
//{
// Logger.LogInfo("Prop:" + f.Name);
//}
return fields.FirstOrDefault(x => x.PropertyType == propertyType);
}
public static MethodInfo GetMethodForType(Type t, string methodName, bool debug = false)
{
return GetAllMethodsForType(t, debug).LastOrDefault(x => x.Name.ToLower() == methodName.ToLower());
}
public static async Task<MethodInfo> GetMethodForTypeAsync(Type t, string methodName, bool debug = false)
{
return await Task.Run(() => GetMethodForType(t, methodName, debug));
}
public static IEnumerable<MethodInfo> GetAllMethodsForType(Type t, bool debug = false)
{
foreach (var m in t.GetMethods(
BindingFlags.NonPublic
| BindingFlags.Public
| BindingFlags.Static
| BindingFlags.Instance
| BindingFlags.FlattenHierarchy
| BindingFlags.CreateInstance
))
{
if (debug)
Logger.LogInfo(m.Name);
yield return m;
}
if(t.BaseType != null)
{
foreach (var m in t.BaseType.GetMethods(
BindingFlags.NonPublic
| BindingFlags.Public
| BindingFlags.Static
| BindingFlags.Instance
| BindingFlags.FlattenHierarchy
))
{
if (debug)
Logger.LogInfo(m.Name);
yield return m;
}
}
}
public static IEnumerable<MethodInfo> GetAllMethodsForObject(object ob)
{
return GetAllMethodsForType(ob.GetType());
}
public static IEnumerable<PropertyInfo> GetAllPropertiesForObject(object o)
{
if (o == null)
return new List<PropertyInfo>();
var t = o.GetType();
var props = t.GetProperties(BindingFlags.Instance | BindingFlags.Public).ToList();
props.AddRange(t.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic));
props.AddRange(t.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy));
props.AddRange(t.GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy));
props.AddRange(t.GetProperties(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy));
if (t.BaseType != null)
{
t = t.BaseType;
props.AddRange(t.GetProperties(BindingFlags.Instance | BindingFlags.Public));
props.AddRange(t.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic));
props.AddRange(t.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy));
props.AddRange(t.GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy));
props.AddRange(t.GetProperties(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy));
}
return props.Distinct(x => x.Name).AsEnumerable();
}
public static IEnumerable<FieldInfo> GetAllFieldsForObject(object o)
{
var t = o.GetType();
var fields = t.GetFields(BindingFlags.Instance | BindingFlags.Public).ToList();
fields.AddRange(t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic));
fields.AddRange(t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy));
fields.AddRange(t.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy));
fields.AddRange(t.GetFields(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy));
if (t.BaseType != null)
{
t = t.BaseType;
fields.AddRange(t.GetFields(BindingFlags.Instance | BindingFlags.Public));
fields.AddRange(t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic));
fields.AddRange(t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy));
fields.AddRange(t.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy));
fields.AddRange(t.GetFields(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy));
}
return fields.Distinct(x => x.Name).AsEnumerable();
}
public static T GetFieldOrPropertyFromInstance<T>(object o, string name, bool safeConvert = true)
{
PropertyInfo property = GetAllPropertiesForObject(o).FirstOrDefault(x => x.Name.ToLower() == name.ToLower());
if(property != null)
{
if (safeConvert)
return Tarkov.Core.PatchConstants.DoSafeConversion<T>(property.GetValue(o));
else
return (T)property.GetValue(o);
}
FieldInfo field = GetAllFieldsForObject(o).FirstOrDefault(x => x.Name.ToLower() == name.ToLower());
if(field != null)
{
if (safeConvert)
return Tarkov.Core.PatchConstants.DoSafeConversion<T>(field.GetValue(o));
else
return (T)field.GetValue(o);
}
return default(T);
}
public static async Task<T> GetFieldOrPropertyFromInstanceAsync<T>(object o, string name, bool safeConvert = true)
{
return await Task.Run(() => GetFieldOrPropertyFromInstance<T>(o, name, safeConvert));
}
private static Dictionary<object, Dictionary<string, FieldInfo>> StoredFields { get; } = new Dictionary<object, Dictionary<string, FieldInfo>>();
private static Dictionary<object, Dictionary<string, FieldInfo>> StoredProperties { get; } = new Dictionary<object, Dictionary<string, FieldInfo>>();
public static void SetFieldOrPropertyFromInstance(object o, string name, object v)
{
var field = GetAllFieldsForObject(o).FirstOrDefault(x => x.Name.ToLower() == (name.ToLower()));
if (field != null)
field.SetValue(o, v);
var property = GetAllPropertiesForObject(o).FirstOrDefault(x => x.Name.ToLower() == (name.ToLower()));
if (property != null)
property.SetValue(o, v);
}
public static void SetFieldOrPropertyFromInstance<T>(object o, string name, T v)
{
var field = GetAllFieldsForObject(o).FirstOrDefault(x=>x.Name.ToLower() == (name.ToLower()));
if (field != null)
field.SetValue(o, v);
var property = GetAllPropertiesForObject(o).FirstOrDefault(x => x.Name.ToLower() == (name.ToLower()));
if (property != null)
property.SetValue(o, v);
}
public static void ConvertDictionaryToObject(object o, Dictionary<string, object> dict)
{
foreach (var key in dict)
{
var prop = PatchConstants.GetPropertyFromType(o.GetType(), key.Key);
if (prop != null)
{
prop.SetValue(o, key.Value);
}
var field = PatchConstants.GetFieldFromType(o.GetType(), key.Key);
if (field != null)
{
field.SetValue(o, key.Value);
}
}
}
public static string SITToJson(this object o)
{
return JsonConvert.SerializeObject(o
, new JsonSerializerSettings()
{
Converters = PatchConstants.JsonConverterDefault
}
);
}
public static async Task<string> SITToJsonAsync(this object o)
{
return await Task.Run(() =>
{
return SITToJson(o);
});
}
public static T SITParseJson<T>(this string str)
{
return (T)JsonConvert.DeserializeObject<T>(str
, new JsonSerializerSettings()
{
Converters = PatchConstants.JsonConverterDefault
}
) ;
}
public static object GetPlayerProfile(object __instance)
{
var instanceProfile = __instance.GetType().GetProperty("Profile"
, BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy).GetValue(__instance);
if (instanceProfile == null)
{
Logger.LogInfo("ReplaceInPlayer:PatchPostfix: Couldn't find Profile");
return null;
}
return instanceProfile;
}
public static string GetPlayerProfileAccountId(object instanceProfile)
{
var instanceAccountProp = instanceProfile.GetType().GetField("AccountId"
, BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
if (instanceAccountProp == null)
{
Logger.LogInfo($"ReplaceInPlayer:PatchPostfix: instanceAccountProp not found");
return null;
}
var instanceAccountId = instanceAccountProp.GetValue(instanceProfile).ToString();
return instanceAccountId;
}
public static IDisposable StartWithToken(string name)
{
return GetAllMethodsForType(StartWithTokenType).Single(x=>x.Name == "StartWithToken").Invoke(null, new object[] { name }) as IDisposable;
}
public static async Task InvokeAsyncStaticByReflection(MethodInfo methodInfo, object rModel, params object[] p)
{
if (rModel == null)
{
await (Task)methodInfo
.MakeGenericMethod(new[] { rModel.GetType() })
.Invoke(null, p);
}
else
{
await (Task)methodInfo
.Invoke(null, p);
}
}
/// <summary>
/// Invoke an async Task<object> method
/// </summary>
/// <param name="type"></param>
/// <param name="outputType"></param>
/// <param name="method"></param>
/// <param name="param"></param>
/// <returns></returns>
//public static async Task<object> InvokeAsyncMethod(Type type, Type outputType, string method, object[] param)
//{
// var m = PatchConstants.GetAllMethodsForType(type).First(x => x.Name == method);// foo.GetType().GetMethod(nameof(IFoo.Get));
// Logger.LogInfo("InvokeAsyncMethod." + m.Name);
// //var builder = AsyncTaskMethodBuilder.Create();
// var generic = m.MakeGenericMethod(outputType);
// var task = (Task)generic.Invoke(type, param);
// await task.ConfigureAwait(false);
// var resultProperty = task.GetType().GetProperty("Result");
// return resultProperty.GetValue(task);
//}
static PatchConstants()
{
if (Logger == null)
Logger = BepInEx.Logging.Logger.CreateLogSource("SIT.Tarkov.Core.PatchConstants");
TypesDictionary.Add("EftTypes", EftTypes);
FilesCheckerTypes = typeof(ICheckResult).Assembly.GetTypes();
LocalGameType = EftTypes.Single(x => x.Name == "LocalGame");
ExfilPointManagerType = EftTypes.Single(x => x.GetMethod("InitAllExfiltrationPoints") != null);
BackendInterfaceType = EftTypes.Single(x => x.GetMethods().Select(y => y.Name).Contains("CreateClientSession") && x.IsInterface);
SessionInterfaceType = EftTypes.Single(x => x.GetMethods().Select(y => y.Name).Contains("GetPhpSessionId") && x.IsInterface);
MessageNotificationType = EftTypes.Single(x => x.GetMethods(BindingFlags.Static | BindingFlags.Public).Select(y => y.Name).Contains("DisplayMessageNotification"));
if (MessageNotificationType == null)
{
Logger.LogInfo("SIT.Tarkov.Core:PatchConstants():MessageNotificationType:Not Found");
}
GroupingType = EftTypes.Single(x => x.GetMethods(BindingFlags.Public | BindingFlags.Static).Select(y => y.Name).Contains("CreateRaidPlayer"));
if (GroupingType != null)
{
Logger.LogInfo("SIT.Tarkov.Core:PatchConstants():Found GroupingType:" + GroupingType.FullName);
}
JsonConverterType = typeof(AbstractGame).Assembly.GetTypes()
.First(t => t.GetField("Converters", BindingFlags.Static | BindingFlags.Public) != null);
JsonConverterDefault = JsonConverterType.GetField("Converters", BindingFlags.Static | BindingFlags.Public).GetValue(null) as JsonConverter[];
StartWithTokenType = PatchConstants.EftTypes.Single(x => GetAllMethodsForType(x).Count(y => y.Name == "StartWithToken") == 1);
BotSystemHelpers.Setup();
if (JobPriorityType == null)
{
JobPriorityType = PatchConstants.EftTypes.Single(x =>
PatchConstants.GetAllMethodsForType(x).Any(x => x.Name == "Priority")
//&&
//(PatchConstants.GetFieldFromType(x, "General") != null
//|| PatchConstants.GetPropertyFromType(x, "General") != null)
);
//Logger.LogInfo($"Loading JobPriorityType:{JobPriorityType.FullName}");
}
if (PlayerInfoType == null)
{
PlayerInfoType = PatchConstants.EftTypes.Single(x =>
PatchConstants.GetAllMethodsForType(x).Any(x => x.Name == "AddBan")
&& PatchConstants.GetAllMethodsForType(x).Any(x => x.Name == "RemoveBan")
);
//Logger.LogInfo($"Loading PlayerInfoType:{PlayerInfoType.FullName}");
}
if (PlayerCustomizationType == null)
{
var profileType = typeof(EFT.Profile);
PlayerCustomizationType = PatchConstants.GetFieldFromType(typeof(EFT.Profile), "Customization").FieldType;
//Logger.LogInfo($"Loading PlayerCustomizationType:{PlayerCustomizationType.FullName}");
}
//SpawnPointSystemInterfaceType = PatchConstants.EftTypes.Single(x =>
// x.GetMethods(PatchConstants.PrivateFlags).Any(x => x.Name.IndexOf("CheckFarthestFromOtherPlayers", StringComparison.OrdinalIgnoreCase) != -1)
// && x.IsInterface
// );
//Logger.LogInfo($"Loading SpawnPointSystemInterfaceType:{SpawnPointSystemInterfaceType.FullName}");
//SpawnPointSystemClassType = PatchConstants.EftTypes.Single(x =>
// x.GetMethods(PatchConstants.PrivateFlags).Any(x => x.Name.IndexOf("CheckFarthestFromOtherPlayers", StringComparison.OrdinalIgnoreCase) != -1)
// && x.IsClass
// );
//Logger.LogInfo($"Loading SpawnPointSystemClassType:{SpawnPointSystemClassType.FullName}");
SpawnPointArrayInterfaceType = PatchConstants.EftTypes.Single(x =>
PatchConstants.GetAllMethodsForType(x).Any(x => x.Name == "CreateSpawnPoint")
&& PatchConstants.GetAllMethodsForType(x).Any(x => x.Name == "DestroySpawnPoint")
&& x.IsInterface
);
//Logger.LogInfo($"Loading SpawnPointArrayInterfaceType:{SpawnPointArrayInterfaceType.FullName}");
BackendStaticConfigurationType = PatchConstants.EftTypes.Single(x =>
PatchConstants.GetAllMethodsForType(x).Any(x => x.Name == "LoadApplicationConfig")
//&& PatchConstants.GetFieldFromType(x, "BackendUrl") != null
//&& PatchConstants.GetFieldFromType(x, "Config") != null
);
//Logger.LogInfo($"Loading BackendStaticConfigurationType:{BackendStaticConfigurationType.FullName}");
if (!TypeDictionary.ContainsKey("StatisticsSession"))
{
TypeDictionary.Add("StatisticsSession", PatchConstants.EftTypes.OrderBy(x => x.Name).First(x =>
x.IsClass
&& PatchConstants.GetAllMethodsForType(x).Any(x => x.Name == "BeginStatisticsSession")
&& PatchConstants.GetAllMethodsForType(x).Any(x => x.Name == "EndStatisticsSession")
));
//Logger.LogInfo($"StatisticsSession:{TypeDictionary["StatisticsSession"].FullName}");
}
if (!TypeDictionary.ContainsKey("FilterCustomization"))
{
// Gather FilterCustomization
TypeDictionary.Add("FilterCustomization", PatchConstants.EftTypes.OrderBy(x => x.Name).Last(x =>
x.IsClass
&& PatchConstants.GetAllMethodsForType(x).Any(x => x.Name == "FilterCustomization")
));
Logger.LogInfo($"FilterCustomization:{TypeDictionary["FilterCustomization"].FullName}");
// Test Default
//var filterCustomizationDefaultProp = PatchConstants.GetPropertyFromType(TypeDictionary["FilterCustomization"], "Default");
//Logger.LogInfo($"FilterCustomization:{filterCustomizationDefaultProp.Name}");
//var filterCustomizationDefaultField = PatchConstants.GetFieldFromType(PatchConstants.TypeDictionary["FilterCustomization"], "Default");
//Logger.LogInfo($"FilterCustomization:{filterCustomizationDefaultField.Name}");
//Logger.LogInfo($"FilterCustomization:{filterCustomizationDefaultField.GetValue(null)}");
}
TypeDictionary.Add("Profile", PatchConstants.EftTypes.First(x =>
x.IsClass && x.FullName == "EFT.Profile"
));
TypeDictionary.Add("Profile.Customization", PatchConstants.EftTypes.First(x =>
x.IsClass
&& x.BaseType == typeof(Dictionary<EBodyModelPart, string>)
));
TypeDictionary.Add("Profile.Inventory", PatchConstants.EftTypes.First(x =>
x.IsClass
&& PatchConstants.GetAllMethodsForType(x).Any(x => x.Name == "UpdateTotalWeight")
&& PatchConstants.GetAllMethodsForType(x).Any(x => x.Name == "GetAllItemByTemplate")
&& PatchConstants.GetAllMethodsForType(x).Any(x => x.Name == "GetItemsInSlots")
));
//TypeDictionary.Add("Profile.Inventory.Equipment", PatchConstants.EftTypes.First(x =>
// x.IsClass
// && PatchConstants.GetAllMethodsForType(x).Any(x => x.Name == "BeginStatisticsSession")
// && PatchConstants.GetAllMethodsForType(x).Any(x => x.Name == "EndStatisticsSession")
//));
}
}
}