コード例 #1
0
        public void MakeDefIcon(ThingWithComps thing = null)
        {
            string colorStr = LabelColor(thing);

            ColorUtility.TryParseHtmlString(colorStr, out Color color);

            string texPart = "1Affix";

            if (IsDeadly(thing))
            {
                texPart = "Deadly";
            }

            defIcons[colorStr] = IconUtility.FetchOrMakeIcon(texPart, color, 1f);
            return;
        }
コード例 #2
0
        private void MakeIcons()
        {
            Texture2D defIcon = parent.def.uiIcon;

            uiIcon = defIcon;

            if (!UnityData.IsInMainThread)
            {
                return;                             // too early to be fetching this stuff
            }
            if (AffixCount == 0)
            {
                return;
            }

            // Use the highest affix cost for the color
            LootAffixDef highestAffix = affixes.FirstOrFallback(
                lad => lad.IsDeadly(parent),  // deadly overrides others
                affixes.OrderByDescending(lad => lad.GetRealAffixCost(parent)).First()
                );

            ColorUtility.TryParseHtmlString(highestAffix.LabelColor(parent), out Color color);

            string texPart = AffixCount + "Affix";

            if (highestAffix.IsDeadly(parent))
            {
                texPart = "Deadly";
            }

            // Grab the overlay icon
            float scale = Mathf.Sqrt(defIcon.width * defIcon.height) / 256;  // 64x64 -> 16x16 overlays

            overlayIcon = IconUtility.FetchOrMakeIcon(texPart, color, scale);

            // Apply the overlay onto the Thing icon
            uiIcon = defIcon.CloneAsReadable();
            uiIcon.AddOverlayToBLCorner(overlayIcon);
            uiIcon.Apply(true, true);  // apply and lock
        }