コード例 #1
0
 /// <summary>
 /// Call in <see cref="ModItem.SetDefaults"/> for a clicker item to make it display total money generated by item
 /// </summary>
 /// <param name="item">The clicker class item</param>
 public static void SetDisplayMoneyGenerated(Item item)
 {
     if (ClickerSystem.IsClickerItem(item, out ClickerItemCore clickerItem))
     {
         clickerItem.isClickerDisplayMoneyGenerated = true;
     }
 }
コード例 #2
0
 /// <summary>
 /// Call in <see cref="ModItem.SetDefaults"/> for a clicker item to make it display total click count in the tooltip
 /// </summary>
 /// <param name="item">The clicker class item</param>
 public static void SetDisplayTotalClicks(Item item)
 {
     if (ClickerSystem.IsClickerItem(item, out ClickerItemCore clickerItem))
     {
         clickerItem.isClickerDisplayTotal = true;
     }
 }
コード例 #3
0
        public override void OnSpawn(Projectile projectile, IEntitySource source)
        {
            if (source is not EntitySource_ItemUse_WithAmmo itemSource || !ClickerSystem.IsClickerItem(itemSource.Item))
            {
                return;
            }

            projectile.DamageType = ModContent.GetInstance <ClickerDamage>();
            projectile.penetrate  = -1;            //3 by default
            projectile.timeLeft   = 190;           //240 by default, this controls its behavior: 140 starts homing
        }
コード例 #4
0
        public override void ModifyTooltips(Item item, List <TooltipLine> tooltips)
        {
            if (ClickerSystem.IsClickerItem(item))
            {
                Player player        = Main.LocalPlayer;
                var    clickerPlayer = player.GetModPlayer <ClickerPlayer>();
                int    index;

                float alpha = Main.mouseTextColor / 255f;

                if (ClickerConfigClient.Instance.ShowClassTags)
                {
                    index = tooltips.FindIndex(tt => tt.mod.Equals("Terraria") && tt.Name.Equals("ItemName"));
                    if (index != -1)
                    {
                        tooltips.Insert(index + 1, new TooltipLine(mod, "ClickerTag", $"-{LangHelper.GetText("Tooltip.ClickerTag")}-")
                        {
                            overrideColor = Main.DiscoColor
                        });
                    }
                }

                if (isClickerDisplayTotal)
                {
                    index = tooltips.FindIndex(tt => tt.mod.Equals("Terraria") && tt.Name.Equals("Tooltip0"));

                    if (index != -1)
                    {
                        string color = (new Color(252, 210, 44) * alpha).Hex3();
                        tooltips.Add(new TooltipLine(mod, "TransformationText", $"{LangHelper.GetText("Tooltip.TotalClicks")}: [c/{color}:{clickerPlayer.clickerTotal}]"));
                    }
                }

                if (ClickerSystem.IsClickerWeapon(item))
                {
                    TooltipLine tooltip = tooltips.Find(tt => tt.mod.Equals("Terraria") && tt.Name.Equals("Damage"));
                    if (tooltip != null)
                    {
                        string number = tooltip.text.Split(' ')[0];
                        tooltip.text = LangHelper.GetText("Tooltip.ClickDamage", number);
                    }

                    //Show the clicker's effects
                    //Then show ones missing through the players enabled effects (respecting overlap, ignoring the currently held clickers effect if its not the same type)
                    List <string> effects = new List <string>(itemClickEffects);
                    foreach (var name in ClickerSystem.GetAllEffectNames())
                    {
                        if (clickerPlayer.HasClickEffect(name, out ClickEffect effect) && !effects.Contains(name))
                        {
                            if (!(player.HeldItem.type != item.type && player.HeldItem.type != ItemID.None && player.HeldItem.GetGlobalItem <ClickerItemCore>().itemClickEffects.Contains(name)))
                            {
                                effects.Add(name);
                            }
                        }
                    }

                    if (effects.Count > 0)
                    {
                        index = tooltips.FindIndex(tt => tt.mod.Equals("Terraria") && tt.Name.Equals("Knockback"));

                        if (index != -1)
                        {
                            //"Auto Select" key: player.controlTorch

                            var    keys = PlayerInput.CurrentProfile.InputModes[InputMode.Keyboard].KeyStatus[TriggerNames.SmartSelect];
                            string key  = keys.Count == 0 ? null : keys[0];

                            //If has a key, but not pressing it, show the ForMoreInfo text
                            //Otherwise, list all effects

                            bool showDesc = key == null || player.controlTorch;

                            foreach (var name in effects)
                            {
                                if (ClickerSystem.IsClickEffect(name, out ClickEffect effect))
                                {
                                    tooltips.Insert(++index, effect.ToTooltip(clickerPlayer.GetClickAmountTotal(this, name), alpha, showDesc));
                                }
                            }

                            if (!showDesc && ClickerConfigClient.Instance.ShowEffectSuggestion)
                            {
                                //Add ForMoreInfo as the last line
                                index = tooltips.FindLastIndex(tt => tt.mod.Equals("Terraria") && tt.Name.StartsWith("Tooltip"));
                                var ttl = new TooltipLine(mod, "ForMoreInfo", LangHelper.GetText("Tooltip.ForMoreInfo", key))
                                {
                                    overrideColor = Color.Gray
                                };

                                if (index != -1)
                                {
                                    tooltips.Insert(++index, ttl);
                                }
                                else
                                {
                                    tooltips.Add(ttl);
                                }
                            }
                        }
                    }
                }


                if (item.prefix < PrefixID.Count || !ClickerPrefix.ClickerPrefixes.Contains(item.prefix))
                {
                    return;
                }

                int ttindex = tooltips.FindLastIndex(t => (t.mod == "Terraria" || t.mod == mod.Name) && (t.isModifier || t.Name.StartsWith("Tooltip") || t.Name.Equals("Material")));
                if (ttindex != -1)
                {
                    if (radiusBoostPrefix != 0)
                    {
                        TooltipLine tt = new TooltipLine(mod, "PrefixClickerRadius", (radiusBoostPrefix > 0 ? "+" : "") + LangHelper.GetText("Prefix.PrefixClickerRadius.Tooltip", (int)((radiusBoostPrefix / 2) * 100)))
                        {
                            isModifier    = true,
                            isModifierBad = radiusBoostPrefix < 0
                        };
                        tooltips.Insert(++ttindex, tt);
                    }
                    if (radiusBoostPrefix != 0)
                    {
                        TooltipLine tt = new TooltipLine(mod, "PrefixClickBoost", (clickBoostPrefix < 0 ? "" : "+") + LangHelper.GetText("Prefix.PrefixClickBoost.Tooltip", clickBoostPrefix))
                        {
                            isModifier    = true,
                            isModifierBad = clickBoostPrefix > 0
                        };
                        tooltips.Insert(++ttindex, tt);
                    }
                }
            }
        }