mirror of
https://github.com/sp-tarkov/assembly-tool.git
synced 2025-02-12 20:30:43 -05:00
Remove more not needed manual remaps, dynamically remap item templates (different from the item objects) and clean up
This commit is contained in:
parent
c26df580d2
commit
06602ce037
@ -1189,96 +1189,6 @@
|
||||
"ExcludeNestedTypes": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"NewTypeName": "SecureContainerTemplateClass",
|
||||
"OriginalTypeName": "GClass2827",
|
||||
"UseForceRename": false,
|
||||
"SearchParams": {
|
||||
"IsPublic": true,
|
||||
"IncludeMethods": [],
|
||||
"ExcludeMethods": [],
|
||||
"IncludeFields": [
|
||||
"containType"
|
||||
],
|
||||
"ExcludeFields": [],
|
||||
"IncludeProperties": [],
|
||||
"ExcludeProperties": [],
|
||||
"IncludeNestedTypes": [],
|
||||
"ExcludeNestedTypes": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"NewTypeName": "Meds2Class",
|
||||
"OriginalTypeName": "GClass2855",
|
||||
"UseForceRename": false,
|
||||
"SearchParams": {
|
||||
"IsPublic": true,
|
||||
"IncludeMethods": [],
|
||||
"ExcludeMethods": [],
|
||||
"IncludeFields": [
|
||||
"BodyPartTimeMults"
|
||||
],
|
||||
"ExcludeFields": [],
|
||||
"IncludeProperties": [],
|
||||
"ExcludeProperties": [],
|
||||
"IncludeNestedTypes": [],
|
||||
"ExcludeNestedTypes": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"NewTypeName": "RepairKitClass",
|
||||
"OriginalTypeName": "GClass2860",
|
||||
"UseForceRename": false,
|
||||
"SearchParams": {
|
||||
"IsPublic": true,
|
||||
"IncludeMethods": [],
|
||||
"ExcludeMethods": [],
|
||||
"IncludeFields": [
|
||||
"TargetItemFilter"
|
||||
],
|
||||
"ExcludeFields": [],
|
||||
"IncludeProperties": [],
|
||||
"ExcludeProperties": [],
|
||||
"IncludeNestedTypes": [],
|
||||
"ExcludeNestedTypes": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"NewTypeName": "MoneyClass",
|
||||
"OriginalTypeName": "GClass2870",
|
||||
"UseForceRename": false,
|
||||
"SearchParams": {
|
||||
"IsPublic": true,
|
||||
"IncludeMethods": [],
|
||||
"ExcludeMethods": [],
|
||||
"IncludeFields": [
|
||||
"eqMax"
|
||||
],
|
||||
"ExcludeFields": [],
|
||||
"IncludeProperties": [],
|
||||
"ExcludeProperties": [],
|
||||
"IncludeNestedTypes": [],
|
||||
"ExcludeNestedTypes": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"NewTypeName": "ThrowableWeaponClass",
|
||||
"OriginalTypeName": "GClass2872",
|
||||
"UseForceRename": false,
|
||||
"SearchParams": {
|
||||
"IsPublic": true,
|
||||
"IncludeMethods": [],
|
||||
"ExcludeMethods": [],
|
||||
"IncludeFields": [
|
||||
"MinFragmentDamage"
|
||||
],
|
||||
"ExcludeFields": [],
|
||||
"IncludeProperties": [],
|
||||
"ExcludeProperties": [],
|
||||
"IncludeNestedTypes": [],
|
||||
"ExcludeNestedTypes": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"NewTypeName": "BossKnightBrainClass",
|
||||
"OriginalTypeName": "GClass292",
|
||||
|
@ -62,8 +62,8 @@ public class ReCodeItRemapper
|
||||
Logger.Log("You must de-obfuscate the assembly before remapping it.\n", ConsoleColor.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
HandleTypeTableRemaps(assemblyPath, types);
|
||||
|
||||
GenerateDynamicRemaps(assemblyPath, types);
|
||||
|
||||
var tasks = new List<Task>(remapModels.Count);
|
||||
foreach (var remap in remapModels)
|
||||
@ -430,28 +430,46 @@ public class ReCodeItRemapper
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleTypeTableRemaps(string path, IEnumerable<TypeDef> types)
|
||||
private void GenerateDynamicRemaps(string path, IEnumerable<TypeDef> types)
|
||||
{
|
||||
// HACK: Because this is written in net8 and the assembly is net472 we must resolve the type this way instead of
|
||||
// filtering types directly using GetTypes() Otherwise, it causes serialization issues.
|
||||
// This is also necessary because we can't access non-compile time constants with dnlib.
|
||||
var templateMappingTypeDef = types.Single(t => t.FindField("TypeTable") != null);
|
||||
var templateMappingTypeDef = types.SingleOrDefault(t => t.FindField("TypeTable") != null);
|
||||
|
||||
if (templateMappingTypeDef is null)
|
||||
{
|
||||
Logger.Log("Could not find type for field TypeTable", ConsoleColor.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
var assembly = Assembly.LoadFrom(path);
|
||||
var templateMappingClass = assembly.Modules
|
||||
.First()
|
||||
.GetType(templateMappingTypeDef.Name);
|
||||
|
||||
|
||||
if (templateMappingClass is null)
|
||||
{
|
||||
Logger.Log($"Could not find {templateMappingTypeDef.Name} in the assembly.", ConsoleColor.Red);
|
||||
Logger.Log($"Could not resolve type for {templateMappingTypeDef.Name}", ConsoleColor.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
var typeTable = (Dictionary<string, Type>)templateMappingClass
|
||||
.GetField("TypeTable")
|
||||
.GetValue(templateMappingClass);
|
||||
|
||||
foreach (var type in typeTable)
|
||||
|
||||
BuildAssociationFromTable(typeTable, "ItemClass");
|
||||
|
||||
var templateTypeTable = (Dictionary<string, Type>)templateMappingClass
|
||||
.GetField("TemplateTypeTable")
|
||||
.GetValue(templateMappingClass);
|
||||
|
||||
BuildAssociationFromTable(templateTypeTable, "TemplateClass");
|
||||
}
|
||||
|
||||
private void BuildAssociationFromTable(Dictionary<string, Type> table, string extName)
|
||||
{
|
||||
foreach (var type in table)
|
||||
{
|
||||
if (DataProvider.ItemTemplates!.TryGetValue(type.Key, out var template))
|
||||
{
|
||||
@ -462,7 +480,7 @@ public class ReCodeItRemapper
|
||||
var remap = new RemapModel
|
||||
{
|
||||
OriginalTypeName = type.Value.Name,
|
||||
NewTypeName = $"{template._name}Class",
|
||||
NewTypeName = $"{template._name}{extName}",
|
||||
UseForceRename = true
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user