Ejemplo n.º 1
0
 public static bool EndlessStack(BagPickup swag, int type, int index)
 {
     if (!swag.infStack.Contains(type))
     {
         return(swag.contained[index].stack < swag.contained[index].maxStack);
     }
     return(true);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Sets the display list of what is inside the bag; calls SetHoverStorage in CastledPlayer
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="modPlayer"></param>
 /// <param name="bagg"></param>
 public static void SetList(Item bag, CastledPlayer modPlayer, BagPickup bagg)
 {
     if (bag != null && !bag.IsAir && bag.GetGlobalItem <SGlobalItem>().storage != null)
     {
         modPlayer.SetHoverStorage(bag.GetGlobalItem <SGlobalItem>().storage.contained);
     }
     else
     {
         modPlayer.SetHoverStorage(bagg.contained);
     }
 }
Ejemplo n.º 3
0
        public static BagPickup Load(TagCompound tag)
        {
            var bP = new BagPickup(0, false)
            {
                contained        = tag.Get <List <Item> >(nameof(contained)),
                limit            = tag.GetInt(nameof(limit)),
                doPickup         = tag.GetBool(nameof(doPickup)),
                starterBagOpened = tag.GetBool(nameof(starterBagOpened))
            };

            return(bP);
        }
Ejemplo n.º 4
0
        public static void ReplaceItem(BagPickup bag, Item item, int type)
        {
            switch (type)
            {
            case 0:
            {
                item.SetDefaults(ModContent.ItemType <StarterBagNew>());
                item.GetGlobalItem <SGlobalItem>().storage = bag;
            }
            break;

            case 1:
            {
                item.SetDefaults(ModContent.ItemType <ApprenticeBagNew>());
                item.GetGlobalItem <SGlobalItem>().storage = bag;
            }
            break;
            }
        }
Ejemplo n.º 5
0
 public override void UpdateInventory(Player player)
 {
     BagPickup.ReplaceItem(bag, item, 1);
 }
Ejemplo n.º 6
0
 public override void Load(TagCompound tag)
 {
     bag = tag.Get <BagPickup>(nameof(bag));
 }
Ejemplo n.º 7
0
        public static void RollItems(BagPickup bag)
        {
            bool ModLoaded(Mod mod) => mod != null;
            int I(Mod mod, string name) => mod.ItemType(name);

            Mod spirit      = ModLoader.GetMod("SpiritMod");
            Mod split       = ModLoader.GetMod("Split");
            Mod thorium     = ModLoader.GetMod("ThoriumMod");
            Mod calamity    = ModLoader.GetMod("CalamityMod");
            Mod clicker     = ModLoader.GetMod("ClickerClass");
            Mod joost       = ModLoader.GetMod("JoostMod");
            int chosenClass = Main.rand.Next(4);

            if (ModLoaded(thorium))
            {
                chosenClass += 2;
            }
            if (ModLoaded(clicker))
            {
                chosenClass++;
            }
            List <int> melee = new List <int>
            {
                ItemID.WoodenSword
            };
            List <int> ranged = new List <int>
            {
                ItemID.WoodenBow
            };
            List <int> magic = new List <int>
            {
                ItemID.WandofSparking
            };
            List <int> summon = new List <int>
            {
                ItemID.SlimeStaff
            };
            List <int> misc = new List <int>();
            List <int> acc  = new List <int>
            {
                WorldGen.CopperTierOre == 7 ? ItemID.CopperWatch : ItemID.TinWatch
            };

            if (ModLoaded(spirit))
            {
                summon.Remove(ItemID.SlimeStaff);
                melee.Remove(ItemID.WoodenSword);
                melee.Add(I(spirit, "HuskstalkSword"));
                ranged.Add(I(spirit, "HuskstalkBow"));
                melee.Add(I(spirit, "WoodenClub"));
                magic.Add(I(spirit, "CactusStaff"));
                summon.Add(I(spirit, "OvergrowthStaff"));
                acc.Add(I(spirit, "Rabbit_Foot"));
            }
            if (ModLoaded(split))
            {
                melee.Add(I(split, "WoodenRacquet"));
            }
            if (ModLoaded(thorium))
            {
                misc.Add(I(thorium, "WoodenBaton"));
                misc.Add(I(thorium, "WoodenWhistle"));
                acc.Add(I(thorium, WorldGen.CopperTierOre == 7 ? "CopperBuckler" : "CopperBuckler"));
            }
            if (ModLoaded(clicker))
            {
                misc.Add(I(clicker, "WoodenClicker"));
            }
            if (ModLoaded(calamity))
            {
                summon.Remove(ItemID.SlimeStaff);
                melee.Add(I(calamity, "WulfrumBlade"));
                ranged.Add(I(calamity, "WulfrumBow"));
                magic.Add(I(calamity, "WulfrumWand"));
                summon.Add(I(calamity, "SquirrelSquireStaff"));
                summon.Add(I(calamity, "WulfrumController"));
            }
            if (ModLoaded(joost))
            {
                summon.Remove(ItemID.SlimeStaff);
                magic.Add(I(joost, "EmberWand"));
                summon.Add(I(joost, "EmberStaff"));
            }
            #region Fill the bag (First Part)
            bag.contained.Clear();
            Item weapon    = new Item();
            Item accessory = new Item();
            accessory.SetDefaults(Main.rand.Next(acc));
            switch (chosenClass)
            {
            case 0:
                weapon.SetDefaults(Main.rand.Next(melee));
                break;

            case 1:
                weapon.SetDefaults(Main.rand.Next(ranged));
                break;

            case 2:
                weapon.SetDefaults(Main.rand.Next(magic));
                break;

            case 3:
                weapon.SetDefaults(Main.rand.Next(summon));
                break;
            }
            if (ModLoaded(thorium) && misc.Contains(I(thorium, "WoodenBaton")) && CustomClass())
            {
                weapon.SetDefaults(I(thorium, "WoodenBaton"));
            }
            if (ModLoaded(thorium) && misc.Contains(I(thorium, "WoodenWhistle")) && CustomClass())
            {
                weapon.SetDefaults(I(thorium, "WoodenWhistle"));
            }
            if (ModLoaded(clicker) && misc.Contains(I(clicker, "WoodenClicker")) && CustomClass())
            {
                weapon.SetDefaults(I(clicker, "WoodenClicker"));
            }
            if (weapon.type < ItemID.IronPickaxe)
            {
                RandomItem();
            }
            bag.contained.Add(weapon);
            bag.contained.Add(accessory);
            bool CustomClass() => chosenClass > 3 && Main.rand.NextBool(3);

            void RandomItem()
            {
                int a = Main.rand.Next(3);

                switch (a)
                {
                case 0:
                    weapon.SetDefaults(Main.rand.Next(melee));
                    break;

                case 1:
                    weapon.SetDefaults(Main.rand.Next(ranged));
                    break;

                case 2:
                    weapon.SetDefaults(Main.rand.Next(magic));
                    break;

                case 3:
                    weapon.SetDefaults(Main.rand.Next(summon));
                    break;
                }
            }

            #endregion
            #region Fill the bag (Second Part)
            Item[] set = new Item[3]
            {
                new Item(),
                new Item(),
                new Item()
            };
            set[0].SetDefaults(ModContent.ItemType <ScaffoldTreads>());
            set[1].SetDefaults(ModContent.ItemType <ScaffoldPlate>());
            set[2].SetDefaults(ModContent.ItemType <ScaffoldHeadgear>());
            foreach (Item i in set)
            {
                bag.contained.Add(i);
            }
            #endregion
        }