0
0
mirror of https://github.com/sp-tarkov/assembly-tool.git synced 2025-02-13 01:30:45 -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:
Cj 2024-11-05 21:16:37 -05:00
parent c26df580d2
commit 06602ce037
2 changed files with 27 additions and 99 deletions

View File

@ -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",

View File

@ -63,7 +63,7 @@ public class ReCodeItRemapper
return;
}
HandleTypeTableRemaps(assemblyPath, types);
GenerateDynamicRemaps(assemblyPath, types);
var tasks = new List<Task>(remapModels.Count);
foreach (var remap in remapModels)
@ -430,12 +430,19 @@ 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()
@ -443,7 +450,7 @@ public class ReCodeItRemapper
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;
}
@ -451,7 +458,18 @@ public class ReCodeItRemapper
.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
};