コード例 #1
0
 public void Dispose()
 {
     amountLookup.Clear();
     attributeLookup.Clear();
     lastSelection = default;
     panel         = default;
 }
コード例 #2
0
 private VitalsPanelWrapper()
 {
     amountLookup    = new Dictionary <string, AmountInstance>(64);
     attributeLookup = new Dictionary <string, AttributeInstance>(64);
     lastSelection   = default;
     panel           = default;
 }
コード例 #3
0
        /// <summary>
        /// Updates the displayed plant growth information. It is invariant per plant so it
        /// only needs to be done once per selection.
        /// </summary>
        /// <param name="panel">The vitals panel wrapper to update.</param>
        /// <param name="plant">The plant to display.</param>
        /// <param name="instance">The vitals panel to update.</param>
        /// <param name="isDecor">Whether the plant is a decor plant.</param>
        /// <param name="hasAdditional">Whether the plant has additional requirements.</param>
        private static void UpdatePlantGrowth(ref VitalsPanelState panel, GameObject plant,
                                              bool isDecor, bool hasAdditional)
        {
            var amountLines    = panel.amountLines;
            var attributeLines = panel.attributeLines;
            var aLabel         = panel.plantAdditionalLabel;
            int n = amountLines.Length;

            if (plant.TryGetComponent(out ReceptacleMonitor rm))
            {
                // Update the invariant text for plants
                if (plant.TryGetComponent(out Growing growing))
                {
                    string wildGrowth = GameUtil.GetFormattedCycles(growing.WildGrowthTime());
                    string tameGrowth = GameUtil.GetFormattedCycles(growing.
                                                                    DomesticGrowthTime());
                    panel.plantNormalLabel.SetText(CONDITIONS_GROWING.WILD.BASE.Format(
                                                       wildGrowth));
                    panel.plantNormalTooltip.SetSimpleTooltip(CONDITIONS_GROWING.WILD.TOOLTIP.
                                                              Format(wildGrowth));
                    aLabel.color = rm.Replanted ? Color.black : Color.grey;
                    aLabel.SetText(hasAdditional ? CONDITIONS_GROWING.ADDITIONAL_DOMESTIC.BASE.
                                   Format(tameGrowth) : CONDITIONS_GROWING.DOMESTIC.BASE.
                                   Format(tameGrowth));
                    panel.plantAdditionalTooltip.SetSimpleTooltip(CONDITIONS_GROWING.
                                                                  ADDITIONAL_DOMESTIC.TOOLTIP.Format(tameGrowth));
                }
                else
                {
                    string wildGrowth = Util.FormatTwoDecimalPlace(100.0f * TUNING.CROPS.
                                                                   WILD_GROWTH_RATE_MODIFIER);
                    string tameGrowth = Util.FormatTwoDecimalPlace(100.0f);
                    panel.plantNormalLabel.SetText(isDecor ? CONDITIONS_GROWING.WILD_DECOR.BASE.
                                                   ToString() : CONDITIONS_GROWING.WILD_INSTANT.BASE.Format(wildGrowth));
                    panel.plantNormalTooltip.SetSimpleTooltip(CONDITIONS_GROWING.WILD_INSTANT.
                                                              TOOLTIP);
                    aLabel.color = (rm == null || rm.Replanted) ? Color.black : Color.grey;
                    aLabel.SetText(CONDITIONS_GROWING.ADDITIONAL_DOMESTIC_INSTANT.BASE.
                                   Format(tameGrowth));
                    panel.plantAdditionalTooltip.SetSimpleTooltip(CONDITIONS_GROWING.
                                                                  ADDITIONAL_DOMESTIC_INSTANT.TOOLTIP);
                }
            }
            // Turn off the attributes and amounts
            for (int i = 0; i < n; i++)
            {
                amountLines[i].go.SetActive(false);
            }
            n = attributeLines.Length;
            for (int i = 0; i < n; i++)
            {
                attributeLines[i].go.SetActive(false);
            }
        }