Beispiel #1
0
        internal static List <TagCompound> SaveModBuffs(Player player)
        {
            var  list         = new List <TagCompound>();
            byte vanillaIndex = 0;

            for (int k = 0; k < Player.maxBuffs; k++)
            {
                int buff = player.buffType[k];
                if (buff == 0 || Main.buffNoSave[buff])
                {
                    continue;
                }

                if (BuffLoader.IsModBuff(buff))
                {
                    var modBuff = BuffLoader.GetBuff(buff);
                    list.Add(new TagCompound {
                        ["index"] = vanillaIndex,                         //position of the loaded buff if there were no modBuffs before it
                        ["mod"]   = modBuff.mod.Name,
                        ["name"]  = modBuff.Name,
                        ["time"]  = player.buffTime[k]
                    });
                }
                else
                {
                    vanillaIndex++;
                }
            }
            return(list);
        }
Beispiel #2
0
        internal static List <TagCompound> SaveModBuffs(Player player)
        {
            var list = new List <TagCompound>();

            for (int k = 0; k < Player.MaxBuffs; k++)
            {
                int buff = player.buffType[k];
                if (buff == 0 || Main.buffNoSave[buff])
                {
                    continue;
                }

                if (BuffLoader.IsModBuff(buff))
                {
                    var modBuff = BuffLoader.GetBuff(buff);
                    list.Add(new TagCompound {
                        ["mod"]  = modBuff.Mod.Name,
                        ["name"] = modBuff.Name,
                        ["time"] = player.buffTime[k]
                    });
                }
                else
                {
                    list.Add(new TagCompound {
                        ["mod"]  = "Terraria",
                        ["id"]   = buff,
                        ["time"] = player.buffTime[k]
                    });
                }
            }
            return(list);
        }
Beispiel #3
0
        internal static bool WriteModBuffs(Player player, BinaryWriter writer)
        {
            byte[] data;
            byte   num = 0;

            using (MemoryStream buffer = new MemoryStream())
            {
                using (BinaryWriter customWriter = new BinaryWriter(buffer))
                {
                    byte index = 0;
                    for (int k = 0; k < Player.maxBuffs; k++)
                    {
                        int buff = player.buffType[k];
                        if (!Main.buffNoSave[buff])
                        {
                            if (BuffLoader.IsModBuff(buff))
                            {
                                customWriter.Write(index);
                                ModBuff modBuff = BuffLoader.GetBuff(buff);
                                customWriter.Write(modBuff.mod.Name);
                                customWriter.Write(modBuff.Name);
                                customWriter.Write(player.buffTime[k]);
                                num++;
                            }
                            index++;
                        }
                    }
                    customWriter.Flush();
                    data = buffer.ToArray();
                }
            }
            if (num > 0)
            {
                writer.Write(num);
                writer.Write(data);
                return(true);
            }
            return(false);
        }