示例#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);
                    }
                }
            }
        }
示例#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);
                    }
                }
            }
        }
示例#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>());
                }
            }
        }
示例#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;
            }
        }
示例#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>());
            }
        }
示例#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>());
            }
        }
示例#7
0
 public override bool NeedsSaving(Item item)
 {
     return(RuinedPrefix.IsItemRuinable(item));
 }