Handle armor points on armored rigs

This commit is contained in:
Tyfon
2024-04-29 15:45:28 -07:00
parent 42508308bc
commit 3b8dff8353

View File

@@ -116,10 +116,15 @@ namespace UIFixes
[PatchPrefix] [PatchPrefix]
private static void Prefix(Item compareItem) private static void Prefix(Item compareItem)
{ {
if (compareItem is ArmorClass) if (compareItem == null)
{ {
return;
}
// Armor points is added in method_5, but not in other places so it's missed by compare // Armor points is added in method_5, but not in other places so it's missed by compare
ArmorComponent[] armorComponents = compareItem.GetItemComponentsInChildren<ArmorComponent>(true).Where(c => c.ArmorClass > 0).ToArray<ArmorComponent>(); ArmorComponent[] armorComponents = compareItem.GetItemComponentsInChildren<ArmorComponent>(true).Where(c => c.ArmorClass > 0).ToArray<ArmorComponent>();
if (armorComponents.Any())
{
float maxDurability = armorComponents.Sum(c => c.Repairable.Durability); float maxDurability = armorComponents.Sum(c => c.Repairable.Durability);
ItemAttributeClass itemAttributeClass = new ItemAttributeClass(EItemAttributeId.ArmorPoints); ItemAttributeClass itemAttributeClass = new ItemAttributeClass(EItemAttributeId.ArmorPoints);