示例#1
1
 internal void Setup(TagCompound tag)
 {
     this.modName = tag.GetString("mod");
     this.itemName = tag.GetString("name");
     this.data = tag;
     item.toolTip = "Mod: " + modName;
     item.toolTip2 = "Item: " + itemName;
 }
示例#2
0
        public static void Load(string path)
        {
            var l = new TagList<TagString>();

            if (File.Exists(path))
            {
                var t = File.ReadAllLines(path);
                var p = "";
                foreach (string s in t)
                {
                    //New page
                    if (s == "\t----")
                    {
                        l.Add(new TagString(p));
                        p = "";
                        continue;
                    }
                    if (p == "")
                        p = s;
                    else
                        p = p + "\n" + s;
                }
                l.Add(new TagString(p));
            } else
            {
                l.Add(new TagString("Rules not found"));
            }

            var c = new TagCompound();
            c ["pages"] = l;
            c ["title"] = new TagString("Rules");
            Debug.WriteLine("Rules: " + c);
            Content = c;
        }
示例#3
0
        internal static void LoadTiles(TagCompound tag)
        {
            if (!tag.HasTag("data"))
                return;

            var tables = TileTables.Create();
            foreach (var tileTag in tag.GetList<TagCompound>("tileMap"))
            {
                ushort type = (ushort)tileTag.GetShort("value");
                string modName = tileTag.GetString("mod");
                string name = tileTag.GetString("name");
                Mod mod = ModLoader.GetMod(modName);
                tables.tiles[type] = mod == null ? (ushort)0 : (ushort)mod.TileType(name);
                if (tables.tiles[type] == 0)
                {
                    tables.tiles[type] = (ushort)ModLoader.GetMod("ModLoader").TileType("PendingMysteryTile");
                    tables.tileModNames[type] = modName;
                    tables.tileNames[type] = name;
                }
                tables.frameImportant[type] = tileTag.GetBool("framed");
            }
            foreach (var wallTag in tag.GetList<TagCompound>("wallMap"))
            {
                ushort wall = (ushort)wallTag.GetShort("value");
                string modName = wallTag.GetString("mod");
                string name = wallTag.GetString("name");
                Mod mod = ModLoader.GetMod(modName);
                tables.walls[wall] = mod == null ? (ushort)0 : (ushort)mod.WallType(name);
            }
            ReadTileData(new BinaryReader(new MemoryStream(tag.GetByteArray("data"))), tables);
        }
示例#4
0
    public virtual void WriteDocument(Stream stream, TagCompound tag, CompressionOption compression)
    {
      bool createWriter;

      if (compression == CompressionOption.On)
      {
        throw new NotSupportedException("Compression is not supported.");
      }

      createWriter = _writer == null;

      if (createWriter)
      {
        XmlWriterSettings settings;

        settings = new XmlWriterSettings
                   {
                     Indent = true,
                     Encoding = Encoding.UTF8
                   };

        _writer = XmlWriter.Create(stream, settings);
        _writer.WriteStartDocument(true);
      }

      this.WriteTag(tag, WriteTagOptions.None);

      if (createWriter)
      {
        _writer.WriteEndDocument();
        _writer.Flush();
        _writer = null;
      }
    }
示例#5
0
        public override TagDictionary ReadDictionary(TagCompound owner)
        {
            TagDictionary value;

              value = new TagDictionary(owner);

              this.LoadChildren(value, this.Options, TagType.None);

              return value;
        }
示例#6
0
        internal static void LoadContainers(TagCompound tag)
        {
            if (tag.HasTag("data"))
                ReadContainers(new BinaryReader(new MemoryStream(tag.GetByteArray("data"))));

            foreach (var frameTag in tag.GetList<TagCompound>("itemFrames"))
            {
                TEItemFrame itemFrame = TileEntity.ByID[tag.GetInt("id")] as TEItemFrame;
                ItemIO.Load(itemFrame.item, frameTag.GetCompound("item"));
            }
        }
示例#7
0
 public override void Load(TagCompound tag)
 {
     Setup(tag);
     int type = ModLoader.GetMod(modName)?.ItemType(itemName) ?? 0;
     if (type > 0)
     {
         item.netDefaults(type);
         item.modItem.Load(tag.GetCompound("data"));
         ItemIO.LoadGlobals(item, tag.GetList<TagCompound>("globalData"));
     }
 }
示例#8
0
        public static TagCompound ParseCompound(JsonReader reader, string rootName = "")
        {
            TagCompound res = new TagCompound(rootName);
            string tagName = null;
            while (reader.Read())
            {
                if (reader.TokenType == JsonToken.PropertyName)
                {
                    tagName = reader.Value as string;
                }

                if (reader.TokenType == JsonToken.Boolean)
                {
                    bool b = (bool)reader.Value;
                    TagByte tag = new TagByte(tagName, b);
                    res.Set(tag);
                }
                else if (reader.TokenType == JsonToken.Integer)
                {
                    long l = (long)reader.Value;
                    TagLong tag = new TagLong(tagName, l);
                    res.Set(tag);
                }
                else if (reader.TokenType == JsonToken.Float)
                {
                    double d = (double)reader.Value;
                    TagDouble tag = new TagDouble(tagName, d);
                    res.Set(tag);
                }
                else if (reader.TokenType == JsonToken.String)
                {
                    string s = reader.Value as string;
                    TagString tag = new TagString(tagName, s);
                    res.Set(tag);
                }
                else if (reader.TokenType == JsonToken.StartObject)
                {
                    TagCompound tag = ParseCompound(reader);
                    res.Set(tag);
                }
                else if (reader.TokenType == JsonToken.StartArray)
                {
                    TagList list = ParseList(reader, tagName);
                    res.Set(list);
                }
                else if (reader.TokenType == JsonToken.EndObject)
                {
                    return res;
                }
            }

            return res;
        }
示例#9
0
        public SlotItem(BlockID type, int count, int uses, string name)
        {
            this.ItemID = type;
            this.Count = (byte)count;
            this.Uses = uses;

            var t = new TagCompound();
            var td = new TagCompound();
            t ["display"] = td;
            td ["Name"] = new TagString(name);

            this.Data = t;
        }
示例#10
0
    public void ConstructorTest()
    {
      // arrange
      TagCompound tag;

      // act
      tag = new TagCompound();

      // assert
      Assert.IsEmpty(tag.Name);
      Assert.IsNotNull(tag.Value);
      Assert.AreSame(tag, tag.Value.Owner);
    }
示例#11
0
文件: Program.cs 项目: jaquadro/NNBT
            Type INbtTypeResolver.Resolve(TagCompound tag)
            {
                if (!tag.ContainsKey("Id"))
                    return null;

                string id = tag["Id"] as TagString;
                switch (id) {
                    case "Tile":
                        return typeof(TileLayer);
                    case "Object":
                        return typeof(ObjectLayer);
                    default:
                        return null;
                }
            }
示例#12
0
    public void NameTest()
    {
      // arrange
      TagCompound target;
      string expected;

      target = new TagCompound();
      expected = "newvalue";

      // act
      target.Name = expected;

      // assert
      Assert.AreEqual(expected, target.Name);
    }
示例#13
0
文件: NbtTree.cs 项目: jaquadro/NNBT
        public NbtTree(Stream stream)
        {
            int typeByte = stream.ReadByte();
            if (typeByte == -1)
                throw new EndOfStreamException();

            TagType type = (TagType)typeByte;
            if (type == TagType.Compound) {
                Name = new TagString(stream);
                Root = new TagCompound(stream);
            }
            else {
                Name = "";
                Root = new TagCompound();
            }
        }
示例#14
0
    public void ConstructorWithNameTest()
    {
      // arrange
      TagCompound tag;
      string name;

      name = "creationDate";

      // act
      tag = new TagCompound(name);

      // assert
      Assert.AreEqual(name, tag.Name);
      Assert.IsNotNull(tag.Value);
      Assert.AreSame(tag, tag.Value.Owner);
    }
示例#15
0
    public void ToStringEmptyTest()
    {
      // arrange
      TagCompound target;
      string expected;
      string actual;
      string name;

      name = "tagname";
      expected = string.Format("[Compound: {0}] (0 entries)", name);
      target = new TagCompound(name);

      // act
      actual = target.ToString();

      // assert
      Assert.AreEqual(expected, actual);
    }
示例#16
0
        public static void Load(Item item, TagCompound tag)
        {
            if (tag.Count == 0)
            {
                item.netDefaults(0);
                return;
            }

            string modName = tag.GetString("mod");
            if (modName == "Terraria")
            {
                item.netDefaults(tag.GetInt("id"));
                if (tag.HasTag("legacyData"))
                    LoadLegacyModData(item, tag.GetByteArray("legacyData"), tag.GetBool("hasGlobalSaving"));
            }
            else
            {
                int type = ModLoader.GetMod(modName)?.ItemType(tag.GetString("name")) ?? 0;
                if (type > 0)
                {
                    item.netDefaults(type);
                    if (tag.HasTag("legacyData"))
                        LoadLegacyModData(item, tag.GetByteArray("legacyData"), tag.GetBool("hasGlobalSaving"));
                    else
                        item.modItem.Load(tag.GetCompound("data"));
                }
                else
                {
                    item.netDefaults(ModLoader.GetMod("ModLoader").ItemType("MysteryItem"));
                    ((MysteryItem)item.modItem).Setup(tag);
                }
            }

            item.Prefix(tag.GetByte("prefix"));
            item.stack = tag.GetTag<int?>("stack") ?? 1;
            item.favorited = tag.GetBool("fav");

            if (!(item.modItem is MysteryItem))
                LoadGlobals(item, tag.GetList<TagCompound>("globalData"));
        }
示例#17
0
 public override void Load(TagCompound tag)
 {
     QEItemHandlers  = tag.GetList <ItemPair>("QEItems").ToList();
     QEFluidHandlers = tag.GetList <FluidPair>("QEFluids").ToList();
 }
示例#18
0
 public override void Load(TagCompound tag)
 {
     UUID = tag.Get <Guid>("UUID");
     Handler.Load(tag.GetCompound("Items"));
 }
示例#19
0
 // TODO: This stupid ass shit won't save. Get this thing's gay ass to work.
 public override void Load(TagCompound tag)
 {
     Main.player[Main.myPlayer].GetModPlayer <DeathCountPlayer>().playerDeathCount = tag.GetInt("playerDeathCount");
 }
示例#20
0
 public override void Load(TagCompound tag)
 {
     Platform = PlatformEnum.None;
 }
示例#21
0
        public override void Load(TagCompound tag)
        {
            IList <string> downed = tag.GetList <string>("downed");

            downedFriezaShip = downed.Contains("friezaShip");
        }
        ////////////////

        public override void Load(TagCompound tag)
        {
            var itemInfo = this.item.GetGlobalItem <UmbralCowlItemInfo>();

            itemInfo.IsAllowed = tag.GetBool("is_allowed_use");
        }
 public override void Load(TagCompound tag)
 {
     item.SetDefaults(SanguineGlyph._type);
 }
示例#24
0
 public override void Load(TagCompound tag)
 {
     items = tag.Get <List <Item> >("items");
 }
示例#25
0
 public override void Load(TagCompound tag)
 {
     ExpiryModeIsActive = tag.GetBool("ExpiryModeIsActive");
 }
示例#26
0
        public void TestWrongGetTagType()
        {
            //get a valid NBT type as a different valid NBT type
            try {
                var tag = new TagCompound {
                    { "key1", 2 }
                };
                tag.Get <float>("key1");
                Assert.Fail("Test method did not throw expected exception System.IO.IOException.");
            }
            catch (IOException e) {
                Assert.AreEqual(e.Message, "NBT Deserialization (type=System.Single,entry=int \"key1\" = 2)");
                Assert.AreEqual(e.InnerException.Message, "Unable to cast object of type 'System.Int32' to type 'System.Single'");
            }

            //get a valid NBT type as an invalid NBT type
            try {
                var tag = new TagCompound {
                    { "key1", 2 }
                };
                tag.Get <char>("key1");
                Assert.Fail("Test method did not throw expected exception System.IO.IOException.");
            }
            catch (IOException e) {
                Assert.AreEqual(e.Message, "NBT Deserialization (type=System.Char,entry=int \"key1\" = 2)");
                Assert.AreEqual(e.InnerException.Message, "Unable to cast object of type 'System.Int32' to type 'System.Char'");
            }

            //get a missing tag as an invalid NBT type
            try {
                var tag = new TagCompound();
                tag.Get <char>("key1");
                Assert.Fail("Test method did not throw expected exception System.IO.IOException.");
            }
            catch (IOException e) {
                Assert.AreEqual(e.Message, "NBT Deserialization (type=System.Char,entry=\"key1\" = null)");
                Assert.AreEqual(e.InnerException.Message, "Invalid NBT payload type 'System.Char'");
            }

            //get a list tag as an invalid generic type
            try {
                var tag = new TagCompound {
                    { "key1", new List <int>() }
                };
                tag.Get <IQueryable <int> >("key1");
                Assert.Fail("Test method did not throw expected exception System.IO.IOException.");
            }
            catch (IOException e) {
                Assert.AreEqual(e.Message, "NBT Deserialization (type=System.Linq.IQueryable`1[System.Int32],entry=int \"key1\" [])");
                Assert.AreEqual(e.InnerException.Message, "Unable to cast object of type 'System.Collections.Generic.List`1[System.Int32]' to type 'System.Linq.IQueryable`1[System.Int32]'");
            }

            //get a missing tag as an invalid generic type
            try {
                var tag = new TagCompound();
                tag.Get <IQueryable <int> >("key1");
                Assert.Fail("Test method did not throw expected exception System.IO.IOException.");
            }
            catch (IOException e) {
                Assert.AreEqual(e.Message, "NBT Deserialization (type=System.Linq.IQueryable`1[System.Int32],entry=\"key1\" = null)");
                Assert.AreEqual(e.InnerException.Message, "Invalid NBT payload type 'System.Linq.IQueryable`1[System.Int32]'");
            }
        }
示例#27
0
        public void TestNestedLists()
        {
            var tag = GetNestedListTestTag();

            AssertEqual(tag, AfterIO(tag));

            AssertEqual(tag.ToString(), @"{
  list ""dynList"" [
    int [1, 2, 3, 4, 5],
    string [
      ""a"",
      ""ab"",
      ""abc""
    ],
    object [
      {
        float ""key1"" = 2,
        byte[] ""key2"" = [1, 2, 4],
        object ""key3"" {
          list ""moarLists"" [
            long [-1, -2, -3],
            int[] [
              [],
              [5, 6, 7, 8]
            ]
          ]
        }
      }
    ],
    list [
      object [],
      object [
        {
          string ""key"" = ""value""
        }
      ]
    ]
  ]
}");

            //verify that imposing an element type on a dynamic list throws the appropriate exception
            try {
                tag.GetList <TagCompound>("dynList");
                Assert.Fail("Test method did not throw expected exception System.IO.IOException.");
            }
            catch (IOException e) {
                Assert.IsTrue(e.Message.StartsWith("NBT Deserialization (type=System.Collections.Generic.List`1[Terraria.ModLoader.IO.TagCompound],entry=list \"dynList\" ["));
                Assert.AreEqual(e.InnerException.Message, "Unable to cast object of type 'System.Collections.Generic.List`1[System.Int32]' to type 'Terraria.ModLoader.IO.TagCompound'");
            }

            //verify that recovering a strongly typed list provides a copy with common content
            tag = new TagCompound {
                ["list"] = new List <List <TagCompound> > {
                    new List <TagCompound> {
                        new TagCompound()
                    }
                }
            };
            AssertEqual(tag.ToString(), @"{
  list ""list"" [
    object [
      {}
    ]
  ]
}");

            //should modify the underlying tag
            var list1 = tag.GetList <IList>("list");

            list1.Add(new List <TagCompound>());
            list1[0].Add(new TagCompound());
            AssertEqual(tag.ToString(), @"{
  list ""list"" [
    object [
      {},
      {}
    ],
    object []
  ]
}");
            var list2 = tag.GetList <List <TagCompound> >("list");

            list2.RemoveAt(1);            //no effect on underlying tag
            list2[0][1]["key"] = "value"; //effect on underlying tag
            AssertEqual(tag.ToString(), @"{
  list ""list"" [
    object [
      {},
      {
        string ""key"" = ""value""
      }
    ],
    object []
  ]
}");
        }
示例#28
0
        public static Tile[,] LoadTilesFromBase64(string data)
        {
            int oldX = Main.maxTilesX;
            int oldY = Main.maxTilesY;

            Tile[,] oldTiles    = Main.tile;
            Tile[,] loadedTiles = new Tile[0, 0];
            try
            {
                TagCompound tagCompound = TagIO.FromStream(new MemoryStream(Convert.FromBase64String(data)));
                if (LoadTilesMethodInfo == null)
                {
                    LoadTilesMethodInfo = typeof(Main).Assembly.GetType("Terraria.ModLoader.IO.TileIO").GetMethod("LoadTiles", BindingFlags.Static | BindingFlags.NonPublic);
                }
                if (LoadWorldTilesVanillaMethodInfo == null)
                {
                    LoadWorldTilesVanillaMethodInfo = typeof(Main).Assembly.GetType("Terraria.IO.WorldFile").GetMethod("LoadWorldTiles", BindingFlags.Static | BindingFlags.NonPublic);
                }
                bool[] importance = new bool[TileID.Count];
                for (int i = 0; i < TileID.Count; i++)
                {
                    importance[i] = Main.tileFrameImportant[i];
                }

                Point16 dimensions = tagCompound.Get <Point16>("d");
                Main.maxTilesX = dimensions.X;
                Main.maxTilesY = dimensions.Y;
                loadedTiles    = new Tile[Main.maxTilesX, Main.maxTilesY];
                for (int i = 0; i < Main.maxTilesX; i++)
                {
                    for (int j = 0; j < Main.maxTilesY; j++)
                    {
                        loadedTiles[i, j] = new Tile();
                    }
                }
                Main.tile = loadedTiles;

                using (MemoryStream memoryStream = new MemoryStream(tagCompound.GetByteArray("v")))
                {
                    using (BinaryReader binaryReader = new BinaryReader(memoryStream))
                    {
                        LoadWorldTilesVanillaMethodInfo.Invoke(null, new object[] { binaryReader, importance });
                    }
                }

                if (tagCompound.ContainsKey("m"))
                {
                    LoadTilesMethodInfo.Invoke(null, new object[] { tagCompound["m"] });
                }

                // Expand because TileFrame ignores edges of map.
                Main.maxTilesX = dimensions.X + 12;
                Main.maxTilesY = dimensions.Y + 12;
                Tile[,] loadedTilesExpanded = new Tile[Main.maxTilesX, Main.maxTilesY];
                for (int i = 0; i < Main.maxTilesX; i++)
                {
                    for (int j = 0; j < Main.maxTilesY; j++)
                    {
                        if (i < 6 || i >= Main.maxTilesX - 6 || j < 6 || j >= Main.maxTilesY - 6)
                        {
                            loadedTilesExpanded[i, j] = new Tile();
                        }
                        else
                        {
                            loadedTilesExpanded[i, j] = Main.tile[i - 6, j - 6];
                        }
                    }
                }
                Main.tile = loadedTilesExpanded;

                for (int i = 0; i < Main.maxTilesX; i++)
                {
                    for (int j = 0; j < Main.maxTilesY; j++)
                    {
                        //WorldGen.TileFrame(i, j, true, false);

                        //if (i > 5 && j > 5 && i < Main.maxTilesX - 5 && j < Main.maxTilesY - 5
                        // 0 needs to be 6 ,   MaxX == 5, 4 index,
                        // need tp add 6?       4(10) < 5(11) - 5

                        if (Main.tile[i, j].active())
                        {
                            WorldGen.TileFrame(i, j, true, false);
                        }
                        if (Main.tile[i, j].wall > 0)
                        {
                            Framing.WallFrame(i, j, true);
                        }
                    }
                }
            }
            catch { }
            Main.maxTilesX = oldX;
            Main.maxTilesY = oldY;
            Main.tile      = oldTiles;
            return(loadedTiles);
        }
 public override void Load(TagCompound tag)
 {
     LureMinimum = tag.GetByte(LureCountTag);
 }
 public override void Load(TagCompound tag)
 {
     gems = tag.GetByteArray(nameof(gems));
 }
示例#31
0
 /// <summary>
 /// Allows you to load custom data you have saved for this world.
 /// </summary>
 public virtual void Load(TagCompound tag)
 {
 }
示例#32
0
    public override void Write(TagCompound tag, string fileName, NbtOptions options)
    {
      if (string.IsNullOrEmpty(fileName))
        throw new ArgumentNullException("fileName");
      else if (tag == null)
        throw new ArgumentNullException("tag");

      this.Options = options;

      if (options.HasFlag(NbtOptions.Compress))
        this.WriteCompressed(tag, fileName);
      else
        this.WriteUncompressed(tag, fileName);
    }
示例#33
0
 public override void Load(TagCompound tag)
 {
     CurrentPirateQuest = tag.GetInt("Current");
 }
 public override void Load(TagCompound tag)
 {
     LifeElixir = tag.GetInt("LifeElixir");
     Fuaran     = tag.GetInt("Fuaran");
 }
 public override void Load(Item item, TagCompound tag)
 {
     originalOwner = tag.GetString("originalOwner");
 }
示例#36
0
        public static ITag CreateTag(TagType tagType, string name, object defaultValue)
        {
            ITag result;

              switch (tagType)
              {
            case TagType.Byte:
              result = new TagByte();
              break;

            case TagType.Short:
              result = new TagShort();
              break;

            case TagType.Int:
              result = new TagInt();
              break;

            case TagType.Long:
              result = new TagLong();
              break;

            case TagType.Float:
              result = new TagFloat();
              break;

            case TagType.Double:
              result = new TagDouble();
              break;

            case TagType.ByteArray:
              result = new TagByteArray();
              break;

            case TagType.String:
              result = new TagString();
              break;

            case TagType.List:
              result = new TagList();
              break;

            case TagType.Compound:
              result = new TagCompound();
              break;

            case TagType.IntArray:
              result = new TagIntArray();
              break;

            case TagType.End:
              result = new TagEnd();
              break;

            default:
              throw new ArgumentException(string.Format("Unrecognized tag type: {0}", tagType));
              }

              result.Name = name;
              if (defaultValue != null)
              {
            result.Value = defaultValue;
              }

              return result;
        }
示例#37
0
        /// <summary>
        /// ファイル変換を開始する
        /// </summary>
        /// <param name="file"></param>
        private async void ConvertStart()
        {
            try
            {
                string file     = convertFile.FileName;
                string fileName = System.IO.Path.GetFileName(file);

                using (Bitmap bitmap = new Bitmap(file))
                {
                    ImageConvert imageConvert = new ImageConvert(convertFile, blockColors.ToArray());
                    TagCompound  compound     = new TagCompound();
                    string       savefile     = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(file), System.IO.Path.GetFileNameWithoutExtension(file));
                    bool         convertType  = (bool)NBTRadioButton.IsChecked;
                    convertFile.Total    = bitmap.Height * 2;
                    convertFile.Complete = 0;

                    ProgressBorder.Visibility = Visibility.Visible;
                    ConvertButton.Visibility  = Visibility.Visible;

                    // 非同期処理
                    var convertTask = Task.Run(() =>
                    {
                        if (convertType)
                        {
                            compound  = imageConvert.ToNBT(bitmap);
                            savefile += ".nbt";
                        }
                        else
                        {
                            compound  = imageConvert.ToSchematic(bitmap);
                            savefile += ".schematic";
                        }
                    });

                    await convertTask;

                    ConvertButton.Visibility = Visibility.Collapsed;
                    BuildButton.Visibility   = Visibility.Visible;

                    var buildTask = Task.Run(() =>
                    {
                        OrangeNBT.NBT.IO.NBTFile.ToFile(savefile, compound);
                    });

                    await buildTask;

                    ImageView.Source = imageConvert.ConvertBitmap(bitmap);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(@"変換に失敗しました\" + ex.Message, "ハルの画像変換ソフト",
                                MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                ProgressBorder.Visibility = Visibility.Collapsed;
                ConvertButton.Visibility  = Visibility.Collapsed;
                BuildButton.Visibility    = Visibility.Collapsed;
            }
        }
示例#38
0
 public virtual void WriteDocument(Stream stream, TagCompound tag, CompressionOption compression)
 {
   if (compression != CompressionOption.Off)
   {
     using (Stream compressedStream = new GZipStream(stream, CompressionMode.Compress, true))
     {
       _stream = compressedStream;
       this.WriteTag(tag, WriteTagOptions.None);
     }
   }
   else
   {
     _stream = stream;
     this.WriteTag(tag, WriteTagOptions.None);
   }
 }
示例#39
0
 public static Medal Deserialize(TagCompound tag)
 {
     return(new Medal(tag.GetString("name"), tag.GetInt("difficulty"), tag.GetFloat("order")));
 }
示例#40
0
 public override void Load(TagCompound tag)
 {
     location = new Point16(tag.GetShort("X"), tag.GetShort("Y"));
 }
示例#41
0
 protected void WriteUncompressed(TagCompound tag, string fileName)
 {
   using (FileStream output = File.Open(fileName, FileMode.Create))
   {
     this.OutputStream = output;
     this.Write(tag);
   }
 }
示例#42
0
        public override void Load(TagCompound tag)
        {
            IList <string> list = tag.GetList <string>("InvokerBookSet");

            InvokerBookSetOK = list.Contains("InvokerBookSetOK");
        }
示例#43
0
        public override void Write(TagCompound tag, string fileName, NbtOptions options)
        {
            if (string.IsNullOrEmpty(fileName))
              {
            throw new ArgumentNullException("fileName");
              }

              if (tag == null)
              {
            throw new ArgumentNullException("tag");
              }

              this.Options = options;

              using (Stream fileStream = File.Create(fileName))
              {
            this.OutputStream = fileStream;
            this.Open();
            this.Write(tag, options);
            this.Close();
              }
        }
示例#44
0
 public abstract TagDictionary ReadDictionary(TagCompound owner);
示例#45
0
 public virtual void WriteDocument(Stream stream, TagCompound tag)
 {
   this.WriteDocument(stream, tag, CompressionOption.Auto);
 }
示例#46
0
        public PlayerDat(Tag tag)
        {
            if (tag == null)
            {
                tc = new TagCompound();
                return;
            }
			
            tc = (TagCompound)tag;
			
            foreach (var tp in tc.CompoundList)
            {
                Tag v = tp.Value;
                switch (tp.Key)
                {
                    case "SleepTimer":
                        SleepTimer = v.Short;
                        break;
                    case "Motion":
                        Motion [0] = ((TagList<TagDouble>)v) [0].Double;
                        Motion [1] = ((TagList<TagDouble>)v) [1].Double;
                        Motion [2] = ((TagList<TagDouble>)v) [2].Double;
                        break;
                    case "OnGround":
                        OnGround = v.Byte;
                        break;
                    case "HurtTime":
                        HurtTime = v.Short;
                        break;
                    case "Health":
                        Health = v.Short;
                        break;
                    case "Dimension":
                        Dimension = v.Int;
                        break;
                    case "Air":
                        Air = v.Short;
                        break;
                    case "Inventory":
                        if (v is TagList<TagCompound>)
                        {
                            foreach (TagCompound ti in ((TagList<TagCompound>)v))
                            {
                                byte slot = ti ["Slot"].Byte;
                                SlotItem item = new SlotItem((BlockID)ti ["id"].Short, ti ["Count"].Byte, ti ["Damage"].Short);

                                if (100 <= slot && slot < 104)
                                {
                                    InventoryWear [slot - 100] = item;
                                }
                                if (80 <= slot && slot < 84)
                                {
                                    InventoryCraft [slot - 80] = item;
                                }
                                if (0 <= slot && slot < 36)
                                {
                                    Inventory [slot] = item;
                                }
                            }
                        } else if ((v is TagList<TagByte>) == false)
                        {
                            Console.Error.WriteLine("Player.dat: WARNING: No inventory");
                            Console.Error.WriteLine("Inventory: " + v.GetType() + "\t" + v);
                        }
                        break;
                    case "Pos":
                        Pos.X = ((TagList<TagDouble>)v) [0].Double;
                        Pos.Y = ((TagList<TagDouble>)v) [1].Double;
                        Pos.Z = ((TagList<TagDouble>)v) [2].Double;
                        break;
                    case "AttackTime":
                        AttackTime = v.Short;
                        break;
                    case "Sleeping":
                        Sleeping = v.Byte;
                        break;
                    case "Fire":
                        Fire = v.Short;
                        break;
                    case "FallDistance":
                        FallDistance = v.Float;
                        break;
                    case "Rotation":
                        Rotation [0] = ((TagList<TagFloat>)v) [0].Float;
                        Rotation [1] = ((TagList<TagFloat>)v) [1].Float;
                        break;
                    case "DeathTime":
                        DeathTime = v.Short;
                        break;
                    case "SpawnX":
                        if (Spawn == null)
                            Spawn = new CoordInt();
                        Spawn.X = v.Int;
                        break;
                    case "SpawnY":
                        if (Spawn == null)
                            Spawn = new CoordInt();
                        Spawn.Y = v.Int;
                        break;
                    case "SpawnZ":
                        if (Spawn == null)
                            Spawn = new CoordInt();
                        Spawn.Z = v.Int;
                        break;
                    case "foodExhaustionLevel":
                        foodExhaustionLevel = v.Float;
                        break;
                    case "foodTickTimer":
                        foodTickTimer = v.Int;
                        break;
                    case "foodSaturationLevel":
                        foodSaturationLevel = v.Float;
                        break;
                    case "foodLevel":
                        foodLevel = v.Int;
                        break;
                    case "XpLevel":
                        XpLevel = v.Int;
                        break;
                    case "XpTotal":
                        XpTotal = v.Int;
                        break;
                    case "Xp": //not used anymore
					//Debug.Assert (false);
                        Xp = v.Int;
                        break;
                    case "XpP":
                        XpP = v.Float;
                        break;
                    case "playerGameType":
                        playerGameType = v.Int;
                        break;
                    case "abilities":
					//TODO: booleans
					//flying, instabuild, mayfly, invulnerable
                        break;
                    case "EnderItems":
                        //A list
                        break;
                    case "Attributes":
                        //A list
                        break;
                    case "SelectedItemSlot":
                        //integer
                        break;
                    case "UUIDLeast"://long
                        break;
                    case "UUIDMost"://long
                        break;
                    case "HealF"://float
                        break;
                    case "AbsorptionAmount"://float
                        break;
                    case "SpawnForced": //bool
                        break;
                    case "Score": //int
                        break;
                    case "PortalCooldown": //int
                        break;
                    case "Invulnerable": //bool
                        break;
#if DEBUG
                    default:
                        Console.WriteLine("Unknown: " + tp.Key + ": " + v);
                        throw new NotImplementedException();
#endif
                }				
            }
        }
示例#47
0
 public override void Load(TagCompound tag)
 {
     tag.GetList <TagCompound>("ExtraAccessories").Select(ItemIO.Load).ToList().CopyTo(ExtraAccessories);
     numberExtraAccessoriesEnabled = tag.GetInt("NumberExtraAccessoriesEnabled");
 }
示例#48
0
 public static void Load(TagCompound tag)
 {
     myPayout = tag.Get <int>("cafePayout");
 }
示例#49
0
        private static TagCompound MakeRootTag()
        {
            TagList list = new TagList("ZZZZ", ETagType.Compound);
            TagCompound tag = list.AddCompound();
            tag.SetShort("EF", 4095);
            TagCompound tag2 = list.AddCompound();
            tag2.SetFloat("JK", 0.5f);
            tag2.SetString("TXT", "Hello World!");

            list.Add(tag);
            list.Add(tag2);

            dynamic root = new TagCompound("ROOT");
            root.Set(list);
            root.DYN = new int[] { 5, -6 };
            root.ZZZZ[1].TEST = 0.1;
            return root;
        }
示例#50
0
文件: Glyph.cs 项目: ShoxTech/kRPG
 public override void Load(TagCompound tag)
 {
     base.Load(tag);
     projCount = tag.GetInt("projCount");
 }
示例#51
0
 protected void WriteCompressed(TagCompound tag, string fileName)
 {
   using (Stream fileStream = File.Open(fileName, FileMode.Create))
   {
     using (Stream output = new GZipStream(fileStream, CompressionMode.Compress))
     {
       this.OutputStream = output;
       this.Write(tag);
     }
   }
 }
示例#52
0
 public override void Load(TagCompound tag)
 {
     types = tag.GetList <int>(nameof(types));
 }
示例#53
0
    public override TagDictionary ReadDictionary(TagCompound owner)
    {
      TagDictionary results;
      ITag tag;

      results = new TagDictionary(owner);

      tag = this.Read();
      while (tag.Type != TagType.End)
      {
        results.Add(tag);
        tag = this.Read();
      }

      return results;
    }
示例#54
0
 public override void Load(TagCompound tag)
 {
     Items  = TheOneLibrary.Utility.Utility.Load(tag);
     guid   = tag.ContainsKey("GUID") && !string.IsNullOrEmpty((string)tag["GUID"]) ? Guid.Parse(tag.GetString("GUID")) : Guid.NewGuid();
     active = tag.GetBool("Active");
 }
示例#55
0
 TagDictionary ITagReader.ReadDictionary(TagCompound owner)
 {
   return this.ReadDictionary(owner);
 }
示例#56
0
 public override void Load(TagCompound tag) // Withdraws the gobbler storage from the savefile
 {
     GobblerStorage = tag.GetIntArray("GobblerStorage");
 }
示例#57
0
        public Tag ExportTag()
        {
            tc ["SleepTimer"] = new TagShort(SleepTimer);

            TagList<TagDouble > motion = new TagList<TagDouble>();
            motion [0] = new TagDouble(Motion [0]);
            motion [1] = new TagDouble(Motion [1]);
            motion [2] = new TagDouble(Motion [2]);
            tc ["Motion"] = motion;
            tc ["OnGround"] = new TagByte(){Byte = OnGround};
            tc ["HurtTime"] = new TagShort(HurtTime);
            tc ["Health"] = new TagShort(Health);

            tc ["Dimension"] = new TagInt(Dimension);
            tc ["Air"] = new TagShort(Air);
			
            if (tc ["Inventory"] is TagList<TagCompound> == false)
            {
                tc ["Inventory"] = new TagList<TagCompound>();
            }
            TagList<TagCompound > inv = tc ["Inventory"] as TagList<TagCompound>;
			
            for (byte n = 0; n < 104; n++)
            {
                SlotItem item = null;
                if (n < 36)
                    item = Inventory [n];
                if (n >= 80 && n < 84)
                    item = InventoryCraft [n - 80];
                if (n >= 100)
                    item = InventoryWear [n - 100];

                TagCompound ti = null;
				
                //Find slot item
                foreach (TagCompound itc in inv)
                {
                    if (itc ["Slot"].Byte == n)
                    {
                        ti = itc;
                        break;
                    }
                }
				
                if (item == null)
                {
                    if (ti != null)
                        inv.Remove(ti);
                    continue;
                }
                if (ti == null)
                {
                    ti = new TagCompound();
                    inv.Add(ti);
                }
				
                ti ["id"] = new TagShort((short)item.ItemID);
                ti ["Damage"] = new TagShort((short)item.Uses);
                ti ["Count"] = new TagByte((byte)item.Count);
                ti ["Slot"] = new TagByte(n);
            }
            inv.Sort((x, y) => x ["Slot"].Byte - y ["Slot"].Byte);

            TagList<TagDouble > p = new TagList<TagDouble>();
            p [0] = new TagDouble(Pos .X);
            p [1] = new TagDouble(Pos .Y);
            p [2] = new TagDouble(Pos .Z);
            tc ["Pos"] = p;
            tc ["AttackTime"] = new TagShort(AttackTime);
            tc ["Sleeping"] = new TagByte(Sleeping);
            tc ["Fire"] = new TagShort(Fire);
            tc ["FallDistance"] = new TagFloat(FallDistance);
            TagList<TagFloat > rot = new TagList<TagFloat>();
            rot [0] = new  TagFloat(Rotation [0]);
            rot [1] = new  TagFloat(Rotation [1]);
            tc ["Rotation"] = rot;
            tc ["DeathTime"] = new TagShort(DeathTime);

            if (Spawn != null)
            {
                tc ["SpawnX"] = new TagInt(Spawn.X);
                tc ["SpawnY"] = new TagInt(Spawn.Y);
                tc ["SpawnZ"] = new TagInt(Spawn.Z);
            }
			
            tc ["foodExhaustionLevel"] = new TagFloat(foodExhaustionLevel);
            tc ["foodTickTimer"] = new TagInt(foodTickTimer);
            tc ["foodSaturationLevel"] = new TagFloat(foodSaturationLevel);
            tc ["foodLevel"] = new TagInt(foodLevel);
            tc ["XpLevel"] = new TagInt(XpLevel);
            tc ["XpTotal"] = new TagInt(XpTotal);
            tc ["Xp"] = new TagInt(Xp);
            tc ["playerGameType"] = new TagInt(playerGameType);
			
            return tc;
        }
示例#58
0
        public override void Load(TagCompound tag)
        {
            var downed = tag.GetList <string>("downed");

            downedDarkMon = downed.Contains("darknessMonster");
        }
示例#59
0
 public override void Load(TagCompound tag)
 {
     items = tag.GetList<TagCompound>("items").Select(ItemIO.Load).ToList();
 }
示例#60
0
 public override void Load(TagCompound tag)
 {
     energy = new Core(getMaxEnergyStored());
     base.Load(tag);
 }