コード例 #1
0
 internal ShopPackItemDefinition(ShopPackItemDefinition clone)
 {
     this.ItemDef = clone.ItemDef != null ?
                    new ItemDefinition(clone.ItemDef.mod, clone.ItemDef.name) :
                    null;
     this.Stack            = clone.Stack;
     this.CrimsonWorldOnly = clone.CrimsonWorldOnly;
 }
コード例 #2
0
        ////////////////

        public int GetItemTypeOfIcon()
        {
            if (this.Info == null)
            {
                return(-1);
            }

            try {
                var    info = (ShopPackDefinition)this.Info;
                string _;
                if (!info.Validate(out _))
                {
                    return(-1);
                }

                int count = info.Items.Count;
                for (int i = 0; i < count; i++)
                {
                    ShopPackItemDefinition itemInfo = info.Items[i];
                    int bagItemType = itemInfo.ItemDef?.Type ?? 0;

                    if (bagItemType <= 0)
                    {
                        continue;
                    }
                    if (bagItemType >= Main.itemTexture.Length)
                    {
                        continue;
                    }
                    if (Main.itemTexture[bagItemType] == null)
                    {
                        continue;
                    }

                    return(bagItemType);
                }
            } catch (Exception e) {
                LogHelpers.WarnOnce("!!3 " + e.ToString());
            }

            return(-1);
        }
コード例 #3
0
 public bool IsSameAs(ShopPackItemDefinition itemDef)
 {
     if (this.ItemDef == null)
     {
         return(false);
     }
     if (!this.ItemDef.Equals(itemDef.ItemDef))
     {
         return(false);
     }
     if (this.Stack != itemDef.Stack)
     {
         return(false);
     }
     if (this.CrimsonWorldOnly != itemDef.CrimsonWorldOnly)
     {
         return(false);
     }
     return(true);
 }
コード例 #4
0
        public override void ModifyTooltips(List <TooltipLine> tooltips)
        {
            if (this.Info == null)
            {
                return;
            }

            var info       = (ShopPackDefinition)this.Info;
            var itemSetTip = new TooltipLine(this.mod, "Items", "Items included:");

            try {
                tooltips.RemoveRange(1, tooltips.Count - 1);
                tooltips.Add(itemSetTip);

                int count = info.Items.Count;
                for (int i = 0; i < count; i++)
                {
                    ShopPackItemDefinition packItemDef = info.Items[i];
                    if (packItemDef == null)
                    {
                        LogHelpers.WarnOnce("Invalid pack item for " + this.DisplayName + " at " + i);
                        continue;
                    }

                    ItemDefinition itemDef = packItemDef.ItemDef;
                    if (itemDef == null || itemDef.Type == 0)
                    {
                        LogHelpers.WarnOnce("Undefined pack item for " + this.DisplayName + " at " + i);
                        continue;
                    }

                    Item item = new Item();
                    item.SetDefaults(itemDef.Type, true);
                    item.stack = packItemDef.Stack;

                    var itemTip = new TooltipLine(this.mod, "Item " + i, "  " + item.HoverName);

                    Color rarityColor;
                    if (ItemRarityAttributeHelpers.RarityColor.TryGetValue(item.rare, out rarityColor))
                    {
                        itemTip.overrideColor = rarityColor;
                    }

                    tooltips.Add(itemTip);
                }
            } catch (Exception e) {
                LogHelpers.WarnOnce("!!1 " + e.ToString());
            }

            try {
                Color tipColor = info.Price <= 10 ?
                                 Colors.CoinCopper :
                                 (info.Price < 100 ?
                                  Colors.CoinSilver :
                                  (info.Price < 1000 ?
                                   Colors.CoinGold :
                                   Colors.CoinPlatinum));
                var ppTip = new TooltipLine(this.mod, "Custom Price", "Buy price: " + info.Price + " progress points")
                {
                    overrideColor = tipColor
                };
                tooltips.Add(ppTip);

                var instructTip = new TooltipLine(this.mod, "Items", "Click to purchase");
                tooltips.Add(instructTip);
            } catch (Exception e) {
                LogHelpers.WarnOnce("!!2 " + e.ToString());
            }
        }