예제 #1
0
        public override void RightClick(Item item, Player player)
        {
            bool          addedSlot = false;
            CastledPlayer modP      = player.GetModPlayer <CastledPlayer>();

            if (player.GetModPlayer <CastledPlayer>().SLHighlighting)
            {
                SLHighlight = true;
            }
            if (IsContrabande(item))
            {
                for (int a = 0; a < 254; a++)
                {
                    if (modP.contrabande[a].IsAir)
                    {
                        if (!addedSlot)
                        {
                            //int oldStack = item.stack;
                            Main.PlaySound(SoundID.Item108, player.position);
                            modP.contrabande[a] = item.Clone();
                            if (item.stack > 1)
                            {
                                //oldStack = item.stack;
                                item.stack = 0;
                                //Main.NewText(oldStack);
                            }
                            //modP.contrabande[a].stack = oldStack;
                            //Main.NewText(modP.contrabande[a].Name);
                            //Main.NewText($"{modP.contrabande[a].Name} {modP.contrabande[a].stack}");
                            addedSlot = true;
                            if (ModContent.GetInstance <ClientConfig>().algorithmoMessage)
                            {
                                Main.NewText($"{modP.contrabande[a].Name} {modP.contrabande[a].stack} {a}");
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Several switch cases that determine several values, to discard contrabande automatically. This affects every slot, including banks.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="type"></param>
        public void ForceDiscard(Player player, int type)
        {
            CastledPlayer modP = player.GetModPlayer <CastledPlayer>();

            int Slots()
            {
                switch (type)
                {
                case 1:
                    return(58);

                case 2:
                    return(19);

                case 3:
                    return(9);

                case 4:
                    return(4);

                case 5:
                    return(4);

                case 6:
                    return(40);

                case 7:
                    return(40);

                case 8:
                    return(40);
                }
                return(0);
            }

            bool SlotIsAir(int a)
            {
                switch (type)
                {
                case 1:
                    return(player.inventory[a].IsAir);

                case 2:
                    return(player.armor[a].IsAir);

                case 3:
                    return(player.dye[a].IsAir);

                case 4:
                    return(player.miscEquips[a].IsAir);

                case 5:
                    return(player.miscDyes[a].IsAir);

                case 6:
                    return(player.bank.item[a].IsAir);

                case 7:
                    return(player.bank2.item[a].IsAir);

                case 8:
                    return(player.bank3.item[a].IsAir);
                }
                return(false);
            }

            bool ItemsCheck(int a)
            {
                if (!SlotIsAir(a))
                {
                    switch (type)
                    {
                    case 1:
                        return(player.inventory[a].GetGlobalItem <SGlobalItem>().IsContrabande(player.inventory[a]));

                    case 2:
                        return(player.armor[a].GetGlobalItem <SGlobalItem>().IsContrabande(player.armor[a]));

                    case 3:
                        return(player.dye[a].GetGlobalItem <SGlobalItem>().IsContrabande(player.dye[a]));

                    case 4:
                        return(player.miscEquips[a].GetGlobalItem <SGlobalItem>().IsContrabande(player.miscEquips[a]));

                    case 5:
                        return(player.miscDyes[a].GetGlobalItem <SGlobalItem>().IsContrabande(player.miscDyes[a]));

                    case 6:
                        return(player.bank.item[a].GetGlobalItem <SGlobalItem>().IsContrabande(player.bank.item[a]));

                    case 7:
                        return(player.bank2.item[a].GetGlobalItem <SGlobalItem>().IsContrabande(player.bank2.item[a]));

                    case 8:
                        return(player.bank3.item[a].GetGlobalItem <SGlobalItem>().IsContrabande(player.bank3.item[a]));
                    }
                }
                return(false);
            }

            void Actions(int a, int b, int action)
            {
                switch (action)
                {
                case 1:
                {
                    switch (type)
                    {
                    case 1:
                        modP.contrabande[b] = player.inventory[a].Clone();
                        break;

                    case 2:
                        modP.contrabande[b] = player.armor[a].Clone();
                        break;

                    case 3:
                        modP.contrabande[b] = player.dye[a].Clone();
                        break;

                    case 4:
                        modP.contrabande[b] = player.miscEquips[a].Clone();
                        break;

                    case 5:
                        modP.contrabande[b] = player.miscDyes[a].Clone();
                        break;

                    case 6:
                        modP.contrabande[b] = player.bank.item[a].Clone();
                        break;

                    case 7:
                        modP.contrabande[b] = player.bank2.item[a].Clone();
                        break;

                    case 8:
                        modP.contrabande[b] = player.bank3.item[a].Clone();
                        break;
                    }
                }
                break;

                case 2:
                {
                    switch (type)
                    {
                    case 1:
                        player.inventory[a] = new Item();
                        break;

                    case 2:
                        player.armor[a] = new Item();
                        break;

                    case 3:
                        player.dye[a] = new Item();
                        break;

                    case 4:
                        player.miscEquips[a] = new Item();
                        break;

                    case 5:
                        player.miscDyes[a] = new Item();
                        break;

                    case 6:
                        player.bank.item[a] = new Item();
                        break;

                    case 7:
                        player.bank2.item[a] = new Item();
                        break;

                    case 8:
                        player.bank3.item[a] = new Item();
                        break;
                    }
                    if (LMan.forceDiscard)
                    {
                        LMan.forceDiscard = false;
                        CastledPlayer.serves++;
                    }
                }
                break;
                }
            }

            for (int a = 0; a < Slots(); a++)
            {
                if (ItemsCheck(a))
                {
                    //Main.NewText($"{ItemsCheck(a)} {player.inventory[a].type}");
                    for (int b = 0; b < 254; b++)
                    {
                        //Main.NewText($"{modP.contrabande[b].Name} {addedSlot}");
                        if (modP.contrabande[b].IsAir)
                        {
                            if (!addedSlot)
                            {
                                Main.PlaySound(SoundID.Item108, player.position);
                                Actions(a, b, 1);
                                Actions(a, b, 2);
                                //Main.NewText(modP.contrabande[b].Name);
                                //Main.NewText(modP.contrabande[a].Name);
                                //Main.NewText($"{modP.contrabande[a].Name} {modP.contrabande[a].stack}");
                                addedSlot = true;
                            }
                        }
                    }
                }
            }
        }