From 279805b98ec1c5dc266e63ad0cc3c8a61f4ba970 Mon Sep 17 00:00:00 2001 From: Avifir Date: Wed, 15 Feb 2023 14:43:46 +0000 Subject: [PATCH] Remove redundant erroring UpdateBeltPrefabs patch The EquipmentInfrastructure.cs UpdateBeltPrefabs patch is redundant (see BarleyFlour/VisualAdjustments2@f16e1984f2ec665573854386002ac4e64d487755 ) and causes NullReferenceExceptions In general use this fails gracefully, in rare cases the Harmony error handling causes crashes - best to be avoided where possible. --- .../Infrastructure/EquipmentInfrastructure.cs | 40 +------------------ 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/VisualAdjustments2/Infrastructure/EquipmentInfrastructure.cs b/VisualAdjustments2/Infrastructure/EquipmentInfrastructure.cs index f84b1a9..1533db4 100644 --- a/VisualAdjustments2/Infrastructure/EquipmentInfrastructure.cs +++ b/VisualAdjustments2/Infrastructure/EquipmentInfrastructure.cs @@ -35,42 +35,4 @@ public static bool Prefix(UnitEntityView __instance, ItemEntity item) else return true; } } - - [HarmonyPatch(typeof(UnitViewHandsEquipment), nameof(UnitViewHandsEquipment.UpdateBeltPrefabs))] - public static class bro - { - private static void Postfix(UnitViewHandsEquipment __instance) - { - try - { - if (!__instance.Owner.IsPlayerFaction) return; - var characterSettings = __instance.Owner.GetSettings(); -#if DEBUG - Main.Logger.Log($"Updating {__instance.Owner.CharacterName}'s Belt items, Hide is set to {characterSettings.HideEquipmentDict[ItemsFilter.ItemType.Usable]}"); -#endif - if (characterSettings.HideEquipmentDict[ItemsFilter.ItemType.Usable]) - { - foreach (var go in __instance.m_ConsumableSlots) - { -#if DEBUG - Main.Logger.Log($"Tried to hide belt item: {go.name}"); -#endif - go.SetActive(false); - } - } - /*if (characterSettings.overrideScale && !__instance.Character.PeacefulMode) - { - foreach (var go in ___m_ConsumableSlots) - { - if (go == null) continue; - go.transform.localScale *= ViewManager.GetRealSizeScale(__instance.Owner.View, characterSettings); - } - }*/ - } - catch (Exception ex) - { - Main.Logger.Error(ex.ToString()); - } - } - } -} \ No newline at end of file +}