Ejemplo n.º 1
0
        public override void whileMouseHovering()
        {
            PartsPlayer p = Main.player[Main.myPlayer].GetModPlayer <PartsPlayer>();

            if (Main.mouseLeftRelease && Main.mouseLeft)
            {
                if (Main.mouseItem == null || Main.mouseItem.type == 0)
                {
                    if (!isSelected)
                    {
                        ((ARareItemSwapJPANs)ModLoader.GetMod("ARareItemSwapJPANs")).ExchangeUISelectRecipe(recipe);
                    }
                    else
                    {
                        Main.mouseItem = recipe.Purchase(p);
                    }
                }
                else
                {
                    recipe.refund(p, ref Main.mouseItem);
                }
            }
            else if (Main.stackSplit <= 1 && Main.mouseRight)
            {
                if (item.maxStack >= 1 && (Main.mouseItem.IsTheSameAs(item) || Main.mouseItem.type == 0) && (Main.mouseItem.stack < Main.mouseItem.maxStack || Main.mouseItem.type == 0))
                {
                    if (Main.mouseItem.type == 0)
                    {
                        Main.mouseItem = recipe.Purchase(p);
                    }
                    else
                    {
                        if (Main.mouseItem.stack + recipe.result.stack <= Main.mouseItem.maxStack)
                        {
                            Item purchased = recipe.Purchase(p);
                            if (!purchased.IsAir)
                            {
                                Main.mouseItem.stack += purchased.stack;
                            }
                        }
                    }
                    Recipe.FindRecipes();
                    Main.soundInstanceMenuTick.Stop();
                    Main.soundInstanceMenuTick = Main.soundMenuTick.CreateInstance();
                    Main.PlaySound(12, -1, -1, 1, 1f, 0f);
                    if (Main.stackSplit == 0)
                    {
                        Main.stackSplit = 15;
                    }
                    else
                    {
                        Main.stackSplit = Main.stackDelay;
                    }
                }
            }
            Main.hoverItemName = item.Name;
            string hoverItemName = Main.hoverItemName;

            Main.hoverItemName = hoverItemName + " ( " + item.stack + ")\nCosts:\n";
            foreach (Item pr in recipe.parts)
            {
                Main.hoverItemName += " - " + pr.Name + " (" + pr.stack + ");\n";
            }
            if (recipe.irreversible)
            {
                Main.hoverItemName += "IRREVERSIBLE!";
            }
            if (ModLoader.GetMod("ResearchFrom14") != null)
            {
                Mod rmod       = ModLoader.GetMod("ResearchFrom14");
                int?toResearch = (rmod.Call("isresearched", p.player, item)) as int?;
                if (toResearch != null)
                {
                    if (toResearch < 0)
                    {
                        Main.hoverItemName += "\nUnresearchable!";
                    }
                    else if (toResearch == 0)
                    {
                        Main.hoverItemName += "\nResearched!";
                    }
                    else
                    {
                        Main.hoverItemName += "\nResearch " + toResearch + " more to unlock.";
                    }
                }
            }
        }