Пример #1
0
        public void AddGrassToTop(RegionController ownerWorld, Vector3i origin)
        {
            Vector3i currentPosition;
            Block    currentBlock;

            bool recentAir;

            recentAir = false;
            for (int x = 0; x < generatorSettings.RegionSize.X; x++)
            {
                for (int z = 0; z < generatorSettings.RegionSize.Z; z++)
                {
                    for (int y = generatorSettings.RegionSize.Y - 1; y > 0; y--)
                    {
                        currentPosition = origin + new Vector3i(x, y, z);

                        currentBlock = ownerWorld.GetBlock(currentPosition);

                        if (currentBlock.Type != BlockType.Air && recentAir)
                        {
                            ownerWorld.ChangeBlock(currentPosition, BlockType.Grass);
                            recentAir = false;
                        }
                        else if (currentBlock.Type == BlockType.Air)
                        {
                            recentAir = true;
                        }
                    }
                }
            }
        }
Пример #2
0
        public void FastGenerateRegion3D(RegionController ownerWorld, Vector3i origin)
        {
            noiseSettings3D.startingPoint = origin;

            fastNoise3D.FillWithPerlinNoise3D(flatNoise);
            PlaceBlocks(ownerWorld, origin, flatNoise);

            AddGrassToTop(ownerWorld, origin);
        }
Пример #3
0
        public void FakeGenerator(RegionController ownerWorld, Vector3i origin)
        {
            float     density;
            BlockType blockType;

            for (int x = 0; x < generatorSettings.RegionSize.X; x++)
            {
                for (int y = 0; y < generatorSettings.RegionSize.Y - 1; y++)
                {
                    for (int z = 0; z < generatorSettings.RegionSize.Z; z++)
                    {
                        density   = 0;
                        blockType = GetBlockFromNoise(density, y);
                        if (blockType != BlockType.Air)
                        {
                            ownerWorld.ChangeBlock(origin + new Vector3i(x, y, z), blockType);
                        }
                    }
                }
            }
        }
Пример #4
0
        public bool CreateRegion(RegionController updater, Vector3i regionCoordiants)
        {
            if (!regionMap.Keys.Contains(regionCoordiants))
            {
                Vector3i newOrigin = new Vector3i(regionCoordiants.X * regionSize.X,
                                                  regionCoordiants.Y * regionSize.Y,
                                                  regionCoordiants.Z * regionSize.Z);

                Region newRegion = GetNewRegion(newOrigin, regionSize);
                regionMap.Add(regionCoordiants, newRegion);
                generator.FastGenerateRegion3D(updater, newOrigin);

                RegionCreatedData creationData = new RegionCreatedData(newRegion);

                GlobalSystems.EventManager.SendEvent(new RegionCreatedEvent(new Optional <object>(this),
                                                                            0,
                                                                            creationData));

                return(true);
            }

            return(false);
        }
Пример #5
0
        private void PlaceBlocks(RegionController ownerWorld, Vector3i origin, float[] noise)
        {
            float     density;
            BlockType blockType;

            for (int x = 0; x < generatorSettings.RegionSize.X; x++)
            {
                for (int y = 0; y < generatorSettings.RegionSize.Y - 1; y++)
                {
                    for (int z = 0; z < generatorSettings.RegionSize.Z; z++)
                    {
                        density = noise[x * generatorSettings.RegionSize.Y * generatorSettings.RegionSize.Z +
                                        y * generatorSettings.RegionSize.Z +
                                        z];

                        blockType = GetBlockFromNoise(density, y);
                        if (blockType != BlockType.Air)
                        {
                            ownerWorld.ChangeBlock(origin + new Vector3i(x, y, z), blockType);
                        }
                    }
                }
            }
        }