public virtual void DeleteOneFirstTerrain() { if (terrainsList.Count > 0) { AbstractTag newterrainToDel = terrainsList[0]; terrainsList.Remove(newterrainToDel); terrainsListToDel.Add(newterrainToDel); } }
public override void ReStart() { versionForCoRoutine++; base.ReStart(); currentTerrain = null; for (int i = 0; i < terrainsListToDel.Count; i++) { AbstractTag newterrainToDel = terrainsListToDel[i]; List <AbstractTag> AllElements = (newterrainToDel.GetComponent("TerrainTag") as TerrainTag).GetAllElements(); AllElements.Clear(); } }
public static List <MockSpan> GetByTag <T>(List <MockSpan> spans, AbstractTag <T> key, T value) { var found = new List <MockSpan>(spans.Count); foreach (var span in spans) { if (span.Tags[key.Key].Equals(value)) { found.Add(span); } } return(found); }
private IEnumerator ClearTerrainFactory() { int curversionForCoRoutine = versionForCoRoutine; if (terrainsList.Count > 0) { if (curversionForCoRoutine != versionForCoRoutine) { yield break; } AbstractTag newterrainToDel = terrainsList[0]; TerrainTag terrainTag = newterrainToDel.GetComponent("TerrainTag") as TerrainTag; List <AbstractTag> AllElements = terrainTag.GetAllElements(); terrainTag.RemakeAllElementsList(); yield return(null); if (curversionForCoRoutine != versionForCoRoutine) { yield break; } terrainsList.Remove(newterrainToDel); terrainsListToDel.Add(newterrainToDel); if (curversionForCoRoutine != versionForCoRoutine) { yield break; } yield return(null); for (int i = 0; i < AllElements.Count; i++) { if (curversionForCoRoutine != versionForCoRoutine) { yield break; } if (AllElements[i]) { AllElements[i].DeleteFromUsed(); } yield return(null); } if (curversionForCoRoutine != versionForCoRoutine) { yield break; } AllElements.Clear(); AllElements = null; } yield return(null); }
public void TestReadNonExistantTagFromCompound() { String filename = @"..\..\..\LibNBT Tests\Data\test.nbt"; TagCompound newTag = new TagCompound(); AbstractTag aTag = newTag.GetAbstractTag("nope"); Assert.IsNull(aTag); TagCompound fileTag = AbstractTag.ReadFromFile(filename) as TagCompound; aTag = fileTag.GetAbstractTag("Entities"); Assert.IsNull(aTag); }
public void TestLoadSimpleNbt() { String filename = @"..\..\..\LibNBT Tests\Data\test.nbt"; AbstractTag tag = TagCompound.ReadFromFile(filename); Assert.IsNotNull(tag); Assert.IsInstanceOfType(tag, typeof(TagCompound)); TagCompound root = tag as TagCompound; Assert.AreEqual <String>("hello world", root.Name); TagString tagStr = root.GetString("name"); Assert.AreEqual <String>("name", tagStr.Name); Assert.AreEqual <String>("Bananrama", tagStr.Value); }
public virtual void DestroyPullObjects() { AbstractTag newTerrain = null; for (int i = 0; i < terrainsListToDel.Count; i++) { newTerrain = terrainsListToDel[i]; Destroy(newTerrain.gameObject); } terrainsListToDel.Clear(); for (int i = 0; i < terrainsList.Count; i++) { newTerrain = terrainsList[i]; Destroy(newTerrain.gameObject); } terrainsList.Clear(); }
public static MockSpan GetOneByTag <T>(List <MockSpan> spans, AbstractTag <T> key, T value) { var found = GetByTag(spans, key, value); if (found.Count > 1) { throw new ArgumentException("there is more than one span with tag '" + key.Key + "' and value '" + value + "'"); } if (found.Count == 0) { return(null); } else { return(found[0]); } }
public override void PutToFirstState(AbstractTag newTerrain) { newTerrain.singleTransform.position = new Vector3(-9999, -9999, -9999); newTerrain.singleTransform.rotation = Quaternion.identity; //MakeInactiveObjectsActive TerrainTag terrainTag = newTerrain.GetComponent("TerrainTag") as TerrainTag; terrainTag.ParseObstacleSets(); //terrainTag.MakeAllActive(); if (!GlobalOptions.flagOnlyFizik) { terrainTag.RecalculateRoadPathArray(); if (terrainsList.Count > 0) { TerrainTag terrainTagPrev = (terrainsList[terrainsList.Count - 1] as Abstract).GetComponent("TerrainTag") as TerrainTag; terrainTag.SetPrev(terrainTagPrev); terrainTagPrev.SetNext(terrainTag); } } }
public void PushToAllElements(AbstractTag inobj) { AllElements.Add(inobj); }
public void TestLoadComplexNbt() { String filename = @"..\..\..\LibNBT Tests\Data\bigtest.nbt"; AbstractTag tag = TagCompound.ReadFromFile(filename); Assert.IsNotNull(tag); Assert.IsInstanceOfType(tag, typeof(TagCompound)); TagCompound level = tag as TagCompound; Assert.AreEqual <String>("Level", level.Name); TagShort shortTest = level.GetShort("shortTest"); Assert.IsNotNull(shortTest); Assert.AreEqual <String>("shortTest", shortTest.Name); Assert.AreEqual <short>(32767, shortTest.Value); TagLong longTest = level.GetLong("longTest"); Assert.IsNotNull(longTest); Assert.AreEqual <String>("longTest", longTest.Name); Assert.AreEqual <long>(9223372036854775807, longTest.Value); TagFloat floatTest = level.GetFloat("floatTest"); Assert.IsNotNull(floatTest); Assert.AreEqual <String>("floatTest", floatTest.Name); Assert.AreEqual <float>(0.49823147f, floatTest.Value); TagString stringTest = level.GetString("stringTest"); Assert.IsNotNull(stringTest); Assert.AreEqual <String>("stringTest", stringTest.Name); Assert.AreEqual <String>("HELLO WORLD THIS IS A TEST STRING ÅÄÖ!", stringTest.Value); TagInt intTest = level.GetInt("intTest"); Assert.IsNotNull(intTest); Assert.AreEqual <String>("intTest", intTest.Name); Assert.AreEqual <int>(2147483647, intTest.Value); TagCompound nestedCompoundTest = level.GetCompound("nested compound test"); Assert.IsNotNull(nestedCompoundTest); Assert.AreEqual <String>("nested compound test", nestedCompoundTest.Name); TagCompound ham = nestedCompoundTest.GetCompound("ham"); Assert.IsNotNull(ham); Assert.AreEqual <String>("ham", ham.Name); TagString ham_name = ham.GetString("name"); Assert.IsNotNull(ham_name); Assert.AreEqual <String>("name", ham_name.Name); Assert.AreEqual <String>("Hampus", ham_name.Value); TagFloat ham_value = ham.GetFloat("value"); Assert.IsNotNull(ham_value); Assert.AreEqual <String>("value", ham_value.Name); Assert.AreEqual <float>(0.75f, ham_value.Value); TagCompound egg = nestedCompoundTest.GetCompound("egg"); Assert.IsNotNull(egg); Assert.AreEqual <String>("egg", egg.Name); TagString egg_name = egg.GetString("name"); Assert.IsNotNull(egg_name); Assert.AreEqual <String>("name", egg_name.Name); Assert.AreEqual <String>("Eggbert", egg_name.Value); TagFloat egg_value = egg.GetFloat("value"); Assert.IsNotNull(egg_value); Assert.AreEqual <String>("value", egg_value.Name); Assert.AreEqual <float>(0.5f, egg_value.Value); TagByte byteTest = level.GetByte("byteTest"); Assert.IsNotNull(byteTest); Assert.AreEqual <String>("byteTest", byteTest.Name); Assert.AreEqual <byte>(0x7f, byteTest.Value); TagDouble doubleTest = level.GetDouble("doubleTest"); Assert.IsNotNull(doubleTest); Assert.AreEqual <String>("doubleTest", doubleTest.Name); Assert.AreEqual <double>(0.4931287132182315, doubleTest.Value); TagList listTest_long = level.GetList("listTest (long)"); Assert.IsNotNull(listTest_long); Assert.AreEqual <String>("listTest (long)", listTest_long.Name); Assert.IsNotNull(listTest_long.Value); Assert.AreEqual <int>(5, listTest_long.Value.Count); Assert.AreEqual <long>(11, (listTest_long.Value[0] as TagLong).Value); Assert.AreEqual <long>(12, (listTest_long.Value[1] as TagLong).Value); Assert.AreEqual <long>(13, (listTest_long.Value[2] as TagLong).Value); Assert.AreEqual <long>(14, (listTest_long.Value[3] as TagLong).Value); Assert.AreEqual <long>(15, (listTest_long.Value[4] as TagLong).Value); TagList listTest_compound = level.GetList("listTest (compound)"); Assert.IsNotNull(listTest_compound); Assert.AreEqual <String>("listTest (compound)", listTest_compound.Name); Assert.IsNotNull(listTest_compound.Value); Assert.AreEqual <int>(2, listTest_compound.Value.Count); TagCompound listTest_compound_tag0 = listTest_compound.Value[0] as TagCompound; Assert.IsNotNull(listTest_compound_tag0); TagString listTest_compound_tag0_name = listTest_compound_tag0.GetString("name"); Assert.IsNotNull(listTest_compound_tag0_name); Assert.AreEqual <String>("name", listTest_compound_tag0_name.Name); Assert.AreEqual <String>("Compound tag #0", listTest_compound_tag0_name.Value); TagLong listTest_compound_tag0_createdOn = listTest_compound_tag0.GetLong("created-on"); Assert.IsNotNull(listTest_compound_tag0_createdOn); Assert.AreEqual <String>("created-on", listTest_compound_tag0_createdOn.Name); Assert.AreEqual <long>(1264099775885, listTest_compound_tag0_createdOn.Value); TagCompound listTest_compound_tag1 = listTest_compound.Value[1] as TagCompound; Assert.IsNotNull(listTest_compound_tag1); TagString listTest_compound_tag1_name = listTest_compound_tag1.GetString("name"); Assert.IsNotNull(listTest_compound_tag1_name); Assert.AreEqual <String>("name", listTest_compound_tag1_name.Name); Assert.AreEqual <String>("Compound tag #1", listTest_compound_tag1_name.Value); TagLong listTest_compound_tag1_createdOn = listTest_compound_tag1.GetLong("created-on"); Assert.IsNotNull(listTest_compound_tag1_createdOn); Assert.AreEqual <String>("created-on", listTest_compound_tag1_createdOn.Name); Assert.AreEqual <long>(1264099775885, listTest_compound_tag1_createdOn.Value); TagByteArray byteArrayTest = level.GetByteArray("byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))"); Assert.IsNotNull(byteArrayTest); Assert.AreEqual <String>("byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))", byteArrayTest.Name); Assert.IsNotNull(byteArrayTest.Value); Assert.AreEqual <int>(1000, byteArrayTest.Value.Length); }
public void TestAnvilRegion() { String filename = @"..\..\..\LibNBT Tests\Data\r.0.0.mca"; FileStream input = File.OpenRead(filename); int[] locations = new int[1024]; byte[] buffer = new byte[4096]; input.Read(buffer, 0, 4096); for (int i = 0; i < 1024; i++) { locations[i] = BitConverter.ToInt32(buffer, i * 4); } int[] timestamps = new int[1024]; input.Read(buffer, 0, 4096); for (int i = 0; i < 1024; i++) { timestamps[i] = BitConverter.ToInt32(buffer, i * 4); } input.Read(buffer, 0, 4); if (BitConverter.IsLittleEndian) { BitHelper.SwapBytes(buffer, 0, 4); } int sizeOfChunkData = BitConverter.ToInt32(buffer, 0) - 1; int compressionType = input.ReadByte(); buffer = new byte[sizeOfChunkData]; input.Read(buffer, 0, sizeOfChunkData); Stream inputStream = null; if (compressionType == 1) { inputStream = new GZipStream(new MemoryStream(buffer), CompressionMode.Decompress); } else if (compressionType == 2) { inputStream = new DeflateStream(new MemoryStream(buffer, 2, buffer.Length - 6), CompressionMode.Decompress); } TagCompound tag = AbstractTag.Read(inputStream) as TagCompound; string strTag = tag.ToString(); Assert.IsNotNull(tag); Assert.AreEqual <TagType>(TagType.Compound, tag.GetAbstractTag("Level").Type); TagCompound levelTag = tag.GetCompound("Level"); AbstractTag aTag = levelTag.GetAbstractTag("Entities"); Assert.AreEqual <TagType>(TagType.List, aTag.Type); TagList entitiesTag = aTag as TagList; Assert.AreEqual <int>(0, entitiesTag.Value.Count); aTag = levelTag.GetAbstractTag("Biomes"); Assert.AreEqual <TagType>(TagType.ByteArray, aTag.Type); TagByteArray biomesTag = aTag as TagByteArray; Assert.AreEqual <int>(256, biomesTag.Value.Length); aTag = levelTag.GetAbstractTag("LastUpdate"); Assert.AreEqual <TagType>(TagType.Long, aTag.Type); TagLong lastUpdateTag = aTag as TagLong; Assert.AreEqual <long>(2861877, lastUpdateTag.Value); aTag = levelTag.GetAbstractTag("xPos"); Assert.AreEqual <TagType>(TagType.Int, aTag.Type); TagInt xPosTag = aTag as TagInt; Assert.AreEqual <int>(10, xPosTag.Value); aTag = levelTag.GetAbstractTag("zPos"); Assert.AreEqual <TagType>(TagType.Int, aTag.Type); TagInt zPosTag = aTag as TagInt; Assert.AreEqual <int>(0, zPosTag.Value); aTag = levelTag.GetAbstractTag("TileEntities"); Assert.AreEqual <TagType>(TagType.List, aTag.Type); TagList tileEntitiesTag = aTag as TagList; Assert.AreEqual <int>(0, tileEntitiesTag.Value.Count); aTag = levelTag.GetAbstractTag("TerrainPopulated"); Assert.AreEqual <TagType>(TagType.Byte, aTag.Type); TagByte terrainPopulatedTag = aTag as TagByte; Assert.AreEqual <byte>(1, terrainPopulatedTag.Value); aTag = levelTag.GetAbstractTag("HeightMap"); Assert.AreEqual <TagType>(TagType.IntArray, aTag.Type); TagIntArray heightmapTag = aTag as TagIntArray; Assert.AreEqual <int>(256, heightmapTag.Value.Length); aTag = levelTag.GetAbstractTag("Sections"); Assert.AreEqual <TagType>(TagType.List, aTag.Type); TagList sectionsTag = aTag as TagList; Assert.AreEqual <int>(4, sectionsTag.Value.Count); TagCompound section_0 = sectionsTag.Value[0] as TagCompound; Assert.IsNotNull(section_0); TagByteArray section_0_data = section_0.GetByteArray("Data"); Assert.IsNotNull(section_0_data); Assert.AreEqual <int>(2048, section_0_data.Value.Length); TagByteArray section_0_skyLight = section_0.GetByteArray("SkyLight"); Assert.IsNotNull(section_0_skyLight); Assert.AreEqual <int>(2048, section_0_skyLight.Value.Length); TagByteArray section_0_blockLight = section_0.GetByteArray("BlockLight"); Assert.IsNotNull(section_0_blockLight); Assert.AreEqual <int>(2048, section_0_blockLight.Value.Length); TagByte section_0_y = section_0.GetByte("Y"); Assert.IsNotNull(section_0_y); Assert.AreEqual <byte>(0, section_0_y.Value); TagByteArray section_0_blocks = section_0.GetByteArray("Blocks"); Assert.IsNotNull(section_0_blocks); Assert.AreEqual <int>(4096, section_0_blocks.Value.Length); TagCompound section_1 = sectionsTag.Value[1] as TagCompound; Assert.IsNotNull(section_1); TagByteArray section_1_data = section_1.GetByteArray("Data"); Assert.IsNotNull(section_1_data); Assert.AreEqual <int>(2048, section_1_data.Value.Length); TagByteArray section_1_skyLight = section_1.GetByteArray("SkyLight"); Assert.IsNotNull(section_1_skyLight); Assert.AreEqual <int>(2048, section_1_skyLight.Value.Length); TagByteArray section_1_blockLight = section_1.GetByteArray("BlockLight"); Assert.IsNotNull(section_1_blockLight); Assert.AreEqual <int>(2048, section_1_blockLight.Value.Length); TagByte section_1_y = section_1.GetByte("Y"); Assert.IsNotNull(section_1_y); Assert.AreEqual <byte>(1, section_1_y.Value); TagByteArray section_1_blocks = section_1.GetByteArray("Blocks"); Assert.IsNotNull(section_1_blocks); Assert.AreEqual <int>(4096, section_1_blocks.Value.Length); TagCompound section_2 = sectionsTag.Value[2] as TagCompound; Assert.IsNotNull(section_2); TagByteArray section_2_data = section_2.GetByteArray("Data"); Assert.IsNotNull(section_2_data); Assert.AreEqual <int>(2048, section_2_data.Value.Length); TagByteArray section_2_skyLight = section_2.GetByteArray("SkyLight"); Assert.IsNotNull(section_2_skyLight); Assert.AreEqual <int>(2048, section_2_skyLight.Value.Length); TagByteArray section_2_blockLight = section_2.GetByteArray("BlockLight"); Assert.IsNotNull(section_2_blockLight); Assert.AreEqual <int>(2048, section_2_blockLight.Value.Length); TagByte section_2_y = section_2.GetByte("Y"); Assert.IsNotNull(section_2_y); Assert.AreEqual <byte>(2, section_2_y.Value); TagByteArray section_2_blocks = section_2.GetByteArray("Blocks"); Assert.IsNotNull(section_2_blocks); Assert.AreEqual <int>(4096, section_2_blocks.Value.Length); TagCompound section_3 = sectionsTag.Value[3] as TagCompound; Assert.IsNotNull(section_3); TagByteArray section_3_data = section_3.GetByteArray("Data"); Assert.IsNotNull(section_3_data); Assert.AreEqual <int>(2048, section_3_data.Value.Length); TagByteArray section_3_skyLight = section_3.GetByteArray("SkyLight"); Assert.IsNotNull(section_3_skyLight); Assert.AreEqual <int>(2048, section_3_skyLight.Value.Length); TagByteArray section_3_blockLight = section_3.GetByteArray("BlockLight"); Assert.IsNotNull(section_3_blockLight); Assert.AreEqual <int>(2048, section_3_blockLight.Value.Length); TagByte section_3_y = section_3.GetByte("Y"); Assert.IsNotNull(section_3_y); Assert.AreEqual <byte>(3, section_3_y.Value); TagByteArray section_3_blocks = section_3.GetByteArray("Blocks"); Assert.IsNotNull(section_3_blocks); Assert.AreEqual <int>(4096, section_3_blocks.Value.Length); }
public void DeleteCurrent(AbstractTag inObject) { terrainsList.Remove(inObject); terrainsListToDel.Add(inObject); inObject.singleTransform.parent = null; }
public virtual void PutToFirstState(AbstractTag newTerrain) { newTerrain.singleTransform.position = new Vector3(-9999, -9999, -9999); newTerrain.singleTransform.rotation = Quaternion.identity; newTerrain.ReStart(); }