コード例 #1
0
        // TODO Load MyEffects then RealEffects so load order doesn't mess things up
        internal void Load()
        {
            string origLoadStage = LoadingHelper.GetLoadStage();

            LoadingHelper.SetLoadStage("Registering ItemEffects...");
            string lastModName = "";

            //ItemsToLoad.Add(ModContent.GetModItem(ModContent.ItemType<Terraria.ModLoader.Default.AprilFools>()));

            for (int i = 0; i < ItemsToLoad.Count; i++)
            {
                ModItem item = ItemsToLoad[i];

                if (item.mod.Name != lastModName)
                {
                    lastModName = item.mod.Name;
                    LoadingHelper.SetSubText(lastModName);
                }

                //Thread.Sleep(5000);

                if (item is ModularEffectItem mItem)
                {
                    mItem.RegisterItemEffects();
                }

                LoadingHelper.SetProgress((float)i / ItemsToLoad.Count);
            }

            LoadingHelper.SetLoadStage(origLoadStage);
            LoadingHelper.SetSubText("");
            LoadingHelper.SetProgress(0f);
            ItemsToLoad.Clear();
        }
コード例 #2
0
        public void Load()
        {
            Loaded  = false;
            Loading = true;

            AveragedValues = new Dictionary <int, int>();

            string origLoadStage = LoadingHelper.GetLoadStage();

            LoadingHelper.SetLoadStage("Averaging treasure bag prices...");

            for (int i = 0; i < ItemLoader.ItemCount; i++)
            {
                Item item = new Item();
                item.SetDefaults(i);

                if ((item.IsVanilla() && !VanillaBossBags.Contains(item.type)) ||
                    (item.modItem != null && item.modItem.BossBagNPC == 0)) // 0 is the default
                {
                    continue;
                }

                Player dummy = new Player(false);

                LoadingHelper.SetSubText(Lang.GetItemName(i).Value);

                TempInfo = new TreasureBagOpeningInfo(1); // I need this one because otherwise it calls the default paramless ctor
                for (int j = 0; j < PboneUtilsConfig.Instance.AverageBossBagsSlider; j++)
                {
                    try
                    {
                        if (item.IsVanilla())
                        {
                            dummy.OpenBossBag(item.type);
                            ItemLoader.OpenVanillaBag("bossBag", dummy, item.type);
                        }
                        else // Modded
                        {
                            item.modItem.OpenBossBag(dummy);
                        }
                    }
                    catch (Exception e)
                    {
                        PboneUtils.Log.Debug($"Non-fatal error '{e}' encountered while averaging treasure bag (ID: {item.type}, Name: {item.Name})");
                        PboneUtils.Log.Debug("Skipping bag...");
                    }
                }

                // TODO values are still 0
                AveragedValues.Add(item.type, (int)TempInfo.GetAverageValue());
            }

            LoadingHelper.SetLoadStage(origLoadStage);
            LoadingHelper.SetSubText("");
            LoadingHelper.SetProgress(0f);

            Loading = false;
            Loaded  = true;
        }