예제 #1
0
        public void AddDisplayText(uGUI_ItemIcon icon)
        {
            // This code was made possible with the help of Waisie Milliams Hah
            var arial = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf");

            var textGO = new GameObject("EnergyLabel");

            textGO.transform.parent = icon.transform;
            textGO.AddComponent <Text>();

            Text text = textGO.GetComponent <Text>();

            text.font      = arial;
            text.material  = arial.material;
            text.text      = string.Empty;
            text.fontSize  = 14 + Size;
            text.alignment = TextAnchor.MiddleCenter;
            text.color     = Color.yellow;

            Outline outline = textGO.AddComponent <Outline>();

            outline.effectColor = Color.black;

            RectTransform rectTransform = text.GetComponent <RectTransform>();

            rectTransform.localScale         = Vector3.one;
            rectTransform.anchoredPosition3D = Vector3.zero;

            this.DisplayText = text;
        }
예제 #2
0
 public AmbientEnergyIconOverlay(uGUI_ItemIcon icon, InventoryItem upgradeModule)
     : base(icon, upgradeModule)
 {
     upgradeHandler = MCUServices.Find.CyclopsGroupUpgradeHandler <HandlerType>(base.Cyclops, base.TechType);
     charger        = MCUServices.Find.CyclopsCharger <ChargerType>(base.Cyclops);
     battery        = base.Item.item.GetComponent <Battery>();
 }
예제 #3
0
        public void AddHotkeyLabels(uGUI_QuickSlots instance)
        {
            if (instance == null || !Mod.config.ShowInputText)
            {
                tryAddLabels = true;
                return;
            }

            uGUI_ItemIcon[] icons = (uGUI_ItemIcon[])uGUI_QuickSlots_icons.GetValue(instance);
            if (icons == null || icons.Length == 0)
            {
                tryAddLabels = true;
                return;
            }

            Text textPrefab = GetTextPrefab();

            if (textPrefab == null)
            {
                tryAddLabels = true;
                return;
            }

            for (int i = 0; i < icons.Length; ++i)
            {
                uGUI_ItemIcon icon = icons[i];
                var           text = CreateNewText(textPrefab, icon.transform, Mod.GetInputForSlot(i), i);
            }
            tryAddLabels = false;
        }
        public void ConnectToInventory(Dictionary <InventoryItem, uGUI_ItemIcon> lookup)
        {
            this.InventoryMapping = lookup;

            (BioReactor.container as IItemsContainer).onAddItem += OnAddItemLate;

            if (MaterialsProcessing.Count == 0)
            {
                return;
            }

            foreach (KeyValuePair <InventoryItem, uGUI_ItemIcon> pair in lookup)
            {
                InventoryItem item = pair.Key;
                uGUI_ItemIcon icon = pair.Value;

                BioEnergy bioEnergy = MaterialsProcessing.Find(m => m.Pickupable == item.item);

                if (bioEnergy is null)
                {
                    continue;
                }

                bioEnergy.AddDisplayText(icon);
            }
        }
예제 #5
0
        public void ConnectToInventory(Dictionary <InventoryItem, uGUI_ItemIcon> lookup)
        {
            this.InventoryMapping = lookup;

            (Container as IItemsContainer).onAddItem += OnAddItemLate;

            if (this.MaterialsProcessing.Count == 0)
            {
                return;
            }

            foreach (KeyValuePair <InventoryItem, uGUI_ItemIcon> pair in lookup)
            {
                InventoryItem item = pair.Key;
                uGUI_ItemIcon icon = pair.Value;

                BioEnergy bioEnergy = this.MaterialsProcessing.Find(item.item);

                if (bioEnergy is null)
                {
                    QuickLogger.Debug("Matching pickable in bioreactor not found", true);
                    continue;
                }

                bioEnergy.AddDisplayText(icon);
            }
        }
예제 #6
0
        public void AddHotkeyLabels(uGUI_QuickSlots instance)
        {
            if (instance == null || !instance.gameObject.activeSelf || !instance.gameObject.activeInHierarchy)
            {
                return;
            }

            Text textPrefab = GetTextPrefab();

            if (textPrefab == null)
            {
                return;
            }

            uGUI_ItemIcon[] icons = (uGUI_ItemIcon[])uGUI_QuickSlots_icons.GetValue(instance);
            if (icons == null || icons.Length == 0)
            {
                return;
            }

            for (int i = 0; i < icons.Length; ++i)
            {
                uGUI_ItemIcon icon = icons[i];
                var           text = CreateNewText(textPrefab, icon.transform, Mod.GetInputForSlot(i), i);
            }

            createdLabels = true;
        }
        public void AddDisplayText(uGUI_ItemIcon icon)
        {
            // This code was made possible with the help of Waisie Milliams Hah

            var textGO = new GameObject("EnergyLabel");

            textGO.transform.parent = icon.transform;
            textGO.AddComponent <Text>();

            Text text = textGO.GetComponent <Text>();

            text.font      = arialFont;
            text.material  = arialFont.material;
            text.text      = string.Empty;
            text.fontSize  = 16;
            text.alignment = TextAnchor.MiddleCenter;
            text.color     = Color.white;

            Outline outline = textGO.AddComponent <Outline>();

            outline.effectColor = Color.black;

            RectTransform rectTransform = text.GetComponent <RectTransform>();

            rectTransform.localScale         = Vector3.one;
            rectTransform.anchoredPosition3D = Vector3.zero;

            InfoDisplay = text;
        }
예제 #8
0
 public NuclearIconOverlay(uGUI_ItemIcon icon, InventoryItem upgradeModule)
     : base(icon, upgradeModule)
 {
     upgradeHandler = MCUServices.Find.CyclopsUpgradeHandler <NuclearUpgradeHandler>(base.Cyclops, base.TechType);
     chargeHandler  = MCUServices.Find.CyclopsCharger <NuclearChargeHandler>(base.Cyclops);
     battery        = base.Item.item.GetComponent <Battery>();
 }
예제 #9
0
        public EngineOverlay(uGUI_ItemIcon icon, InventoryItem upgradeModule) : base(icon, upgradeModule)
        {
            engineHandler = MCUServices.Find.CyclopsGroupUpgradeHandler <EngineHandler>(base.Cyclops, TechType.PowerUpgradeModule);

            techTypeInSlot = upgradeModule.item.GetTechType();
            tierString     = $"MK{engineHandler.TierValue(techTypeInSlot)}";
            tierRating     = $"[Bonus Efficiency]\n{Mathf.RoundToInt(engineHandler.EngineRating(techTypeInSlot) * 100f)}%";
        }
예제 #10
0
 // Token: 0x0600001F RID: 31 RVA: 0x00002637 File Offset: 0x00000837
 protected override void OnStart(uGUI_ItemIcon actor)
 {
     if (actor == null)
     {
         return;
     }
     actor.SetAlpha(0f, 0f, 0f);
     actor.enabled = false;
 }
예제 #11
0
 private static void SetIconColors(uGUI_ItemIcon icon, Color frontColor, Color backColor)
 {
     if (!icon)
     {
         return;
     }
     icon.SetForegroundColors(frontColor, frontColor, frontColor);
     icon.SetBackgroundColors(backColor, backColor, backColor);
 }
예제 #12
0
 protected override void OnStart(uGUI_ItemIcon actor)
 {
     if (Object.op_Equality((Object)actor, (Object)null))
     {
         return;
     }
     actor.SetAlpha(0.0f, 0.0f, 0.0f);
     ((Behaviour)actor).set_enabled(false);
 }
        private void AddDisplayText(InventoryItem item, uGUI_ItemIcon icon)
        {
            SlotData slotData = reactorRodData.Find(rod => rod.Item == item.item);

            if (slotData != null)
            {
                slotData.AddDisplayText(icon);
            }
        }
        private void Init(IIngredient ingredient, Atlas.Sprite sprite, bool first, bool last)
        {
            this.ingredient = ingredient;
            bool mainIcon = ingredient == null;

            var quickSlots = GameObject.FindObjectOfType <uGUI_QuickSlots>();
            var bgSprite   = first ? quickSlots.spriteLeft : last ? quickSlots.spriteRight : quickSlots.spriteCenter;

            (transform as RectTransform).SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, bgSprite.rect.width);
            (transform as RectTransform).SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, bgSprite.rect.height);

            layout           = gameObject.AddComponent <LayoutElement>();
            layout.minWidth  = bgSprite.rect.width;
            layout.minHeight = bgSprite.rect.height;

            background               = gameObject.AddComponent <Image>();
            background.color         = new Color(1, 1, 1, Mod.config.BackgroundAlpha);
            background.raycastTarget = false;
            background.material      = quickSlots.materialBackground;
            background.sprite        = bgSprite;

            icon = new GameObject("Icon").AddComponent <uGUI_ItemIcon>();
            icon.transform.SetParent(transform, false);
            icon.SetForegroundSprite(sprite);
            if (mainIcon)
            {
                icon.SetSize(Width, Width);
            }
            else
            {
                icon.SetSize(IconWidth, IconWidth);
            }
            icon.rectTransform.anchorMin        = new Vector2(0.5f, 0.5f);
            icon.rectTransform.anchorMax        = new Vector2(0.5f, 0.5f);
            icon.rectTransform.pivot            = new Vector2(0.5f, 0.5f);
            icon.rectTransform.anchoredPosition = new Vector2(0, 0);
            icon.raycastTarget = false;

            if (!mainIcon)
            {
                text = ModUtils.InstantiateNewText("Text", transform);
                RectTransformExtensions.SetSize(text.rectTransform, Width, Width);
                text.rectTransform.anchorMin        = new Vector2(0.5f, 0);
                text.rectTransform.anchorMax        = new Vector2(0.5f, 0);
                text.rectTransform.pivot            = new Vector2(0.5f, 0);
                text.rectTransform.anchoredPosition = new Vector2(0, 0);
                text.alignment     = TextAnchor.LowerCenter;
                text.fontSize      = Mod.config.FontSize;
                text.raycastTarget = false;

                ColorUtility.TryParseHtmlString(Mod.config.ColorblindMode ? IngredientColorGoodColorblind : IngredientColorGood, out goodColor);
                ColorUtility.TryParseHtmlString(Mod.config.ColorblindMode ? IngredientColorBadColorblind : IngredientColorBad, out badColor);
            }

            UpdateText();
        }
예제 #15
0
 protected override void OnStop(uGUI_ItemIcon actor)
 {
     if (Object.op_Equality((Object)actor, (Object)null))
     {
         return;
     }
     ((Graphic)actor).get_rectTransform().set_anchoredPosition(this._targetPosition);
     actor.SetAlpha(1f, 1f, 1f);
     ((Behaviour)actor).set_enabled(true);
 }
예제 #16
0
 // Token: 0x06000021 RID: 33 RVA: 0x000026FF File Offset: 0x000008FF
 protected override void OnStop(uGUI_ItemIcon actor)
 {
     if (actor == null)
     {
         return;
     }
     actor.rectTransform.anchoredPosition = this._targetPosition;
     actor.SetAlpha(1f, 1f, 1f);
     actor.enabled = true;
 }
        public BoosterOverlay(uGUI_ItemIcon icon, InventoryItem upgradeModule)
            : base(icon, upgradeModule)
        {
            chargeHandler  = MCUServices.Find.CyclopsCharger <BioChargeHandler>(base.Cyclops);
            upgradeHandler = MCUServices.Find.CyclopsUpgradeHandler <BioBoosterUpgradeHandler>(base.Cyclops, base.TechType);
            cyclopsManager = MCUServices.Find.AuxCyclopsManager <BioAuxCyclopsManager>(base.Cyclops);

            reactorCount  = cyclopsManager.TrackedBuildablesCount;
            maxedReactors = reactorCount == BioAuxCyclopsManager.MaxBioReactors;
        }
예제 #18
0
            private static void AnimateIconColor(uGUI_ItemIcon icon, Color frontColor, Color backColor)
            {
                if (!icon)
                {
                    return;
                }
                var anim = new IconColorAnimation(frontColor, backColor, AnimationDuration);

                anim.Play(icon);
            }
예제 #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IconOverlay"/> class.
        /// </summary>
        /// <param name="icon">The PDA icon.</param>
        /// <param name="upgradeModule">The upgrade module item.</param>
        protected IconOverlay(uGUI_ItemIcon icon, InventoryItem upgradeModule)
        {
            Item     = upgradeModule;
            TechType = upgradeModule.item.GetTechType();
            Icon     = icon;
            Cyclops  = Player.main.currentSub;

            UpperText  = upper = new IconOverlayText(icon, TextAnchor.UpperCenter);
            MiddleText = middle = new IconOverlayText(icon, TextAnchor.MiddleCenter);
            LowerText  = lower = new IconOverlayText(icon, TextAnchor.LowerCenter);
        }
예제 #20
0
        private static void ConnectToInventory(uGUI_Equipment equipmentUI)
        {
            foreach (KeyValuePair <InventoryItem, uGUI_EquipmentSlot> pair in equipmentUI.items)
            {
                InventoryItem item = pair.Key;

                if (OverlayCreators.TryGetValue(item.item.GetTechType(), out CreateIconOverlay creator))
                {
                    uGUI_ItemIcon icon = pair.Value.icon;
                    ActiveOverlays.Add(creator.Invoke(icon, item));
                }
            }
        }
예제 #21
0
 static void setLocked(this uGUI_ItemIcon icon, bool locked)
 {
     if (locked)
     {
         icon.OnLock();
         icon.manager = null;
     }
     else
     {
         icon.OnUnlock();
         icon.manager = getToolbar();
     }
 }
            private static void Postfix(uGUI_CraftNode __instance)
            {
                RadialCell    radialCell = RadialCell.Create(__instance);
                uGUI_ItemIcon icon       = __instance.get_icon();
                Vector2       vector2;

                ((Vector2) ref vector2).\u002Ector(radialCell.size, radialCell.size);
                icon.SetBackgroundSize(vector2);
                icon.SetActiveSize(vector2);
                float num = radialCell.size * (float)Config.IconForegroundSizeMult;

                icon.SetForegroundSize(num, num, true);
                icon.SetBackgroundRadius(radialCell.size / 2f);
                ((Transform)((Graphic)icon).get_rectTransform()).SetParent((Transform)uGUI_CraftNodeReflector.GetView(__instance).iconsCanvas);
                icon.SetPosition(radialCell.parent.Position);
            }
        internal void ConnectToContainer(Dictionary <InventoryItem, uGUI_ItemIcon> lookup)
        {
            _slotMapping = lookup;

            RodsContainer.onAddItem += OnAddItemLate;

            foreach (KeyValuePair <InventoryItem, uGUI_ItemIcon> pair in lookup)
            {
                InventoryItem item = pair.Key;
                uGUI_ItemIcon icon = pair.Value;

                AddDisplayText(item, icon);
            }

            UpdateDisplayText(true);
        }
예제 #24
0
 // Token: 0x06000038 RID: 56 RVA: 0x000029CC File Offset: 0x00000BCC
 public static void Play(uGUI_ItemIcon actor, ItemIconAnimation newAnimation)
 {
     if (actor == null)
     {
         throw new ArgumentNullException("actor is null");
     }
     if (newAnimation == null)
     {
         throw new ArgumentNullException("newAnimation is null");
     }
     ItemIconAnimation.InitializeUpdater();
     if (ItemIconAnimation.animations.ContainsKey(actor))
     {
         ItemIconAnimation.animations[actor].OnStop(actor);
     }
     ItemIconAnimation.animations[actor] = newAnimation;
     newAnimation.OnStart(actor);
 }
예제 #25
0
        protected override bool OnUpdate(uGUI_ItemIcon actor)
        {
            if (Object.op_Equality((Object)actor, (Object)null))
            {
                return(false);
            }
            Vector2 vector2_1 = Vector2.MoveTowards(((Graphic)actor).get_rectTransform().get_anchoredPosition(), this._targetPosition, this._speed * Time.get_deltaTime());

            ((Graphic)actor).get_rectTransform().set_anchoredPosition(vector2_1);
            Vector2 vector2_2 = Vector2.op_Subtraction(vector2_1, this._targetPosition);
            float   magnitude = ((Vector2) ref vector2_2).get_magnitude();
            float   num       = Mathf.Pow(Mathf.Max((float)(1.0 - (double)magnitude / (double)this._fadeDistance), 0.0f), (float)Config.AnimationFadePower);

            actor.SetAlpha(num, num, num);
            if ((double)magnitude >= 1.0 / 1000.0)
            {
                return(true);
            }
            ((Behaviour)actor).set_enabled(true);
            return(false);
        }
예제 #26
0
        internal static bool Prefix(uGUI_QuickSlots __instance, ref uGUI_ItemIcon icon, TechType techType, bool highlighted)
        {
            if (TechData.GetEquipmentType(techType) == (EquipmentType)ModdedEquipmentType.SeatruckArm)
            {
                if (icon == null)
                {
                    return(false);
                }

                if (spriteExosuitArm == null)
                {
                    spriteExosuitArm = Object.Instantiate(__instance.spriteExosuitArm);
                }

                icon.SetBackgroundSprite(spriteExosuitArm);

                return(false);
            }

            return(true);
        }
예제 #27
0
        internal static bool Prefix(uGUI_QuickSlots __instance, ref uGUI_ItemIcon icon, TechType techType, bool highlighted)
        {
            if (CraftData.GetEquipmentType(techType) == (EquipmentType)100)
            {
                if (icon == null)
                {
                    return(false);
                }

                if (atlasSpriteExosuitArm == null)
                {
                    atlasSpriteExosuitArm = new Atlas.Sprite(__instance.spriteExosuitArm, false);
                }

                icon.SetBackgroundSprite(atlasSpriteExosuitArm);

                return(false);
            }

            return(true);
        }
예제 #28
0
        // Token: 0x06000020 RID: 32 RVA: 0x00002660 File Offset: 0x00000860
        protected override bool OnUpdate(uGUI_ItemIcon actor)
        {
            if (actor == null)
            {
                return(false);
            }
            Vector2 vector = actor.rectTransform.anchoredPosition;

            vector = Vector2.MoveTowards(vector, this._targetPosition, this._speed * Time.deltaTime);
            actor.rectTransform.anchoredPosition = vector;
            float magnitude = (vector - this._targetPosition).magnitude;
            float num       = Mathf.Max(1f - magnitude / this._fadeDistance, 0f);

            num = Mathf.Pow(num, (float)Config.AnimationFadePower);
            actor.SetAlpha(num, num, num);
            if (magnitude < 0.001f)
            {
                actor.enabled = true;
                return(false);
            }
            return(true);
        }
예제 #29
0
 public AutoDefenseMk2IconOverlay(uGUI_ItemIcon icon, InventoryItem upgradeModule) : base(icon, upgradeModule)
 {
     zapper = MCUServices.Find.AuxCyclopsManager <AutoDefenserMk2>(base.Cyclops);
 }
 public ZapperIconOverlay(TechType zapperTechType, uGUI_ItemIcon icon, InventoryItem upgradeModule) : base(icon, upgradeModule)
 {
     zapper = MCUServices.Find.AuxCyclopsManager <Zapper>(base.Cyclops);
 }