private void SaveModdedStuff()
        {
            string path = Path.Combine(Main.ActiveWorldFileData.Path.Replace(".wld", ""), ActiveDimensionName) + "/modded.data";

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            var tag = new Terraria.ModLoader.IO.TagCompound();

            tag["tiles"] = typeof(Main).Assembly.GetType("Terraria.ModLoader.IO.TileIO")
                           .GetMethod("SaveTiles", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { });
            tag["containers"] = typeof(Main).Assembly.GetType("Terraria.ModLoader.IO.TileIO")
                                .GetMethod("SaveContainers", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { });



            var stream = new MemoryStream();

            Terraria.ModLoader.IO.TagIO.ToStream(tag, stream);
            var data = stream.ToArray();

            using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(path)))
            {
                writer.Write(stream.GetBuffer().Length);
                writer.Write(stream.GetBuffer());
            }
        }
Ejemplo n.º 2
0
 public static void Load(Terraria.ModLoader.IO.TagCompound tag, int ModVersion)
 {
     SpawnedTombstone = tag.GetBool("TombstoneExists");
     TombstoneTileX   = tag.GetInt("TombstonePosX");
     TombstoneTileY   = tag.GetInt("TombstonePosY");
     AlexNPCPosition  = NPC.FindFirstNPC(ModContent.NPCType <Npcs.AlexNPC>());
 }
Ejemplo n.º 3
0
        public override void Load(Terraria.ModLoader.IO.TagCompound tag)
        {
            if (!tag.ContainsKey("ModVersion"))
            {
                return;
            }
            int ModVersion = tag.GetInt("ModVersion");

            if (ModVersion < 1)
            {
                return;
            }
            int ClassCount = tag.GetInt("ClassCount");

            Classes.Clear();
            for (int c = 0; c < ClassCount; c++)
            {
                Classes.Add(new ClassData());
                Classes[c].Load(tag, c, ModVersion);
            }
            CombatSkill = LoadSkillSlot(tag, "CombatSkillSlot");
            for (int s = 0; s < 4; s++)
            {
                ActiveSkill[s] = LoadSkillSlot(tag, "ActiveSkillSlot_" + s);
            }
        }
Ejemplo n.º 4
0
        public SkillSlot LoadSkillSlot(Terraria.ModLoader.IO.TagCompound tag, string SkillSlotText)
        {
            SkillSlot ss = new SkillSlot();

            if (tag.GetBool(SkillSlotText + "_Exists"))
            {
                int    ClassID    = tag.GetInt(SkillSlotText + "_ClassID");
                string ClassModID = tag.GetString(SkillSlotText + "_ClassModID");
                int    SkillID    = tag.GetInt(SkillSlotText + "_SkillID");
                string SkillModID = tag.GetString(SkillSlotText + "_SkillModID");
                for (int c = 0; c < Classes.Count; c++)
                {
                    if (Classes[c].ClassID == ClassID && Classes[c].ClassModID == ClassModID)
                    {
                        for (int s = 0; s < Classes[c].Skills.Count; s++)
                        {
                            if (Classes[c].Skills[s].ID == SkillID && Classes[c].Skills[s].ModID == SkillModID)
                            {
                                ss.ClassPosition = c;
                                ss.SkillPosition = s;
                                break;
                            }
                        }
                    }
                }
            }
            return(ss);
        }
Ejemplo n.º 5
0
        public static void LoadQuest(string QuestKey, Terraria.ModLoader.IO.TagCompound Reader, int ModVersion, PlayerMod pm)
        {
            int       QuestID    = Reader.GetInt(QuestKey + "_ID");
            string    QuestModID = Reader.GetString(QuestKey + "_ModID");
            QuestData qd         = null;

            foreach (QuestData qd2 in pm.QuestDatas)
            {
                if (qd2.QuestID == QuestID && qd2.QuestModID == QuestModID)
                {
                    qd = qd2;
                    break;
                }
            }
            Terraria.ModLoader.IO.TagCompound QuestData = Reader.Get <Terraria.ModLoader.IO.TagCompound>(QuestKey + "_QuestData");
            if (qd == null)
            {
                qd                   = QuestContainer.GetQuestBase(QuestID, QuestModID).GetQuestData;
                qd.QuestID           = QuestID;
                qd.QuestModID        = QuestModID;
                qd.IsUnexistingQuest = true;
                qd.SavedQuestData    = QuestData;
                pm.QuestDatas.Add(qd);
            }
            else
            {
                qd.CustomLoadQuest(QuestKey, QuestData, ModVersion);
            }
        }
Ejemplo n.º 6
0
        public void Load(Terraria.ModLoader.IO.TagCompound tag, int ClassIndex, int ModVersion)
        {
            string ClassText  = "Class_" + ClassIndex;
            int    ClassID    = tag.GetInt(ClassText + "_ID");
            string ClassModID = tag.GetString(ClassText + "_ModID");

            ChangeClass(ClassID, ClassModID);
            Level = tag.GetInt(ClassText + "_Level");
            Exp   = tag.GetInt(ClassText + "_Exp");
            int SkillCount = tag.GetInt(ClassText + "_SkillCount");

            for (int s = 0; s < SkillCount; s++)
            {
                string SkillText  = ClassText + "_Skill_" + s;
                int    ID         = tag.GetInt(SkillText + "_ID");
                string ModID      = tag.GetString(SkillText + "_ModID");
                int    SkillLevel = tag.GetInt(SkillText + "_Level");
                int    Cooldown   = tag.GetInt(SkillText + "_Cooldown");
                foreach (SkillData sd in Skills)
                {
                    if (sd.ID == ID && sd.ModID == ModID)
                    {
                        sd.Level    = SkillLevel;
                        sd.Cooldown = Cooldown;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 7
0
 public void Save(Terraria.ModLoader.IO.TagCompound tag)
 {
     tag.Add("ModVersion", MainMod.ModVersion);
     tag.Add("ObjectivesProgressCount", LoreInternalProgress.Count);
     for (int i = 0; i < LoreInternalProgress.Count; i++)
     {
         ClassLoreStepProgress clsp = LoreInternalProgress[i];
         tag.Add("ObjectivesProgressStep" + i, LoreInternalProgress[i].StepValue);
     }
 }
Ejemplo n.º 8
0
        internal void LoadModdedStuff()
        {
            string path = Path.Combine(Main.ActiveWorldFileData.Path.Replace(".wld", ""), ActiveDimensionName.Split(':')[1]) + "\\modded.data";

            using (BinaryReader reader = new BinaryReader(File.Open(path, FileMode.Open)))
            {
                int bufferSize = reader.ReadInt32();
                Terraria.ModLoader.IO.TagCompound tag = Terraria.ModLoader.IO.TagIO.FromStream(new MemoryStream(reader.ReadBytes(bufferSize)));

                typeof(Main).Assembly.GetType("Terraria.ModLoader.IO.TileIO")
                .GetMethod("LoadTiles", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { tag.GetCompound("tiles") });
                typeof(Main).Assembly.GetType("Terraria.ModLoader.IO.TileIO")
                .GetMethod("LoadContainers", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { tag.GetCompound("containers") });
            }
        }
Ejemplo n.º 9
0
 public void SaveSkillSlot(Terraria.ModLoader.IO.TagCompound tag, SkillSlot ss, string SkillSlotText)
 {
     if (ss.ClassPosition == -1)
     {
         tag.Add(SkillSlotText + "_Exists", false);
     }
     else
     {
         tag.Add(SkillSlotText + "_Exists", true);
         tag.Add(SkillSlotText + "_ClassID", Classes[ss.ClassPosition].ClassID);
         tag.Add(SkillSlotText + "_ClassModID", Classes[ss.ClassPosition].ClassModID);
         tag.Add(SkillSlotText + "_SkillID", Classes[ss.ClassPosition].Skills[ss.SkillPosition].ID);
         tag.Add(SkillSlotText + "_SkillModID", Classes[ss.ClassPosition].Skills[ss.SkillPosition].ModID);
     }
 }
Ejemplo n.º 10
0
 public void SaveQuest(string QuestKey, Terraria.ModLoader.IO.TagCompound Writer)
 {
     Writer.Add(QuestKey + "_ID", QuestID);
     Writer.Add(QuestKey + "_ModID", QuestModID);
     Terraria.ModLoader.IO.TagCompound QuestData = new Terraria.ModLoader.IO.TagCompound();
     if (IsUnexistingQuest)
     {
         QuestData = SavedQuestData;
     }
     else
     {
         CustomSaveQuest(QuestKey, QuestData);
     }
     Writer.Add(QuestKey + "_QuestData", QuestData);
 }
Ejemplo n.º 11
0
 public void Save(Terraria.ModLoader.IO.TagCompound writer, string UniqueID)
 {
     writer.Add(UniqueID + "_ID", RequestID);
     writer.Add(UniqueID + "_ModID", RequestModID);
     writer.Add(UniqueID + "_State", (byte)state);
     writer.Add(UniqueID + "_ObjectiveCount", ObjectiveCount);
     writer.Add(UniqueID + "_MaxObjectiveCount", MaxObjectiveCount);
     writer.Add(UniqueID + "_TimeLeft", RequestTimeLeft);
     for (byte i = 0; i < 3; i++)
     {
         string            RewardID = UniqueID + "_rwi" + i;
         ThisRequestReward reward   = Rewards[i];
         writer.Add(RewardID + "_item", reward.item);
         writer.Add(RewardID + "_value", reward.value);
     }
 }
Ejemplo n.º 12
0
 public override Terraria.ModLoader.IO.TagCompound Save()
 {
     Terraria.ModLoader.IO.TagCompound tag = new Terraria.ModLoader.IO.TagCompound();
     tag.Add("ModVersion", MainMod.ModVersion);
     tag.Add("ClassCount", Classes.Count);
     for (int c = 0; c < Classes.Count; c++)
     {
         Classes[c].Save(tag, c);
     }
     SaveSkillSlot(tag, CombatSkill, "CombatSkillSlot");
     for (int s = 0; s < 4; s++)
     {
         SaveSkillSlot(tag, ActiveSkill[s], "ActiveSkillSlot_" + s);
     }
     return(tag);
 }
Ejemplo n.º 13
0
        public void Save(Terraria.ModLoader.IO.TagCompound tag, int ClassIndex)
        {
            string ClassText = "Class_" + ClassIndex;

            tag.Add(ClassText + "_ID", ClassID);
            tag.Add(ClassText + "_ModID", ClassModID);
            tag.Add(ClassText + "_Level", Level);
            tag.Add(ClassText + "_Exp", Exp);
            tag.Add(ClassText + "_SkillCount", Skills.Count);
            for (int s = 0; s < Skills.Count; s++)
            {
                string SkillText = ClassText + "_Skill_" + s;
                tag.Add(SkillText + "_ID", Skills[s].ID);
                tag.Add(SkillText + "_ModID", Skills[s].ModID);
                tag.Add(SkillText + "_Level", Skills[s].RealLevel);
                tag.Add(SkillText + "_Cooldown", Skills[s].Cooldown);
            }
        }
Ejemplo n.º 14
0
        public void Load(Terraria.ModLoader.IO.TagCompound tag)
        {
            int ModVersion = tag.GetInt("ModVersion");
            int LoreCount  = tag.GetInt("ObjectivesProgressCount");

            for (int i = 0; i < LoreCount; i++)
            {
                float Progress             = tag.GetFloat("ObjectivesProgressStep" + i);
                ClassLoreStepProgress clsp = new ClassLoreStepProgress();
                clsp.StepValue = Progress;
                if (i < LoreInternalProgress.Count)
                {
                    LoreInternalProgress[i] = clsp;
                }
                else
                {
                    LoreInternalProgress.Add(clsp);
                }
            }
        }
Ejemplo n.º 15
0
 public void Load(Terraria.ModLoader.IO.TagCompound writer, string UniqueID, int ModVersion)
 {
     RequestID         = writer.GetInt(UniqueID + "_ID");
     RequestModID      = writer.GetString(UniqueID + "_ModID");
     state             = (RequestState)writer.GetByte(UniqueID + "_State");
     ObjectiveCount    = writer.GetInt(UniqueID + "_ObjectiveCount");
     MaxObjectiveCount = writer.GetInt(UniqueID + "_MaxObjectiveCount");
     RequestTimeLeft   = writer.GetInt(UniqueID + "_TimeLeft");
     for (byte i = 0; i < 3; i++)
     {
         string            RewardID = UniqueID + "_rwi" + i;
         ThisRequestReward reward   = Rewards[i];
         reward.item  = writer.Get <Item>(RewardID + "_item");
         reward.value = writer.GetInt(RewardID + "_value");
     }
     if (state != RequestState.Cooldown)
     {
         Base = RequestContainer.GetRequest(RequestID, RequestModID);
     }
 }
Ejemplo n.º 16
0
 public static void SaveShops(Terraria.ModLoader.IO.TagCompound tag)
 {
     tag.Add("Shop_Count", Shops.Count);
     for (int s = 0; s < Shops.Count; s++)
     {
         string       ShopTag = "Shop_s" + s + ">";
         GuardianShop shop    = Shops[s];
         tag.Add(ShopTag + "OwnerID", shop.OwnerID);
         tag.Add(ShopTag + "OwnerModID", shop.OwnerModID);
         tag.Add(ShopTag + "ItemCount", shop.Items.Count);
         for (int i = 0; i < shop.Items.Count; i++)
         {
             string           ItemTag = ShopTag + "i" + i + ">";
             GuardianShopItem item    = shop.Items[i];
             bool             HasItem = item.ItemID != 0;
             tag.Add(ItemTag + "hasitem", HasItem);
             if (HasItem)
             {
                 Item dummyItem = new Item();
                 dummyItem.SetDefaults(item.ItemID, true);
                 bool IsModItem = dummyItem.modItem != null;
                 tag.Add(ItemTag + "ismoditem", IsModItem);
                 if (IsModItem)
                 {
                     tag.Add(ItemTag + "itemname", dummyItem.modItem.Name);
                     tag.Add(ItemTag + "itemmodname", dummyItem.modItem.mod.Name);
                 }
                 else
                 {
                     tag.Add(ItemTag + "itemid", item.ItemID);
                 }
                 tag.Add(ItemTag + "saletime", item.SaleTime);
                 tag.Add(ItemTag + "timedsaletime", item.TimedSaleTime);
                 tag.Add(ItemTag + "stack", item.Stack);
             }
         }
     }
 }
Ejemplo n.º 17
0
 public static void Save(Terraria.ModLoader.IO.TagCompound tag)
 {
     tag.Add("TombstoneExists", SpawnedTombstone);
     tag.Add("TombstonePosX", TombstoneTileX);
     tag.Add("TombstonePosY", TombstoneTileY);
 }
Ejemplo n.º 18
0
        public static void LoadShops(Terraria.ModLoader.IO.TagCompound tag, int ModVersion)
        {
            int ShopCount = tag.GetInt("Shop_Count");

            for (int s = 0; s < ShopCount; s++)
            {
                string       ShopTag    = "Shop_s" + s + ">";
                int          OwnerID    = tag.GetInt(ShopTag + "OwnerID");
                string       OwnerModID = tag.GetString(ShopTag + "OwnerModID");
                GuardianBase gb         = GuardianBase.GetGuardianBase(OwnerID, OwnerModID);
                GuardianShop shop       = GetShop(OwnerID, OwnerModID);
                if (shop == null)
                {
                    gb.SetupShop(OwnerID, OwnerModID);
                    shop = GetShop(OwnerID, OwnerModID);
                }
                if (shop != null)
                {
                    int ItemCount = tag.GetInt(ShopTag + "ItemCount");
                    for (int i = 0; i < ItemCount; i++)
                    {
                        string ItemTag = ShopTag + "i" + i + ">";
                        if (tag.GetBool(ItemTag + "hasitem"))
                        {
                            bool   IsModItem = tag.GetBool(ItemTag + "ismoditem");
                            string ItemInternalName = null, ItemModInternalName = null;
                            int    ItemID = 0;
                            if (IsModItem)
                            {
                                ItemInternalName    = tag.GetString(ItemTag + "itemname");
                                ItemModInternalName = tag.GetString(ItemTag + "itemmodname");
                            }
                            else
                            {
                                ItemID = tag.GetInt(ItemTag + "itemid");
                            }
                            foreach (GuardianShopItem item in shop.Items)
                            {
                                if (item.ItemID == 0)
                                {
                                    continue;
                                }
                                if (ItemInternalName != null)
                                {
                                    Item anotheritem = new Item();
                                    anotheritem.SetDefaults(item.ItemID, true);
                                    if (anotheritem.modItem == null || anotheritem.modItem.Name != ItemInternalName || anotheritem.modItem.mod.Name != ItemModInternalName)
                                    {
                                        continue;
                                    }
                                }
                                else if (ItemID != item.ItemID)
                                {
                                    continue;
                                }
                                item.SaleTime      = tag.GetInt(ItemTag + "saletime");
                                item.TimedSaleTime = tag.GetInt(ItemTag + "timedsaletime");
                                item.Stack         = tag.GetInt(ItemTag + "stack");
                                break;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 19
0
 public override void Load(Terraria.ModLoader.IO.TagCompound tag)
 {
     base.Load(tag);
 }
Ejemplo n.º 20
0
 public virtual void CustomSaveQuest(string QuestKey, Terraria.ModLoader.IO.TagCompound Writer)
 {
 }
Ejemplo n.º 21
0
 public virtual void SaveCustom(Terraria.ModLoader.IO.TagCompound tag, int UniqueID)
 {
 }
Ejemplo n.º 22
0
 public virtual void LoadCustom(Terraria.ModLoader.IO.TagCompound tag, int ModVersion, int UniqueID)
 {
 }
Ejemplo n.º 23
0
        public void Load(Terraria.ModLoader.IO.TagCompound tag, int ModVersion, int UniqueID)
        {
            ID = tag.GetInt("GuardianID_" + UniqueID);
            if (ModVersion >= 35)
            {
                ModID = tag.GetString("GuardianModID_" + UniqueID);
            }
            else
            {
                ModID = MainMod.mod.Name;
            }
            if (ModVersion >= 19 && tag.ContainsKey("Name_" + UniqueID))
            {
                _Name = tag.GetString("Name_" + UniqueID);
                if (_Name == "")
                {
                    _Name = null;
                }
            }
            if (ModVersion >= 72)
            {
                PickedName = tag.GetByte("NameID_" + UniqueID);
                GuardianBase gb = Base;
                if (gb.PossibleNames.Length > 0 && PickedName > gb.PossibleNames.Length)
                {
                    PickedName = (byte)Main.rand.Next(gb.PossibleNames.Length);
                }
            }
            if (ModVersion >= 52)
            {
                IsStarter = tag.GetBool("StarterFlag_" + UniqueID);
            }
            if (ModVersion >= 7)
            {
                FriendshipLevel       = tag.GetByte("FriendshipLevel_" + UniqueID);
                FriendshipProgression = tag.GetByte("FriendshipProgress_" + UniqueID);
                TravellingStacker     = tag.GetFloat("TravellingStacker_" + UniqueID);
            }
            if (ModVersion >= 18)
            {
                DamageStacker = tag.GetFloat("DamageStacker_" + UniqueID);
            }
            if (ModVersion >= 25)
            {
                FoodStacker  = tag.GetByte("FoodStacker_" + UniqueID);
                DrinkStacker = tag.GetByte("DrinkStacker_" + UniqueID);
            }
            if (ModVersion >= 64)
            {
                ComfortStack  = tag.GetFloat("ComfortStack_" + UniqueID);
                ComfortPoints = tag.GetByte("ComfortPoints_" + UniqueID);
            }
            float HealthPercentage = -1;

            if (ModVersion >= 1)
            {
                HealthPercentage = tag.GetFloat("HealthPercentage_" + UniqueID);
                if (HealthPercentage >= 0)
                {
                    if (HealthPercentage <= 0)
                    {
                        HP = 1;
                    }
                    else
                    {
                        HP = (int)(MHP * HealthPercentage);
                    }
                }
            }
            if (ModVersion >= 58)
            {
                KnockedOut     = tag.GetBool("IsKnockedOut_" + UniqueID);
                KnockedOutCold = tag.GetBool("IsKnockedOutCold_" + UniqueID);
            }
            LifeCrystalHealth = (ModVersion < 42 ? (byte)tag.GetInt("LifeCrystals_" + UniqueID) : tag.GetByte("LifeCrystals_" + UniqueID));
            LifeFruitHealth   = (ModVersion < 42 ? (byte)tag.GetInt("LifeFruits_" + UniqueID) : tag.GetByte("LifeFruits_" + UniqueID));
            if (ModVersion >= 33)
            {
                Male = tag.GetBool("IsMale_" + UniqueID);
            }
            if (ModVersion >= 32 && ModVersion < 42)
            {
                tag.GetBool("ExtraAccessorySlot_" + UniqueID);
            }
            if (ModVersion >= 27)
            {
                ManaCrystals = (ModVersion < 42 ? (byte)tag.GetInt("ManaCrystals_" + UniqueID) : tag.GetByte("ManaCrystals_" + UniqueID));
            }
            if (ModVersion >= 5)
            {
                tactic = (CombatTactic)tag.GetByte("CombatTactic_" + UniqueID);
            }
            if (ModVersion >= 6)
            {
                Tanker = tag.GetBool("TankingFlag_" + UniqueID);
            }
            if (ModVersion >= 11)
            {
                OverrideQuickMountToMountGuardianInstead = tag.GetBool("QuickMountOverride_" + UniqueID);
            }
            if (ModVersion >= 12)
            {
                UseHeavyMeleeAttackWhenMounted = tag.GetBool("MountMeleeUsageToggle_" + UniqueID);
            }
            if (ModVersion >= 13)
            {
                AvoidCombat = tag.GetBool("AvoidCombat_" + UniqueID);
                ChargeAhead = tag.GetBool("ChargeAhead_" + UniqueID);
            }
            if (ModVersion >= 17)
            {
                Passive        = tag.GetBool("Passive_" + UniqueID);
                AttackMyTarget = tag.GetBool("AttackMyTarget_" + UniqueID);
            }
            if (ModVersion >= 21)
            {
                SitOnTheMount = tag.GetBool("SitOnMount_" + UniqueID);
            }
            if (ModVersion >= 26)
            {
                MayLootItems = tag.GetBool("MayLootItems_" + UniqueID);
            }
            if (ModVersion >= 28)
            {
                SetToPlayerSize = tag.GetBool("SetToPlayerSize_" + UniqueID);
            }
            if (ModVersion >= 31)
            {
                GetItemsISendtoTrash = tag.GetBool("GetItemsISendtoTrash_" + UniqueID);
            }
            if (ModVersion >= 41)
            {
                UseWeaponsByInventoryOrder = tag.GetBool("UseWeaponsByInventoryOrder" + UniqueID);
            }
            if (ModVersion >= 46)
            {
                ProtectMode = tag.GetBool("ProtectMode" + UniqueID);
            }
            if (ModVersion >= 49)
            {
                AutoSellWhenInvIsFull = tag.GetBool("AutoSell" + UniqueID);
            }
            if (ModVersion >= 65)
            {
                HideWereForm = tag.GetBool("HideWereForm" + UniqueID);
            }
            if (ModVersion >= 30)
            {
                GiftGiven = tag.GetBool("GiftGiven_" + UniqueID);
            }
            if (ModVersion >= 53)
            {
                for (int i = 0; i < 8; i++)
                {
                    MessageTriggerFlags[i] = tag.GetBool("MessageFlags" + i + "_" + UniqueID);
                    if (ModVersion < 78)
                    {
                        tag.GetBool("FriendLevelFlags" + i + "_" + UniqueID);
                    }
                }
            }
            int ContainerSize = tag.GetInt("InventorySize_" + UniqueID);

            for (int i = 0; i < ContainerSize; i++)
            {
                Item j = new Item();
                if (ModVersion < 2)
                {
                    j.SetDefaults(tag.GetInt("Inventory_" + i + "_Type_" + UniqueID), true);
                    j.stack  = tag.GetInt("Inventory_" + i + "_Stack_" + UniqueID);
                    j.prefix = tag.GetByte("Inventory_" + i + "_Prefix_" + UniqueID);
                }
                else
                {
                    bool ItemExists = true;
                    if (ModVersion >= 3)
                    {
                        ItemExists = tag.GetBool("Inventory_" + i + "_exists_" + UniqueID);
                    }
                    if (ItemExists)
                    {
                        j = tag.Get <Item>("Inventory_" + i + "_" + UniqueID);
                    }
                }
                if (i < Inventory.Length)
                {
                    Inventory[i] = j;
                }
            }
            ContainerSize = tag.GetInt("EquipmentsSize_" + UniqueID);
            for (int e = 0; e < ContainerSize; e++)
            {
                Item j = new Item();
                if (ModVersion < 4)
                {
                    j.SetDefaults(tag.GetInt("Equipment_" + e + "_Type_" + UniqueID), true);
                    j.stack  = tag.GetInt("Equipment_" + e + "_Stack_" + UniqueID);
                    j.prefix = tag.GetByte("Equipment_" + e + "_Prefix_" + UniqueID);
                }
                else
                {
                    if (tag.GetBool("Equipment_" + e + "_exists_" + UniqueID))
                    {
                        j = tag.Get <Item>("Equipment_" + e + "_" + UniqueID);
                    }
                }
                if (e < Equipments.Length)
                {
                    Equipments[e] = j;
                }
            }
            if (ModVersion >= 22)
            {
                int BuffCount = tag.GetInt("BuffCount_" + UniqueID);
                for (int b = 0; b < BuffCount; b++)
                {
                    int ID   = tag.GetInt("Buff_" + b + "_type_" + UniqueID),
                        Time = tag.GetInt("Buff_" + b + "_time_" + UniqueID);
                    if (Time > 0)
                    {
                        Buffs.Add(new BuffData(ID, Time));
                    }
                }
            }
            if (ModVersion >= 23)
            {
                int      SkillCount = tag.GetInt("SkillCount_" + UniqueID);
                string[] SkillNames = Enum.GetNames(typeof(GuardianSkills.SkillTypes));
                for (int s = 0; s < SkillCount; s++)
                {
                    string SkillType     = tag.GetString("SkillType_" + s + "_" + UniqueID);
                    int    SkillLevel    = tag.GetInt("SkillLevel_" + s + "_" + UniqueID);
                    float  SkillProgress = tag.GetFloat("SkillProgress_" + s + "_" + UniqueID);
                    for (int s2 = 0; s2 < SkillNames.Length; s2++)
                    {
                        if (SkillNames[s2] == SkillType)
                        {
                            SkillList[s2].Level    = SkillLevel;
                            SkillList[s2].Progress = SkillProgress;
                            break;
                        }
                    }
                }
            }
            if (ModVersion >= 29)
            {
                BodyDye.SetDefaults(tag.GetInt("BodyDye_" + UniqueID), true);
            }
            if (ModVersion >= 56)
            {
                Fatigue = (sbyte)tag.GetByte("FatigueCount_" + UniqueID);
                Injury  = (sbyte)tag.GetByte("InjuryCount_" + UniqueID);
            }

            /*if (ModVersion >= 61)
             * {
             *  request.Load(tag, ModVersion, UniqueID, this);
             * }*/
            if (ModVersion >= 101)
            {
                request.Load(tag, "Request_" + UniqueID, ModVersion);
            }
            //if (ModVersion >= 8)
            //    request.Load(tag, ModVersion, UniqueID);

            /*if (ModVersion < 95)
             * {
             *  if (ModVersion <= 80)
             *  {
             *      if (ModVersion >= 15)
             *          LifeTime = TimeSpan.FromSeconds(tag.GetDouble("ExistenceTime_" + UniqueID));
             *  }
             *  else
             *  {
             *      if (tag.GetBool("HasExistenceTime_" + UniqueID))
             *      {
             *          LifeTime = TimeSpan.FromSeconds(tag.GetDouble("ExistenceTime_" + UniqueID));
             *      }
             *  }
             * }*/
            if (ModVersion >= 66)
            {
                SkinID   = tag.GetByte("SkinID_" + UniqueID);
                OutfitID = tag.GetByte("OutfitID_" + UniqueID);
            }
            if (ModVersion >= 67)
            {
                _Coins = (uint)(tag.GetInt("Coins_" + UniqueID) + int.MaxValue);
            }
            if (ModVersion < 80)
            {
                ResetSkillsProgress();
            }
            if (ModVersion >= 83)
            {
                LoadCustom(tag, ModVersion, UniqueID);
            }
            if (ModVersion < 90)
            {
                GuardianCommonStatus status = GetCommonStatus;
                if (status.LifeCrystalsUsed < LifeCrystalHealth)
                {
                    status.LifeCrystalsUsed = LifeCrystalHealth;
                }
                if (status.LifeFruitsUsed < LifeFruitHealth)
                {
                    status.LifeFruitsUsed = LifeFruitHealth;
                }
                if (status.ManaCrystalsUsed < ManaCrystals)
                {
                    status.ManaCrystalsUsed = ManaCrystals;
                }
                foreach (GuardianSkills skill in status.SkillList)
                {
                    foreach (GuardianSkills other in SkillList)
                    {
                        if (skill.skillType == other.skillType && skill.Level < other.Level)
                        {
                            skill.Level    = other.Level;
                            skill.Progress = other.Progress;
                        }
                    }
                }
            }
        }
Ejemplo n.º 24
0
 public virtual void CustomLoadQuest(string QuestKey, Terraria.ModLoader.IO.TagCompound Reader, int ModVersion)
 {
 }
Ejemplo n.º 25
0
        public void Save(Terraria.ModLoader.IO.TagCompound tag, int UniqueID)
        {
            tag.Add("GuardianID_" + UniqueID, ID);
            tag.Add("GuardianModID_" + UniqueID, ModID);
            if (_Name != null)
            {
                tag.Add("Name_" + UniqueID, _Name);
            }
            tag.Add("NameID_" + UniqueID, PickedName);
            tag.Add("StarterFlag_" + UniqueID, IsStarter);
            tag.Add("FriendshipLevel_" + UniqueID, FriendshipLevel);
            tag.Add("FriendshipProgress_" + UniqueID, FriendshipProgression);
            tag.Add("TravellingStacker_" + UniqueID, TravellingStacker);
            tag.Add("DamageStacker_" + UniqueID, DamageStacker);
            tag.Add("FoodStacker_" + UniqueID, FoodStacker);
            tag.Add("DrinkStacker_" + UniqueID, DrinkStacker);
            tag.Add("ComfortStack_" + UniqueID, ComfortStack);
            tag.Add("ComfortPoints_" + UniqueID, ComfortPoints);
            tag.Add("HealthPercentage_" + UniqueID, HP <= 0 ? 0 : (HP == MHP ? 1f : (float)HP / MHP));
            tag.Add("IsKnockedOut_" + UniqueID, KnockedOut);
            tag.Add("IsKnockedOutCold_" + UniqueID, KnockedOutCold);
            tag.Add("LifeCrystals_" + UniqueID, LifeCrystalHealth);
            tag.Add("LifeFruits_" + UniqueID, LifeFruitHealth);
            tag.Add("IsMale_" + UniqueID, Male);
            tag.Add("ManaCrystals_" + UniqueID, ManaCrystals);
            tag.Add("CombatTactic_" + UniqueID, (byte)tactic);
            tag.Add("TankingFlag_" + UniqueID, Tanker);
            tag.Add("QuickMountOverride_" + UniqueID, OverrideQuickMountToMountGuardianInstead);
            tag.Add("MountMeleeUsageToggle_" + UniqueID, UseHeavyMeleeAttackWhenMounted);
            tag.Add("AvoidCombat_" + UniqueID, AvoidCombat);
            tag.Add("ChargeAhead_" + UniqueID, ChargeAhead);
            tag.Add("Passive_" + UniqueID, Passive);
            tag.Add("AttackMyTarget_" + UniqueID, AttackMyTarget);
            tag.Add("SitOnMount_" + UniqueID, SitOnTheMount);
            tag.Add("MayLootItems_" + UniqueID, MayLootItems);
            tag.Add("SetToPlayerSize_" + UniqueID, SetToPlayerSize);
            tag.Add("GetItemsISendtoTrash_" + UniqueID, GetItemsISendtoTrash);
            tag.Add("UseWeaponsByInventoryOrder" + UniqueID, UseWeaponsByInventoryOrder);
            tag.Add("ProtectMode" + UniqueID, ProtectMode);
            tag.Add("AutoSell" + UniqueID, AutoSellWhenInvIsFull);
            tag.Add("HideWereForm" + UniqueID, HideWereForm);
            tag.Add("GiftGiven_" + UniqueID, GiftGiven);
            for (int i = 0; i < 8; i++)
            {
                tag.Add("MessageFlags" + i + "_" + UniqueID, MessageTriggerFlags[i]); //It crashes
            }
            int InventorySize = Inventory.Length;

            tag.Add("InventorySize_" + UniqueID, InventorySize);
            for (int i = 0; i < InventorySize; i++)
            {
                tag.Add("Inventory_" + i + "_exists_" + UniqueID, this.Inventory[i].type != 0);
                if (this.Inventory[i].type != 0)
                {
                    tag.Add("Inventory_" + i + "_" + UniqueID, this.Inventory[i]);
                }
            }
            int EquipmentsSize = Equipments.Length;

            tag.Add("EquipmentsSize_" + UniqueID, EquipmentsSize);
            for (int e = 0; e < EquipmentsSize; e++)
            {
                tag.Add("Equipment_" + e + "_exists_" + UniqueID, this.Equipments[e].type != 0);
                if (this.Equipments[e].type != 0)
                {
                    tag.Add("Equipment_" + e + "_" + UniqueID, this.Equipments[e]);
                }
            }
            int BuffCount = Buffs.Count;

            tag.Add("BuffCount_" + UniqueID, BuffCount);
            for (int b = 0; b < Buffs.Count; b++)
            {
                int ID = Buffs[b].ID, Time = Buffs[b].Time;
                if (ID < 0 || ID >= Main.maxBuffTypes)
                {
                    ID = Time = 0;
                }
                tag.Add("Buff_" + b + "_type_" + UniqueID, ID);
                tag.Add("Buff_" + b + "_time_" + UniqueID, Time);
            }
            int SkillCount = SkillList.Count;

            tag.Add("SkillCount_" + UniqueID, SkillCount);
            for (int s = 0; s < SkillCount; s++)
            {
                tag.Add("SkillType_" + s + "_" + UniqueID, SkillList[s].skillType.ToString());
                tag.Add("SkillLevel_" + s + "_" + UniqueID, SkillList[s].Level);
                tag.Add("SkillProgress_" + s + "_" + UniqueID, SkillList[s].Progress);
            }
            tag.Add("BodyDye_" + UniqueID, BodyDye.type);
            tag.Add("FatigueCount_" + UniqueID, (byte)Fatigue);
            tag.Add("InjuryCount_" + UniqueID, (byte)Injury);
            //request.Save(tag, UniqueID);
            request.Save(tag, "Request_" + UniqueID);

            /*tag.Add("HasExistenceTime_" + UniqueID, LifeTime.HasValue);
             * if(LifeTime.HasValue)
             *  tag.Add("ExistenceTime_" + UniqueID, LifeTime.Value.TotalSeconds);*/
            tag.Add("SkinID_" + UniqueID, SkinID);
            tag.Add("OutfitID_" + UniqueID, OutfitID);
            tag.Add("Coins_" + UniqueID, (int)_Coins - int.MaxValue);
            SaveCustom(tag, UniqueID);
            GuardianCommonStatus.SaveStatus(ID, ModID);
        }
Ejemplo n.º 26
0
 public virtual void Load(Terraria.ModLoader.IO.TagCompound tag)
 {
 }