示例#1
0
        public override object Run(object[] args, int start = 1)
        {
            if (args.Length - start <= 1)
            {
                ARareItemSwapJPANs.LogError(name, "Requires at least 2 Arguments;\n" + Help());
                return(null);
            }
            Player p = getPlayerFromObject(args[start]);

            if (p == null)
            {
                ARareItemSwapJPANs.LogError(name, "Invalid player");
                return(null);
            }
            PartsPlayer pp = p.GetModPlayer <PartsPlayer>();

            if (pp == null)
            {
                ARareItemSwapJPANs.LogError(name, "Invalid player");
                return(null);
            }
            Item itm = getItemFromObject(args[start + 1]);

            if (itm == null)
            {
                ARareItemSwapJPANs.LogError(name, "Invalid item for part: null");
                return(null);
            }

            long total = pp.getPartAmount(ARareItemSwapJPANs.ItemToTag(itm));

            if (total == -1)
            {
                ARareItemSwapJPANs.LogError(name, "Invalid item for part: item is not a part");
                return(null);
            }

            if (args.Length - start > 2)
            {
                long?toCheck = getLongFromObject(args[start + 2]);
                if (toCheck == null || !toCheck.HasValue)
                {
                    ARareItemSwapJPANs.LogError(name, "Invalid long for count");
                    return(null);
                }
                return(pp.decreasePart(ARareItemSwapJPANs.ItemToTag(itm), toCheck.Value));
            }
            else
            {
                return(pp.decreasePart(ARareItemSwapJPANs.ItemToTag(itm)));
            }
        }
示例#2
0
        public void whileMouseHovering()
        {
            PartsPlayer p = Main.player[Main.myPlayer].GetModPlayer <PartsPlayer>();

            if (Main.mouseLeftRelease && Main.mouseLeft)
            {
                if (Main.mouseItem == null || Main.mouseItem.type == 0)
                {
                    Main.mouseItem = ARareItemSwapJPANs.getItemFromTag(partTag);
                    if (p.getPartAmount(partTag) >= Main.mouseItem.maxStack)
                    {
                        Main.mouseItem.stack = Main.mouseItem.maxStack;
                        p.decreasePart(partTag, Main.mouseItem.maxStack);
                    }
                    else if (p.getPartAmount(partTag) > 0)
                    {
                        Main.mouseItem.stack = (int)p.getPartAmount(partTag);
                        p.decreasePart(partTag, p.getPartAmount(partTag));
                    }
                    else
                    {
                        Main.mouseItem.TurnToAir();
                    }
                }
                else
                {
                    if (p.addPart(Main.mouseItem))
                    {
                        Main.mouseItem.TurnToAir();
                    }
                }
            }
            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)
                    {
                        if (p.decreasePart(partTag) != -1)
                        {
                            Main.mouseItem       = ARareItemSwapJPANs.getItemFromTag(partTag);
                            Main.mouseItem.stack = 1;
                        }
                    }
                    else
                    {
                        if (Main.mouseItem.stack <= Main.mouseItem.maxStack && ARareItemSwapJPANs.ItemToTag(Main.mouseItem).Equals(partTag))
                        {
                            if (p.decreasePart(partTag) != -1)
                            {
                                Main.mouseItem.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;
                    }
                }
            }
        }