public void VoxelMaterialAssets_MixedGeneratedAsset() { SpaceEngineersCore.LoadDefinitions(); var materials = SpaceEngineersCore.Resources.GetMaterialList(); Assert.IsTrue(materials.Count > 0, "Materials should exist. Has the developer got Space Engineers installed?"); var goldMaterial = materials.FirstOrDefault(m => m.Id.SubtypeId.Contains("Gold")); Assert.IsNotNull(goldMaterial, "Gold material should exist."); const string fileOriginal = @".\TestAssets\asteroid0moon4.vx2"; var voxelMap = new MyVoxelMap(); voxelMap.Load(fileOriginal, materials[0].Id.SubtypeId); IList <byte> materialAssets; Dictionary <byte, long> materialVoxelCells; voxelMap.CalculateMaterialCellAssets(out materialAssets, out materialVoxelCells); Assert.AreEqual(44135, materialAssets.Count, "Asset count should be equal."); var otherAssets = materialAssets.Where(c => c != 4).ToList(); Assert.AreEqual(0, otherAssets.Count, "Other Asset count should be equal."); var assetNameCount = voxelMap.CountAssets(materialAssets); Assert.IsTrue(assetNameCount.Count > 0, "Contains assets."); }
public void VoxelMaterialAssets_FixedSize_MixedContent() { SpaceEngineersCore.LoadDefinitions(); var materials = SpaceEngineersCore.Resources.GetMaterialList(); Assert.IsTrue(materials.Count > 0, "Materials should exist. Has the developer got Space Engineers installed?"); var goldMaterial = materials.FirstOrDefault(m => m.Id.SubtypeId.Contains("Gold")); Assert.IsNotNull(goldMaterial, "Gold material should exist."); const string fileOriginal = @".\TestAssets\test_cube_mixed_2x2x2.vx2"; var voxelMap = new MyVoxelMap(); voxelMap.Load(fileOriginal, materials[0].Id.SubtypeId); var cellCount = voxelMap.SumVoxelCells(); IList <byte> materialAssets; Dictionary <byte, long> materialVoxelCells; voxelMap.CalculateMaterialCellAssets(out materialAssets, out materialVoxelCells); var assetNameCount = voxelMap.CountAssets(materialAssets); Assert.AreEqual(8 * 255, cellCount, "Cell count should be equal."); Assert.AreEqual(8, materialAssets.Count, "Asset count should be equal."); Assert.AreEqual(8, assetNameCount.Count, "Asset Mertials count should be equal."); }
public void VoxelLoadStock() { SpaceEngineersCore.LoadDefinitions(); var materials = SpaceEngineersCore.Resources.GetMaterialList(); Assert.IsTrue(materials.Count > 0, "Materials should exist. Has the developer got Space Engineers installed?"); var contentPath = ToolboxUpdater.GetApplicationContentPath(); var redShipCrashedAsteroidPath = Path.Combine(contentPath, "VoxelMaps", "RedShipCrashedAsteroid.vx2"); var voxelMap = new MyVoxelMap(); voxelMap.Load(redShipCrashedAsteroidPath, materials[0].Id.SubtypeId); Assert.AreEqual(1, voxelMap.FileVersion, "FileVersion should be equal."); IList <byte> materialAssets; Dictionary <byte, long> materialVoxelCells; voxelMap.CalculateMaterialCellAssets(out materialAssets, out materialVoxelCells); Assert.AreEqual(563742, materialAssets.Count, "Asset count should be equal."); var asset0 = materialAssets.Where(c => c == 0).ToList(); Assert.AreEqual(563742, asset0.Count, "asset0 count should be equal."); var assetNameCount = voxelMap.CountAssets(materialAssets); Assert.IsTrue(assetNameCount.Count > 0, "Contains assets."); var lengthOriginal = new FileInfo(redShipCrashedAsteroidPath).Length; Assert.AreEqual(51819, lengthOriginal, "File size must match."); }
public void VoxelLoadSaveVx2V1() { SpaceEngineersCore.LoadDefinitions(); var materials = SpaceEngineersCore.Resources.GetMaterialList(); Assert.IsTrue(materials.Count > 0, "Materials should exist. Has the developer got Space Engineers installed?"); const string fileOriginal = @".\TestAssets\AsteroidV1Format.vx2"; const string fileNew = @".\TestOutput\AsteroidV1Format_save.vx2"; var voxelMap = new MyVoxelMap(); voxelMap.Load(fileOriginal, materials[0].Id.SubtypeId); IList <byte> materialAssets; Dictionary <byte, long> materialVoxelCells; voxelMap.CalculateMaterialCellAssets(out materialAssets, out materialVoxelCells); Assert.AreEqual(594485, materialAssets.Count, "Asset count should be equal."); var asset0 = materialAssets.Where(c => c == 0).ToList(); Assert.AreEqual(0, asset0.Count, "asset0 count should be equal."); var asset1 = materialAssets.Where(c => c == 1).ToList(); Assert.AreEqual(0, asset1.Count, "asset1 Asset count should be equal."); var asset2 = materialAssets.Where(c => c == 2).ToList(); Assert.AreEqual(0, asset2.Count, "asset2 Asset count should be equal."); var asset3 = materialAssets.Where(c => c == 3).ToList(); Assert.AreEqual(251145, asset3.Count, "asset3 Asset count should be equal."); var asset4 = materialAssets.Where(c => c == 4).ToList(); Assert.AreEqual(0, asset4.Count, "asset4 Asset count should be equal."); var asset5 = materialAssets.Where(c => c == 5).ToList(); Assert.AreEqual(0, asset5.Count, "asset5 Asset count should be equal."); var asset6 = materialAssets.Where(c => c == 6).ToList(); Assert.AreEqual(217283, asset6.Count, "asset6 Asset count should be equal."); var asset7 = materialAssets.Where(c => c == 7).ToList(); Assert.AreEqual(237, asset7.Count, "asset7 Asset count should be equal."); var asset8 = materialAssets.Where(c => c == 8).ToList(); Assert.AreEqual(9608, asset8.Count, "asset8 Asset count should be equal."); var asset9 = materialAssets.Where(c => c == 9).ToList(); Assert.AreEqual(40801, asset9.Count, "asset9 Asset count should be equal."); var asset10 = materialAssets.Where(c => c == 10).ToList(); Assert.AreEqual(152, asset10.Count, "asset10 Asset count should be equal."); var assetNameCount = voxelMap.CountAssets(materialAssets); Assert.IsTrue(assetNameCount.Count > 0, "Contains assets."); voxelMap.Save(fileNew); var lengthOriginal = new FileInfo(fileOriginal).Length; var lengthNew = new FileInfo(fileNew).Length; Assert.AreEqual(88299, lengthOriginal, "File size must match."); Assert.AreEqual(72296, lengthNew, "File size must match."); }
public void VoxelMaterialAssetsRandom() { SpaceEngineersCore.LoadDefinitions(); var materials = SpaceEngineersCore.Resources.GetMaterialList(); Assert.IsTrue(materials.Count > 0, "Materials should exist. Has the developer got Space Engineers installed?"); var stoneMaterial = materials.FirstOrDefault(m => m.Id.SubtypeId.Contains("Stone_05")); Assert.IsNotNull(stoneMaterial, "Stone material should exist."); var goldMaterial = materials.FirstOrDefault(m => m.Id.SubtypeId.Contains("Gold")); Assert.IsNotNull(goldMaterial, "Gold material should exist."); var uraniumMaterial = materials.FirstOrDefault(m => m.Id.SubtypeId.Contains("Uraninite_01")); Assert.IsNotNull(uraniumMaterial, "Uranium material should exist."); const string fileOriginal = @".\TestAssets\Arabian_Border_7.vx2"; const string fileNewVoxel = @".\TestOutput\Arabian_Border_7_mixed.vx2"; var voxelMap = new MyVoxelMap(); voxelMap.Load(fileOriginal, materials[0].Id.SubtypeId); IList <byte> materialAssets; Dictionary <byte, long> materialVoxelCells; voxelMap.CalculateMaterialCellAssets(out materialAssets, out materialVoxelCells); Assert.AreEqual(35465, materialAssets.Count, "Asset count should be equal."); var distribution = new[] { Double.NaN, .5, .25 }; var materialSelection = new[] { SpaceEngineersCore.Resources.GetMaterialIndex(stoneMaterial.Id.SubtypeId), SpaceEngineersCore.Resources.GetMaterialIndex(goldMaterial.Id.SubtypeId), SpaceEngineersCore.Resources.GetMaterialIndex(uraniumMaterial.Id.SubtypeId) }; var newDistributiuon = new List <byte>(); int count; for (var i = 1; i < distribution.Count(); i++) { count = (int)Math.Floor(distribution[i] * materialAssets.Count); // Round down. for (var j = 0; j < count; j++) { newDistributiuon.Add(materialSelection[i]); } } count = materialAssets.Count - newDistributiuon.Count; for (var j = 0; j < count; j++) { newDistributiuon.Add(materialSelection[0]); } newDistributiuon.Shuffle(); var assetNameCount = voxelMap.CountAssets(newDistributiuon); Assert.AreEqual(3, assetNameCount.Count, "Asset Mertials count should be equal."); Assert.AreEqual(8867, assetNameCount[stoneMaterial.Id.SubtypeId], "Asset Mertials count should be equal."); Assert.AreEqual(17732, assetNameCount[goldMaterial.Id.SubtypeId], "Asset Mertials count should be equal."); Assert.AreEqual(8866, assetNameCount[uraniumMaterial.Id.SubtypeId], "Asset Mertials count should be equal."); voxelMap.SetMaterialAssets(newDistributiuon); voxelMap.CalculateMaterialCellAssets(out materialAssets, out materialVoxelCells); var cellCount = voxelMap.SumVoxelCells(); voxelMap.Save(fileNewVoxel); }