private void AddCheckboxLine(Amount amount, Transform parentContainer, Func <GameObject, string> label_text_func, Func <GameObject, CheckboxLineDisplayType> display_condition, Func <GameObject, bool> checkbox_value_func, Func <GameObject, string> tooltip_func = null)
    {
        GameObject          gameObject = Util.KInstantiateUI(CheckboxLinePrefab, base.gameObject, false);
        HierarchyReferences component  = gameObject.GetComponent <HierarchyReferences>();

        gameObject.GetComponent <ToolTip>().refreshWhileHovering = true;
        gameObject.SetActive(true);
        CheckboxLine item = default(CheckboxLine);

        item.go = gameObject;
        item.parentContainer   = parentContainer;
        item.amount            = amount;
        item.locText           = (component.GetReference("Label") as LocText);
        item.get_value         = checkbox_value_func;
        item.display_condition = display_condition;
        item.label_text_func   = label_text_func;
        item.go.name           = "Checkbox_";
        if (amount != null)
        {
            GameObject go = item.go;
            go.name += amount.Name;
        }
        else
        {
            GameObject go2 = item.go;
            go2.name += "Unnamed";
        }
        if (tooltip_func != null)
        {
            item.tooltip = tooltip_func;
            ToolTip tt = item.go.GetComponent <ToolTip>();
            tt.refreshWhileHovering = true;
            tt.OnToolTip            = delegate
            {
                tt.ClearMultiStringTooltip();
                tt.AddMultiStringTooltip(tooltip_func(selectedEntity), null);
                return(string.Empty);
            };
        }
        checkboxLines.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);
                 }
             }
         }
     }
 }