Exemplo n.º 1
0
        public override void PostWorldGen()
        {
            var  config       = RuinedItemsConfig.Instance;
            byte ruinedPrefix = ModContent.PrefixType <RuinedPrefix>();

            for (int i = 0; i < Main.chest.Length; i++)
            {
                Item[] items = Main.chest[i]?.item;
                if (items == null)
                {
                    continue;
                }

                for (int j = 0; j < items.Length; j++)
                {
                    Item item = items[j];
                    if (item?.active != true)
                    {
                        continue;
                    }

                    if (WorldGen.genRand.NextFloat() > config.Get <float>(nameof(config.WorldGenChestItemRuinPercentChance)))
                    {
                        continue;
                    }

                    if (RuinedPrefix.IsItemRuinable(item))
                    {
                        item.Prefix(ruinedPrefix);
                    }
                }
            }
        }
Exemplo n.º 2
0
        ////////////////

        private void RuinLootDropsIf(NPC npc, IList <int> itemWhos)
        {
            var   config            = RuinedItemsConfig.Instance;
            float npcLootRuinChance = config.Get <float>(nameof(config.NPCLootItemRuinPercentChance));

            byte ruinedPrefix = ModContent.PrefixType <RuinedPrefix>();

            foreach (int itemWho in itemWhos)
            {
                Item item = Main.item[itemWho];
                if (item?.active != true || !RuinedPrefix.IsItemRuinable(item))
                {
                    continue;
                }

                if (Main.rand.NextFloat() <= npcLootRuinChance)
                {
                    item.Prefix(ruinedPrefix);

                    if (Main.netMode == NetmodeID.Server)
                    {
                        NetMessage.SendData(MessageID.SyncItem, -1, -1, null, itemWho);
                    }
                }
            }
        }
Exemplo n.º 3
0
        ////////////////

        private void ProcessBagItem(Player plr, Item item)
        {
            if (RuinedPrefix.IsItemRuinable(item))
            {
                var   config     = RuinedItemsConfig.Instance;
                float ruinChance = config.Get <float>(nameof(config.NPCLootItemRuinPercentChance));

                if (Main.rand.NextFloat() < ruinChance)
                {
                    item.Prefix(ModContent.PrefixType <RuinedPrefix>());
                }
            }
        }
Exemplo n.º 4
0
        public override void PostReforge(Item item)
        {
            if (RuinedPrefix.IsItemRuinable(item))
            {
                var myitem = item.GetGlobalItem <RuinedItemsItem>();

                if (this.RuinReforgeIf(item, RuinedItemsItem.IsCurrentPreReforgeItemRuined))
                {
                    this.RuinReforge(item);
                }

                myitem.IsScrapUsedUpon = false;
            }
        }
Exemplo n.º 5
0
        public override void OnCraft(Item item, Recipe recipe)
        {
            if (!RuinedPrefix.IsItemRuinable(item))
            {
                return;
            }

            var   config          = RuinedItemsConfig.Instance;
            float craftRuinChance = config.Get <float>(nameof(config.CraftRuinPercentChance));

            if (Main.rand.NextFloat() <= craftRuinChance)
            {
                item.Prefix(ModContent.PrefixType <RuinedPrefix>());
            }
        }
Exemplo n.º 6
0
        public override void PostBuyItem(NPC vendor, Item[] shopInventory, Item item)
        {
            if (!RuinedPrefix.IsItemRuinable(item))
            {
                return;
            }

            var   config             = RuinedItemsConfig.Instance;
            float purchaseRuinChance = config.Get <float>(nameof(config.PurchasedItemRuinPercentChance));

            if (purchaseRuinChance <= 0f)
            {
                return;
            }

            if (Main.rand.NextFloat() < purchaseRuinChance)
            {
                item.Prefix(ModContent.PrefixType <RuinedPrefix>());
            }
        }
Exemplo n.º 7
0
 public override bool NeedsSaving(Item item)
 {
     return(RuinedPrefix.IsItemRuinable(item));
 }