Exemplo n.º 1
0
        public ExteriorSkyIslandMapChunkFactory(
            IRasterChunkConfig <Index2D> config, SkyIslandMaps outOfBoundsValue, bool modifyingThrowsException)
        {
            Contracts.Requires.That(config != null);

            this.outOfBoundsChunk = new ConstantArray2D <SkyIslandMaps>(
                config.Bounds.Dimensions, outOfBoundsValue, modifyingThrowsException);
        }
        public void SetFiniteBounds(
            IStageBounds stageBounds, SkyIslandMaps outOfBoundsValue, bool modifyingThrowsException = true)
        {
            Contracts.Requires.That(stageBounds != null);

            this.stageBounds              = stageBounds;
            this.outOfBoundsValue         = outOfBoundsValue;
            this.modifyingThrowsException = modifyingThrowsException;
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public async Task InitializeAsync()
        {
            if (string.IsNullOrWhiteSpace(this.imagesOptions?.ShapePercentWeightMapImagePath) &&
                string.IsNullOrWhiteSpace(this.imagesOptions?.BaselineHeightImagePath) &&
                string.IsNullOrWhiteSpace(this.imagesOptions?.MountainHeightMultiplierImagePath) &&
                string.IsNullOrWhiteSpace(this.imagesOptions?.TopHeightImagePath) &&
                string.IsNullOrWhiteSpace(this.imagesOptions?.BottomHeightImagePath))
            {
                return;
            }

            var shapeMinTask = this.statsStore.GetAsync(SkyIslandMapStat.ShapePercentWeightMin);
            var shapeMaxTask = this.statsStore.GetAsync(SkyIslandMapStat.ShapePercentWeightMax);

            var baselineMinTask = this.statsStore.GetAsync(SkyIslandMapStat.BaselineHeightMin);
            var baselineMaxTask = this.statsStore.GetAsync(SkyIslandMapStat.BaselineHeightMax);

            var mountainMinTask = this.statsStore.GetAsync(SkyIslandMapStat.MountainHeightMultiplierMin);
            var mountainMaxTask = this.statsStore.GetAsync(SkyIslandMapStat.MountainHeightMultiplierMax);

            var topMinTask = this.statsStore.GetAsync(SkyIslandMapStat.TopHeightMin);
            var topMaxTask = this.statsStore.GetAsync(SkyIslandMapStat.TopHeightMax);

            var bottomMinTask = this.statsStore.GetAsync(SkyIslandMapStat.BottomHeightMin);
            var bottomMaxTask = this.statsStore.GetAsync(SkyIslandMapStat.BottomHeightMax);

            await Task.WhenAll(
                shapeMinTask,
                shapeMaxTask,
                baselineMinTask,
                baselineMaxTask,
                mountainMinTask,
                mountainMaxTask,
                topMinTask,
                topMaxTask,
                bottomMinTask,
                bottomMaxTask).DontMarshallContext();

            this.min = new SkyIslandMaps(
                shapePercentWeight: shapeMinTask.Result,
                baselineHeight: baselineMinTask.Result,
                mountainHeightMultiplier: mountainMinTask.Result,
                topHeight: topMinTask.Result,
                bottomHeight: bottomMinTask.Result);

            this.max = new SkyIslandMaps(
                shapePercentWeight: shapeMaxTask.Result,
                baselineHeight: baselineMaxTask.Result,
                mountainHeightMultiplier: mountainMaxTask.Result,
                topHeight: topMaxTask.Result,
                bottomHeight: bottomMaxTask.Result);
        }
Exemplo n.º 4
0
        public void Update(SkyIslandMaps value)
        {
            this.shapePercentWeightMin =
                Math.Min(value.ShapePercentWeight, this.shapePercentWeightMin);
            this.baselineHeightMin =
                Math.Min(value.BaselineHeight, this.baselineHeightMin);
            this.mountainHeightMultiplierMin =
                Math.Min(value.MountainHeightMultiplier, this.mountainHeightMultiplierMin);
            this.topHeightMin =
                Math.Min(value.TopHeight, this.topHeightMin);
            this.bottomHeightMin =
                Math.Min(value.BottomHeight, this.bottomHeightMin);

            this.shapePercentWeightMax =
                Math.Max(value.ShapePercentWeight, this.shapePercentWeightMax);
            this.baselineHeightMax =
                Math.Max(value.BaselineHeight, this.baselineHeightMax);
            this.mountainHeightMultiplierMax =
                Math.Max(value.MountainHeightMultiplier, this.mountainHeightMultiplierMax);
            this.topHeightMax =
                Math.Max(value.TopHeight, this.topHeightMax);
            this.bottomHeightMax =
                Math.Max(value.BottomHeight, this.bottomHeightMax);
        }
Exemplo n.º 5
0
 public ExteriorSkyIslandMapChunkPopulator(SkyIslandMaps outOfBoundsValue)
 {
     this.outOfBoundsValue = outOfBoundsValue;
 }
        private void GenerateValues(
            IReadOnlySkyIslandMapChunk mapChunk, Index3D min, Index3D max, IVoxelGridChunk chunk)
        {
            Contracts.Requires.That(mapChunk != null);
            Contracts.Requires.That(chunk != null);

            for (int iX = min.X; iX <= max.X; iX++)
            {
                for (int iZ = min.Z; iZ <= max.Z; iZ++)
                {
                    SkyIslandMaps map = mapChunk.MapsStageView[new Index2D(iX, iZ)];

                    if (map.ShapePercentWeight > 0)
                    {
                        // column is inside the floating island
                        for (int iY = min.Y; iY <= max.Y; iY++)
                        {
                            chunk.VoxelsStageView[new Index3D(iX, iY, iZ)] =
                                this.GetVoxelFromColumnInsideIsland(iX, iY, iZ, map.TopHeight, map.BottomHeight);
                        }
                    }
                    else
                    {
                        // column is outside of the floating island
                        double edgeSeamDropoffScale =
                            this.config.EdgeSeamDropoffScaleDistorter.Noise(this.environmentNoise, iX, iZ);
                        double weightedDistanceFromIsland =
                            ((map.ShapePercentWeight * edgeSeamDropoffScale) + 1).ClampLower(0);

                        if (weightedDistanceFromIsland > 0)
                        {
                            // column is close to edge of island so perform island edge seaming
                            double weightedAboveTopGradientThickness =
                                this.config.AboveTopGradientThickness * weightedDistanceFromIsland;
                            double weightedBelowBottomGradientThickness =
                                this.config.BelowBottomGradientThickness * weightedDistanceFromIsland;

                            for (int iY = min.Y; iY <= max.Y; iY++)
                            {
                                var voxel = this.GetVoxelFromColumnOutsideIsland(
                                    iX,
                                    iY,
                                    iZ,
                                    weightedAboveTopGradientThickness,
                                    weightedBelowBottomGradientThickness,
                                    map.BaselineHeight,
                                    map.TopHeight);

                                chunk.VoxelsStageView[new Index3D(iX, iY, iZ)] = voxel;
                            }
                        }
                        else
                        {
                            // column is far enough away from edge of island to be just empty air
                            for (int iY = min.Y; iY <= max.Y; iY++)
                            {
                                chunk.VoxelsStageView[new Index3D(iX, iY, iZ)] = this.config.EmptyAir;
                            }
                        }
                    }
                }
            }
        }