示例#1
0
        /// <summary>
        /// Builds an asteroid Voxel. Voxel detail will be completed by function callbacks.
        /// This allows for muti-threading, and generating content via algorithims.
        /// </summary>
        /// <param name="multiThread"></param>
        /// <param name="size"></param>
        /// <param name="material"></param>
        /// <param name="faceMaterial"></param>
        /// <param name="func"></param>
        /// <returns></returns>
        public static MyVoxelMap BuildAsteroid(bool multiThread, Vector3I size, string material, string faceMaterial, Action <MyVoxelBuilderArgs> func)
        {
            var voxelMap   = new MyVoxelMap();
            var actualSize = new Vector3I(size.X.RoundUpToNearest(64), size.Y.RoundUpToNearest(64), size.Z.RoundUpToNearest(64));

            voxelMap.Init(VRageMath.Vector3D.Zero, actualSize, material);

            ProcessAsteroid(voxelMap, multiThread, material, func, false);

            if (faceMaterial != null)
            {
                voxelMap.ForceVoxelFaceMaterial(faceMaterial);
            }

            return(voxelMap);
        }
        public void ReplaceAllExecuted(string materialName)
        {
            MainViewModel.IsBusy = true;
            var sourceFile = DataModel.SourceVoxelFilepath ?? DataModel.VoxelFilepath;

            var asteroid = new MyVoxelMap();

            asteroid.Load(sourceFile, SpaceEngineersCore.Resources.GetDefaultMaterialName(), true);

            asteroid.ForceBaseMaterial(materialName, materialName);
            asteroid.ForceVoxelFaceMaterial(SpaceEngineersCore.Resources.GetDefaultMaterialName());

            var tempfilename = TempfileUtil.NewFilename(MyVoxelMap.V2FileExtension);

            asteroid.Save(tempfilename);
            DataModel.SourceVoxelFilepath = tempfilename;

            MainViewModel.IsModified = true;
            MainViewModel.IsBusy     = false;

            DataModel.MaterialAssets = null;
            DataModel.InitializeAsync();
        }
示例#3
0
        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
        }