Beispiel #1
0
        // hide any location with maxArmor <= 0 && structure <= 1
        // for vehicles and troopers
        private static bool ShouldHide(MechLabLocationWidget widget)
        {
            var def = widget.chassisLocationDef;

            return(PrecisionUtils.SmallerOrEqualsTo(def.MaxArmor, 0) &&
                   PrecisionUtils.SmallerOrEqualsTo(def.InternalStructure, 1));
        }
    internal static void OnRefreshArmor(MechLabLocationWidget widget)
    {
        void RefreshArmorBar(LanceStat lanceStat, bool isRearArmor)
        {
            lanceStat.SetTextColor(UIColor.White, UIColor.White);
            RefreshBarColor(widget, isRearArmor);

            void SetButtonColor(string buttonId, UIColor uiColor)
            {
                var button = lanceStat.transform.Find(buttonId);
                // the plus icon is actually made of two minus icons
                var icons = button.Find("startButtonFill").GetChildren();

                foreach (var icon in icons)
                {
                    var colorRefTracker = icon.GetComponent <UIColorRefTracker>();
                    colorRefTracker.SetUIColor(uiColor);
                }
            }

            const UIColor limitReachedColor = UIColor.MedGray;
            {
                var max        = isRearArmor ? widget.maxRearArmor : widget.maxArmor;
                var current    = isRearArmor ? widget.currentRearArmor : widget.currentArmor;
                var maxReached = PrecisionUtils.SmallerOrEqualsTo(max, current);
                SetButtonColor("bttn_plus", maxReached ? limitReachedColor : UIColor.White);
            }
            {
                var minReached = PrecisionUtils.SmallerOrEqualsTo(isRearArmor ? widget.currentRearArmor : widget.currentArmor, 0);
                SetButtonColor("bttn_minus", minReached ? limitReachedColor : UIColor.White);
            }
        }

        RefreshArmorBar(widget.armorBar, false);
        if (widget.useRearArmor)
        {
            RefreshArmorBar(widget.rearArmorBar, true);
        }
    }