public static void Postfix(XUiC_ItemStack __instance, bool ___bLocked, bool ___isDragAndDrop) { if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { return; } // Make sure we are dealing with legitimate stacks. if (__instance.ItemStack.IsEmpty()) { return; } if (__instance.ItemStack.itemValue == null) { return; } if (___bLocked && ___isDragAndDrop) { return; } // if (__instance.ItemStack.itemValue.NextSpoilageTick < (int)GameManager.Instance.World.GetWorldTime()) { if (__instance.ItemStack.itemValue.ItemClass != null && __instance.ItemStack.itemValue.ItemClass.Properties.Contains("Spoilable")) { float DegradationMax = 1000f; if (__instance.ItemStack.itemValue.ItemClass.Properties.Contains("SpoilageMax")) { DegradationMax = __instance.ItemStack.itemValue.ItemClass.Properties.GetFloat("SpoilageMax"); } __instance.durability.IsVisible = true; __instance.durabilityBackground.IsVisible = true; float PerCent = 1f - Mathf.Clamp01(__instance.ItemStack.itemValue.CurrentSpoilage / DegradationMax); int TierColor = 7 + (int)Math.Round(8 * PerCent); if (TierColor < 0) { TierColor = 0; } if (TierColor > 7) { TierColor = 7; } // allow over-riding of the color. if (__instance.ItemStack.itemValue.ItemClass.Properties.Contains("QualityTierColor")) { TierColor = __instance.ItemStack.itemValue.ItemClass.Properties.GetInt("QualityTierColor"); } __instance.durability.Color = QualityInfo.GetQualityColor(TierColor); __instance.durability.Fill = PerCent; } } }