2023-07-08 23:42:42 +03:00
|
|
|
using BepInEx;
|
|
|
|
using EFT.UI;
|
2024-07-10 23:03:39 +03:00
|
|
|
using SPT.Reflection.Patching;
|
2023-07-08 23:42:42 +03:00
|
|
|
using System.Reflection;
|
|
|
|
|
2024-03-05 22:48:21 +02:00
|
|
|
namespace IcyClawz.ItemAttributeFix;
|
|
|
|
|
2024-12-02 15:59:14 +02:00
|
|
|
[BepInPlugin("com.IcyClawz.ItemAttributeFix", "IcyClawz.ItemAttributeFix", "1.5.0")]
|
2024-03-05 22:48:21 +02:00
|
|
|
public class Plugin : BaseUnityPlugin
|
2023-07-08 23:42:42 +03:00
|
|
|
{
|
2024-03-05 22:48:21 +02:00
|
|
|
private void Awake() =>
|
|
|
|
new CompactCharacteristicPanelPatch().Enable();
|
|
|
|
}
|
2023-07-08 23:42:42 +03:00
|
|
|
|
2024-03-05 22:48:21 +02:00
|
|
|
internal class CompactCharacteristicPanelPatch : ModulePatch
|
|
|
|
{
|
|
|
|
private static readonly FieldInfo ItemAttributeField =
|
|
|
|
typeof(CompactCharacteristicPanel).GetField("ItemAttribute", BindingFlags.NonPublic | BindingFlags.Instance);
|
2023-07-08 23:42:42 +03:00
|
|
|
|
2024-03-05 22:48:21 +02:00
|
|
|
private static readonly FieldInfo StringField =
|
|
|
|
typeof(CompactCharacteristicPanel).GetField("string_0", BindingFlags.NonPublic | BindingFlags.Instance);
|
2023-07-08 23:42:42 +03:00
|
|
|
|
2024-03-05 22:48:21 +02:00
|
|
|
protected override MethodBase GetTargetMethod() =>
|
|
|
|
typeof(CompactCharacteristicPanel).GetMethod("SetValues", BindingFlags.Public | BindingFlags.Instance);
|
|
|
|
|
|
|
|
[PatchPostfix]
|
|
|
|
private static void PatchPostfix(ref CompactCharacteristicPanel __instance)
|
|
|
|
{
|
|
|
|
if (ItemAttributeField.GetValue(__instance) is ItemAttributeClass attribute)
|
2023-07-08 23:42:42 +03:00
|
|
|
StringField.SetValue(__instance, attribute.FullStringValue());
|
|
|
|
}
|
|
|
|
}
|