Allow insure on inner items

This commit is contained in:
Tyfon
2024-06-13 12:35:11 -07:00
parent bd1ae66fc1
commit 0fcbf2479e
3 changed files with 51 additions and 6 deletions

19
R.cs
View File

@@ -57,6 +57,7 @@ namespace UIFixes
GridWindow.InitTypes();
GridSortPanel.InitTypes();
RepairStrategy.InitTypes();
ContextMenuHelper.InitTypes();
}
public abstract class Wrapper(object value)
@@ -659,12 +660,26 @@ namespace UIFixes
public bool BrokenItemError() => (bool)BrokenItemErrorMethod.Invoke(Value, []);
public bool IsNoCorrespondingArea() => (bool)IsNoCorrespondingAreaMethod.Invoke(Value, []);
}
public class ContextMenuHelper(object value) : Wrapper(value)
{
public static Type Type { get; private set; }
private static FieldInfo InsuranceCompanyField;
public static void InitTypes()
{
Type = PatchConstants.EftTypes.Single(t => t.GetProperty("IsOwnedByPlayer") != null); // GClass3052
InsuranceCompanyField = AccessTools.GetDeclaredFields(Type).Single(f => f.FieldType == typeof(InsuranceCompanyClass));
}
public InsuranceCompanyClass InsuranceCompany { get { return (InsuranceCompanyClass)InsuranceCompanyField.GetValue(Value); } }
}
}
public static class RExtentensions
{
public static R.UIElement R(this UIElement value) => new R.UIElement(value);
public static R.UIInputNode R(this UIInputNode value) => new R.UIInputNode(value);
public static R.UIElement R(this UIElement value) => new(value);
public static R.UIInputNode R(this UIInputNode value) => new(value);
public static R.ProductionPanel R(this ProductionPanel value) => new(value);
public static R.AreaScreenSubstrate R(this AreaScreenSubstrate value) => new(value);
public static R.ItemSpecificationPanel R(this ItemSpecificationPanel value) => new(value);