Fix repair context menu checking for hideout upgrades even when using traders

This commit is contained in:
Tyfon
2024-07-09 11:09:23 -07:00
parent ccdd6f3c21
commit 3038c71ed7
2 changed files with 30 additions and 12 deletions

21
R.cs
View File

@@ -54,6 +54,7 @@ namespace UIFixes
GridWindow.InitTypes();
GridSortPanel.InitTypes();
RepairStrategy.InitTypes();
RepairKit.InitTypes();
ContextMenuHelper.InitTypes();
RagfairNewOfferItemView.InitTypes();
TradingTableGridView.InitTypes();
@@ -597,9 +598,9 @@ namespace UIFixes
public static void InitTypes()
{
Type = PatchConstants.EftTypes.Single(t => t.IsInterface && t.GetMethod("HowMuchRepairScoresCanAccept") != null);
ArmorStrategyType = PatchConstants.EftTypes.Single(t => t.IsClass && Type.IsAssignableFrom(t) && t.GetField("repairableComponent_0", BindingFlags.Instance | BindingFlags.NonPublic) == null);
DefaultStrategyType = PatchConstants.EftTypes.Single(t => Type.IsAssignableFrom(t) && t.GetField("repairableComponent_0", BindingFlags.Instance | BindingFlags.NonPublic) != null);
Type = PatchConstants.EftTypes.Single(t => t.IsInterface && t.GetMethod("HowMuchRepairScoresCanAccept") != null); // GInterface34
ArmorStrategyType = PatchConstants.EftTypes.Single(t => t.IsClass && Type.IsAssignableFrom(t) && t.GetField("repairableComponent_0", BindingFlags.Instance | BindingFlags.NonPublic) == null); // GClass805
DefaultStrategyType = PatchConstants.EftTypes.Single(t => Type.IsAssignableFrom(t) && t.GetField("repairableComponent_0", BindingFlags.Instance | BindingFlags.NonPublic) != null); // GClass804
RepairersProperty = AccessTools.Property(Type, "Repairers");
CurrentRepairerProperty = AccessTools.Property(Type, "CurrentRepairer");
HowMuchRepairScoresCanAcceptMethod = AccessTools.Method(Type, "HowMuchRepairScoresCanAccept");
@@ -640,6 +641,20 @@ namespace UIFixes
public bool IsNoCorrespondingArea() => (bool)IsNoCorrespondingAreaMethod.Invoke(Value, []);
}
public class RepairKit(object value) : Wrapper(value)
{
public static Type Type { get; private set; }
private static MethodInfo GetRepairPointsMethod;
public static void InitTypes()
{
Type = R.RepairStrategy.Type.GetMethod("GetRepairPrice").GetParameters()[1].ParameterType; // GClass803
GetRepairPointsMethod = AccessTools.Method(Type, "GetRepairPoints");
}
public float GetRepairPoints() => (float)GetRepairPointsMethod.Invoke(Value, []);
}
public class ContextMenuHelper(object value) : Wrapper(value)
{
public static Type Type { get; private set; }