public void FillAsteroid(MyVoxelMap asteroid, IMyVoxelFillProperties fillProperties) { _fillMethod.FillAsteroid(asteroid, fillProperties); }
public void FillAsteroid(MyVoxelMap asteroid, IMyVoxelFillProperties fillProperties) { var properties = (AsteroidByteFillProperties)fillProperties; IList<byte> baseAssets; Dictionary<byte, long> materialVoxelCells; asteroid.CalculateMaterialCellAssets(out baseAssets, out materialVoxelCells); var distribution = new List<double> { Double.NaN }; var materialSelection = new List<byte> { SpaceEngineersCore.Resources.GetMaterialIndex(properties.MainMaterial.Value) }; if (properties.SecondPercent > 0) { distribution.Add((double)properties.SecondPercent / 100); materialSelection.Add(SpaceEngineersCore.Resources.GetMaterialIndex(properties.SecondMaterial.Value)); } if (properties.ThirdPercent > 0) { distribution.Add((double)properties.ThirdPercent / 100); materialSelection.Add(SpaceEngineersCore.Resources.GetMaterialIndex(properties.ThirdMaterial.Value)); } if (properties.FourthPercent > 0) { distribution.Add((double)properties.FourthPercent / 100); materialSelection.Add(SpaceEngineersCore.Resources.GetMaterialIndex(properties.FourthMaterial.Value)); } if (properties.FifthPercent > 0) { distribution.Add((double)properties.FifthPercent / 100); materialSelection.Add(SpaceEngineersCore.Resources.GetMaterialIndex(properties.FifthMaterial.Value)); } if (properties.SixthPercent > 0) { distribution.Add((double)properties.SixthPercent / 100); materialSelection.Add(SpaceEngineersCore.Resources.GetMaterialIndex(properties.SixthMaterial.Value)); } if (properties.SeventhPercent > 0) { distribution.Add((double)properties.SeventhPercent / 100); materialSelection.Add(SpaceEngineersCore.Resources.GetMaterialIndex(properties.SeventhMaterial.Value)); } var newDistributiuon = new List<byte>(); int count; for (var i = 1; i < distribution.Count(); i++) { count = (int)Math.Floor(distribution[i] * baseAssets.Count); // Round down. for (var j = 0; j < count; j++) { newDistributiuon.Add(materialSelection[i]); } } count = baseAssets.Count - newDistributiuon.Count; for (var j = 0; j < count; j++) { newDistributiuon.Add(materialSelection[0]); } newDistributiuon.Shuffle(); asteroid.SetMaterialAssets(newDistributiuon); //asteroid.ForceVoxelFaceMaterial(_dataModel.BaseMaterial.DisplayName); }
public void FillAsteroid(MyVoxelMap asteroid, IMyVoxelFillProperties fillProperties) { var properties = (AsteroidSeedFillProperties)fillProperties; /* The full history behind this hack/crutch eludes me. * There are roids that won't change their materials unless their face materials forced to something other than current value. * So we have to do that manually by setting to a usually unused ore (uranium) and then reverting to the one we chose (=old one in case of a flaky roid) */ byte oldMaterial = asteroid.VoxelMaterial; asteroid.ForceVoxelFaceMaterial("Uraninite_01"); asteroid.ForceVoxelFaceMaterial(properties.MainMaterial.Value); // Cycle through veins info and add 'spherical' depisits to the voxel cell grid (not voxels themselves) int i; if (properties.FirstVeins > 0) for (i = 0; i < properties.FirstVeins; i++) asteroid.SeedMaterialSphere(properties.FirstMaterial.Value, (byte)properties.FirstRadius); if (properties.SecondVeins > 0) for (i = 0; i < properties.SecondVeins; i++) asteroid.SeedMaterialSphere(properties.SecondMaterial.Value, (byte)properties.SecondRadius); if (properties.ThirdVeins > 0) for (i = 0; i < properties.ThirdVeins; i++) asteroid.SeedMaterialSphere(properties.ThirdMaterial.Value, (byte)properties.ThirdRadius); if (properties.FourthVeins > 0) for (i = 0; i < properties.FourthVeins; i++) asteroid.SeedMaterialSphere(properties.FourthMaterial.Value, (byte)properties.FourthRadius); if (properties.FifthVeins > 0) for (i = 0; i < properties.FifthVeins; i++) asteroid.SeedMaterialSphere(properties.FifthMaterial.Value, (byte)properties.FifthRadius); if (properties.SixthVeins > 0) for (i = 0; i < properties.SixthVeins; i++) asteroid.SeedMaterialSphere(properties.SixthMaterial.Value, (byte)properties.SixthRadius); if (properties.SeventhVeins > 0) for (i = 0; i < properties.SeventhVeins; i++) asteroid.SeedMaterialSphere(properties.SeventhMaterial.Value, (byte)properties.SeventhRadius); // Hide the surface materials up to depth of 2 cells. asteroid.ForceShellMaterial(properties.MainMaterial.Value, 2); // This recovers material assigning ability for most roids (could be something specific to indestructibleContent property?) // And not for all, apparently :( //asteroid.ForceVoxelFaceMaterial(_dataModel.BaseMaterial.DisplayName); // don't change mattype // doesn't help //asteroid.ForceIndestructibleContent(0xff); // Alt ends }
public void FillAsteroid(MyVoxelMap asteroid, IMyVoxelFillProperties fillProperties) { var properties = (AsteroidByteFillProperties)fillProperties; IList <byte> baseAssets; Dictionary <byte, long> materialVoxelCells; asteroid.CalculateMaterialCellAssets(out baseAssets, out materialVoxelCells); var distribution = new List <double> { Double.NaN }; var materialSelection = new List <byte> { SpaceEngineersCore.Resources.GetMaterialIndex(properties.MainMaterial.Value) }; if (properties.SecondPercent > 0) { distribution.Add((double)properties.SecondPercent / 100); materialSelection.Add(SpaceEngineersCore.Resources.GetMaterialIndex(properties.SecondMaterial.Value)); } if (properties.ThirdPercent > 0) { distribution.Add((double)properties.ThirdPercent / 100); materialSelection.Add(SpaceEngineersCore.Resources.GetMaterialIndex(properties.ThirdMaterial.Value)); } if (properties.FourthPercent > 0) { distribution.Add((double)properties.FourthPercent / 100); materialSelection.Add(SpaceEngineersCore.Resources.GetMaterialIndex(properties.FourthMaterial.Value)); } if (properties.FifthPercent > 0) { distribution.Add((double)properties.FifthPercent / 100); materialSelection.Add(SpaceEngineersCore.Resources.GetMaterialIndex(properties.FifthMaterial.Value)); } if (properties.SixthPercent > 0) { distribution.Add((double)properties.SixthPercent / 100); materialSelection.Add(SpaceEngineersCore.Resources.GetMaterialIndex(properties.SixthMaterial.Value)); } if (properties.SeventhPercent > 0) { distribution.Add((double)properties.SeventhPercent / 100); materialSelection.Add(SpaceEngineersCore.Resources.GetMaterialIndex(properties.SeventhMaterial.Value)); } var newDistributiuon = new List <byte>(); int count; for (var i = 1; i < distribution.Count(); i++) { count = (int)Math.Floor(distribution[i] * baseAssets.Count); // Round down. for (var j = 0; j < count; j++) { newDistributiuon.Add(materialSelection[i]); } } count = baseAssets.Count - newDistributiuon.Count; for (var j = 0; j < count; j++) { newDistributiuon.Add(materialSelection[0]); } newDistributiuon.Shuffle(); asteroid.SetMaterialAssets(newDistributiuon); //asteroid.ForceVoxelFaceMaterial(_dataModel.BaseMaterial.DisplayName); }
public void FillAsteroid(MyVoxelMap asteroid, IMyVoxelFillProperties fillProperties) { var properties = (AsteroidSeedFillProperties)fillProperties; /* The full history behind this hack/crutch eludes me. * There are roids that won't change their materials unless their face materials forced to something other than current value. * So we have to do that manually by setting to a usually unused ore (uranium) and then reverting to the one we chose (=old one in case of a flaky roid) */ byte oldMaterial = asteroid.VoxelMaterial; asteroid.ForceVoxelFaceMaterial("Uraninite_01"); asteroid.ForceVoxelFaceMaterial(properties.MainMaterial.Value); // Cycle through veins info and add 'spherical' depisits to the voxel cell grid (not voxels themselves) int i; if (properties.FirstVeins > 0) { for (i = 0; i < properties.FirstVeins; i++) { asteroid.SeedMaterialSphere(properties.FirstMaterial.Value, (byte)properties.FirstRadius); } } if (properties.SecondVeins > 0) { for (i = 0; i < properties.SecondVeins; i++) { asteroid.SeedMaterialSphere(properties.SecondMaterial.Value, (byte)properties.SecondRadius); } } if (properties.ThirdVeins > 0) { for (i = 0; i < properties.ThirdVeins; i++) { asteroid.SeedMaterialSphere(properties.ThirdMaterial.Value, (byte)properties.ThirdRadius); } } if (properties.FourthVeins > 0) { for (i = 0; i < properties.FourthVeins; i++) { asteroid.SeedMaterialSphere(properties.FourthMaterial.Value, (byte)properties.FourthRadius); } } if (properties.FifthVeins > 0) { for (i = 0; i < properties.FifthVeins; i++) { asteroid.SeedMaterialSphere(properties.FifthMaterial.Value, (byte)properties.FifthRadius); } } if (properties.SixthVeins > 0) { for (i = 0; i < properties.SixthVeins; i++) { asteroid.SeedMaterialSphere(properties.SixthMaterial.Value, (byte)properties.SixthRadius); } } if (properties.SeventhVeins > 0) { for (i = 0; i < properties.SeventhVeins; i++) { asteroid.SeedMaterialSphere(properties.SeventhMaterial.Value, (byte)properties.SeventhRadius); } } // Hide the surface materials up to depth of 2 cells. asteroid.ForceShellMaterial(properties.MainMaterial.Value, 2); // This recovers material assigning ability for most roids (could be something specific to indestructibleContent property?) // And not for all, apparently :( //asteroid.ForceVoxelFaceMaterial(_dataModel.BaseMaterial.DisplayName); // don't change mattype // doesn't help //asteroid.ForceIndestructibleContent(0xff); // Alt ends }