public override void Load(TagCompound tag)
        {
            try
            {
                List <string> allQuests = tag.Get <List <string> >("SpiritMod:AllQuests");

                QuestManager.QuestBookUnlocked = tag.Get <bool>("SpiritMod:QuestBookUnlocked");

                for (int i = 0; i < QuestManager.Quests.Count; i++)
                {
                    Quest quest = QuestManager.Quests[i];

                    quest.ResetEverything();

                    // get the key for this quest
                    string key = "SpiritMod:" + quest.QuestName;
                    if (!tag.ContainsKey(key))
                    {
                        bool failed = true;
                        foreach (string s in quest._altNames)
                        {
                            key = "SpiritMod:" + s;
                            if (tag.ContainsKey(key))
                            {
                                failed = false;
                                break;
                            }
                        }

                        if (failed)
                        {
                            // this quest doesn't exist at all, so skip.
                            continue;
                        }
                    }

                    StoredQuestData data = ConvertBack(tag.Get <TagCompound>(key));

                    quest.IsUnlocked   = data.IsUnlocked;
                    quest.IsCompleted  = data.IsCompleted;
                    quest.RewardsGiven = data.RewardsGiven;

                    if (data.IsActive)
                    {
                        QuestManager.ActivateQuest(quest);
                        quest.ReadFromDataBuffer(data.Buffer);
                    }

                    quest.ActiveTime = data.TimeLeftActive;
                    quest.UnlockTime = data.TimeLeftUnlocked;

                    if (allQuests.Contains(key))
                    {
                        allQuests.Remove(key);
                    }
                }

                // get all the unloaded quests
                QuestManager.UnloadedQuests.Clear();
                for (int i = 0; i < allQuests.Count; i++)
                {
                    QuestManager.UnloadedQuests.Add(allQuests[i], ConvertBack(tag.Get <TagCompound>(allQuests[i])));
                }
            }
            catch (Exception e)
            {
                SpiritMod.Instance.Logger.Error("Error loading quests! Error:\n" + e);
            }
        }
Exemple #2
0
        public override void SetupShop(int type, Chest shop, ref int nextSlot)
        {
            if (type == NPCType <RuneWizard>() && QuestManager.GetQuest <FirstAdventure>().IsCompleted&& !Main.dayTime)
            {
                shop.item[nextSlot++].SetDefaults(ItemType <OccultistMap>(), false);
            }

            if (type == NPCID.Stylist)
            {
                if (QuestManager.GetQuest <StylistQuestSeafoam>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <Items.Sets.DyesMisc.HairDye.SeafoamDye>(), false);
                }

                if (QuestManager.GetQuest <StylistQuestMeteor>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <Items.Sets.DyesMisc.HairDye.MeteorDye>(), false);
                }
                if (QuestManager.GetQuest <StylistQuestCorrupt>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <Items.Sets.DyesMisc.HairDye.CystalDye>(), false);
                }
                if (QuestManager.GetQuest <StylistQuestCrimson>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <Items.Sets.DyesMisc.HairDye.ViciousDye>(), false);
                }
            }
            if (type == NPCID.Merchant)
            {
                if (QuestManager.GetQuest <AnglerStatueQuest>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <Items.Placeable.Furniture.GiantAnglerStatue>(), false);
                }
            }
            if (type == NPCID.Demolitionist)
            {
                if (QuestManager.GetQuest <RescueQuestStylist>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <Items.Accessory.LongFuse>(), false);
                }
            }
            if (type == NPCType <Adventurer>())
            {
                if (QuestManager.GetQuest <FirstAdventure>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <DurasilkSheaf>(), false);
                }

                if (QuestManager.GetQuest <ExplorerQuestAsteroid>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <ExplorerScrollAsteroidFull>(), false);
                }
                if (QuestManager.GetQuest <ExplorerQuestGranite>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <ExplorerScrollGraniteFull>(), false);
                }
                if (QuestManager.GetQuest <ExplorerQuestMarble>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <ExplorerScrollMarbleFull>(), false);
                }
                if (QuestManager.GetQuest <ExplorerQuestHive>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <ExplorerScrollHiveFull>(), false);
                }
                if (QuestManager.GetQuest <ExplorerQuestMushroom>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <ExplorerScrollMushroomFull>(), false);
                }

                if (QuestManager.GetQuest <CritterCaptureFloater>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <Items.Weapon.Magic.LuminanceSeacone.LuminanceSeacone>(), false);
                }

                if (QuestManager.GetQuest <ManicMage>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <Items.Sets.MagicMisc.Lightspire.AkaviriStaff>(), false);
                }

                if (QuestManager.GetQuest <SkyHigh>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <Tiles.Furniture.JadeDragonStatue.DragonStatueItem>(), false);
                }

                if (QuestManager.GetQuest <SlayerQuestCavern>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <Items.Weapon.Thrown.ClatterSpear>(), false);
                }

                if (QuestManager.GetQuest <ZombieOriginQuest>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <Items.Weapon.Swung.Punching_Bag.Punching_Bag>(), false);
                }

                if (QuestManager.GetQuest <DecrepitDepths>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <SepulchreArrow>(), false);
                    shop.item[nextSlot++].SetDefaults(ItemType <SepulchreBannerItem>(), false);
                    shop.item[nextSlot++].SetDefaults(ItemType <SepulchreChest>(), false);
                }

                if (QuestManager.GetQuest <SkyHigh>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <PottedSakura>(), false);
                    shop.item[nextSlot++].SetDefaults(ItemType <PottedWillow>(), false);
                }
                if (QuestManager.GetQuest <ItsNoSalmon>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <Items.Accessory.KoiTotem>(), false);
                }
                if (QuestManager.GetQuest <SporeSalvage>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <Tiles.Furniture.Critters.VibeshroomJarItem>(), false);
                }
                if (QuestManager.GetQuest <SlayerQuestDrBones>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <Items.Consumable.SeedBag>(), false);
                }
                if (QuestManager.GetQuest <IceDeityQuest>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <Items.Weapon.Thrown.CryoKnife>(), false);
                }
                if (QuestManager.GetQuest <IceDeityQuest>().IsCompleted)
                {
                    shop.item[nextSlot++].SetDefaults(ItemType <Items.Placeable.IceSculpture.IceDeitySculpture>(), false);
                }
            }
            OnSetupShop?.Invoke(type, shop, nextSlot);
        }