private void AddAmountLine(Amount amount, Func <AmountInstance, string> tooltip_func = null)
    {
        GameObject gameObject = Util.KInstantiateUI(LineItemPrefab, base.gameObject, false);

        gameObject.GetComponentInChildren <Image>().sprite       = Assets.GetSprite(amount.uiSprite);
        gameObject.GetComponent <ToolTip>().refreshWhileHovering = true;
        gameObject.SetActive(true);
        AmountLine item = default(AmountLine);

        item.amount      = amount;
        item.go          = gameObject;
        item.locText     = gameObject.GetComponentInChildren <LocText>();
        item.toolTip     = gameObject.GetComponentInChildren <ToolTip>();
        item.imageToggle = gameObject.GetComponentInChildren <ValueTrendImageToggle>();
        item.toolTipFunc = ((tooltip_func == null) ? new Func <AmountInstance, string>(amount.GetTooltip) : tooltip_func);
        amountsLines.Add(item);
    }
 public void Refresh()
 {
     if (!((UnityEngine.Object)selectedEntity == (UnityEngine.Object)null) && !((UnityEngine.Object)selectedEntity.gameObject == (UnityEngine.Object)null))
     {
         Amounts    amounts    = selectedEntity.GetAmounts();
         Attributes attributes = selectedEntity.GetAttributes();
         if (amounts != null && attributes != null)
         {
             WiltCondition component = selectedEntity.GetComponent <WiltCondition>();
             if ((UnityEngine.Object)component == (UnityEngine.Object)null)
             {
                 conditionsContainerNormal.gameObject.SetActive(false);
                 conditionsContainerAdditional.gameObject.SetActive(false);
                 foreach (AmountLine amountsLine in amountsLines)
                 {
                     AmountLine current = amountsLine;
                     bool       flag    = current.TryUpdate(amounts);
                     if (current.go.activeSelf != flag)
                     {
                         current.go.SetActive(flag);
                     }
                 }
                 foreach (AttributeLine attributesLine in attributesLines)
                 {
                     AttributeLine current2 = attributesLine;
                     bool          flag2    = current2.TryUpdate(attributes);
                     if (current2.go.activeSelf != flag2)
                     {
                         current2.go.SetActive(flag2);
                     }
                 }
             }
             bool flag3 = false;
             for (int i = 0; i < checkboxLines.Count; i++)
             {
                 CheckboxLine            checkboxLine            = checkboxLines[i];
                 CheckboxLineDisplayType checkboxLineDisplayType = CheckboxLineDisplayType.Hidden;
                 CheckboxLine            checkboxLine2           = checkboxLines[i];
                 if (checkboxLine2.amount != null)
                 {
                     for (int j = 0; j < amounts.Count; j++)
                     {
                         AmountInstance amountInstance = amounts[j];
                         if (checkboxLine.amount == amountInstance.amount)
                         {
                             checkboxLineDisplayType = checkboxLine.display_condition(selectedEntity.gameObject);
                             break;
                         }
                     }
                 }
                 else
                 {
                     checkboxLineDisplayType = checkboxLine.display_condition(selectedEntity.gameObject);
                 }
                 if (checkboxLineDisplayType != CheckboxLineDisplayType.Hidden)
                 {
                     checkboxLine.locText.SetText(checkboxLine.label_text_func(selectedEntity.gameObject));
                     if (!checkboxLine.go.activeSelf)
                     {
                         checkboxLine.go.SetActive(true);
                     }
                     GameObject gameObject = checkboxLine.go.GetComponent <HierarchyReferences>().GetReference("Check").gameObject;
                     gameObject.SetActive(checkboxLine.get_value(selectedEntity.gameObject));
                     if ((UnityEngine.Object)checkboxLine.go.transform.parent != (UnityEngine.Object)checkboxLine.parentContainer)
                     {
                         checkboxLine.go.transform.SetParent(checkboxLine.parentContainer);
                         checkboxLine.go.transform.localScale = Vector3.one;
                     }
                     if ((UnityEngine.Object)checkboxLine.parentContainer == (UnityEngine.Object)conditionsContainerAdditional)
                     {
                         flag3 = true;
                     }
                     if (checkboxLineDisplayType == CheckboxLineDisplayType.Normal)
                     {
                         if (checkboxLine.get_value(selectedEntity.gameObject))
                         {
                             checkboxLine.locText.color = Color.black;
                             gameObject.transform.parent.GetComponent <Image>().color = Color.black;
                         }
                         else
                         {
                             Color color = new Color(0.992156863f, 0f, 0.101960786f);
                             checkboxLine.locText.color = color;
                             gameObject.transform.parent.GetComponent <Image>().color = color;
                         }
                     }
                     else
                     {
                         checkboxLine.locText.color = Color.grey;
                         gameObject.transform.parent.GetComponent <Image>().color = Color.grey;
                     }
                 }
                 else if (checkboxLine.go.activeSelf)
                 {
                     checkboxLine.go.SetActive(false);
                 }
             }
             if ((UnityEngine.Object)component != (UnityEngine.Object)null)
             {
                 Growing component2 = component.GetComponent <Growing>();
                 bool    flag4      = component.HasTag(GameTags.Decoration);
                 conditionsContainerNormal.gameObject.SetActive(true);
                 conditionsContainerAdditional.gameObject.SetActive(!flag4);
                 if ((UnityEngine.Object)component2 == (UnityEngine.Object)null)
                 {
                     float   num       = 1f;
                     LocText reference = conditionsContainerNormal.GetComponent <HierarchyReferences>().GetReference <LocText>("Label");
                     reference.text = string.Empty;
                     reference.text = ((!flag4) ? string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.WILD_INSTANT.BASE, Util.FormatTwoDecimalPlace(num * 0.25f * 100f)) : string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.WILD_DECOR.BASE));
                     reference.GetComponent <ToolTip>().SetSimpleTooltip(string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.WILD_INSTANT.TOOLTIP));
                     reference       = conditionsContainerAdditional.GetComponent <HierarchyReferences>().GetReference <LocText>("Label");
                     reference.color = ((!selectedEntity.GetComponent <ReceptacleMonitor>().Replanted) ? Color.grey : Color.black);
                     reference.text  = string.Empty;
                     reference.text  = string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.ADDITIONAL_DOMESTIC_INSTANT.BASE, Util.FormatTwoDecimalPlace(num * 100f));
                     reference.GetComponent <ToolTip>().SetSimpleTooltip(string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.ADDITIONAL_DOMESTIC_INSTANT.TOOLTIP));
                 }
                 else
                 {
                     LocText reference = conditionsContainerNormal.GetComponent <HierarchyReferences>().GetReference <LocText>("Label");
                     reference.text = string.Empty;
                     reference.text = string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.WILD.BASE, GameUtil.GetFormattedCycles(component.GetComponent <Growing>().WildGrowthTime(), "F1"));
                     reference.GetComponent <ToolTip>().SetSimpleTooltip(string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.WILD.TOOLTIP, GameUtil.GetFormattedCycles(component.GetComponent <Growing>().WildGrowthTime(), "F1")));
                     reference       = conditionsContainerAdditional.GetComponent <HierarchyReferences>().GetReference <LocText>("Label");
                     reference.color = ((!selectedEntity.GetComponent <ReceptacleMonitor>().Replanted) ? Color.grey : Color.black);
                     reference.text  = string.Empty;
                     reference.text  = ((!flag3) ? string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.DOMESTIC.BASE, GameUtil.GetFormattedCycles(component.GetComponent <Growing>().DomesticGrowthTime(), "F1")) : string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.ADDITIONAL_DOMESTIC.BASE, GameUtil.GetFormattedCycles(component.GetComponent <Growing>().DomesticGrowthTime(), "F1")));
                     reference.GetComponent <ToolTip>().SetSimpleTooltip(string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.ADDITIONAL_DOMESTIC.TOOLTIP, GameUtil.GetFormattedCycles(component.GetComponent <Growing>().DomesticGrowthTime(), "F1")));
                 }
                 foreach (AmountLine amountsLine2 in amountsLines)
                 {
                     AmountLine current3 = amountsLine2;
                     current3.go.SetActive(false);
                 }
                 foreach (AttributeLine attributesLine2 in attributesLines)
                 {
                     AttributeLine current4 = attributesLine2;
                     current4.go.SetActive(false);
                 }
             }
         }
     }
 }