コード例 #1
0
        // Humus thickness thresholds
        // Below 0.2 = low fertility
        // Below 0.6 = medium fertility
        // Otherwise = hight fertiltiy

        // e.g. 1.2 humus thickness
        // => top block is high fertility soil
        // below is low fertility soil



        // Returns 3 values:
        // float[0]: 0 = low fertility, 1 = medium fertility, 2 = high fertility
        // float[1]: thickness
        public static float[] GetSoilFertility(RockStrataVariant rock, int forest, int climate, int yPos, int worldHeight)
        {
            float SoilpH = rock.SoilpH - 0.8f * forest / 255;
            float NonOrganicMaterialThickness = rock.WeatheringFactor * ((climate & 0xff + ((climate >> 8) & 0xff) + ((climate >> 16) & 0xff))) / 256;
            float RelativeSeaLevelDistance    = (yPos - TerraGenConfig.seaLevel) / (float)worldHeight;

            NonOrganicMaterialThickness *= Math.Max(0.2f, 1 - RelativeSeaLevelDistance);

            float HumusThickness = 3 * (SoilpH < 6.5f ? Math.Max(0, SoilpH / 2.5f - 1.6f) : Math.Max(0, 5.33f - SoilpH / 1.5f));

            HumusThickness *= Math.Max(0.2f, 1 - RelativeSeaLevelDistance);

            return(new float[] {
                HumusThickness + 1
            });

            /*
             * float RockpH = 6.5f;
             * float RockWeatheringFactor = 1;
             *
             * float SoilpH = RockpH - 0.8f*forestMap[z * chunksize + x]/255;
             * float NonOrganicMaterialThickness = RockWeatheringFactor*((climate & 0xff + ((climate >> 8) & 0xff) + ((climate >> 16) & 0xff)))/256;
             * float RelativeSeaLevelDistance = (yPos - TerraGenConfig.seaLevel) / (float)worldHeight;
             *
             * NonOrganicMaterialThickness *= Math.Max(0.2f, 1 - RelativeSeaLevelDistance);
             *
             * float HumusThickness = 3 * (SoilpH < 6.5f ? Math.Max(0, SoilpH / 2.5f - 1.6f) : Math.Max(0, 5.33f - SoilpH / 1.5f));
             * HumusThickness *= Math.Max(0.2f, 1 - RelativeSeaLevelDistance);
             */
        }
コード例 #2
0
        public override void StartServerSide(ICoreServerAPI api)
        {
            this.api = api;

            this.api.Event.ChunkColumnGeneration(this.OnChunkColumnGeneration, EnumWorldGenPass.Terrain);
            this.api.Event.SaveGameLoaded += this.GameWorldLoaded;

            // Call our loaded method manually if the server is already running (happens when mods are reloaded at runtime)
            if (this.api.Server.CurrentRunPhase == EnumServerRunPhase.RunGame)
            {
                GameWorldLoaded();
            }

            dummyRock = new RockStrataVariant()
            {
                SoilpH = 6.5f, WeatheringFactor = 1f
            };
        }
コード例 #3
0
        public override void StartServerSide(ICoreServerAPI api)
        {
            this.api = api;

            if (DoDecorationPass)
            {
                this.api.Event.InitWorldGenerator(InitWorldGen, "standard");
                this.api.Event.InitWorldGenerator(InitWorldGen, "superflat"); // Just the Init so that BlockSoil can grow grass
                this.api.Event.MapRegionGeneration(OnMapRegionGen, "standard");
                this.api.Event.ChunkColumnGeneration(this.OnChunkColumnGeneration, EnumWorldGenPass.Terrain, "standard");
            }

            dummyRock = new RockStrataVariant()
            {
                SoilpH = 6.5f, WeatheringFactor = 1f
            };

            distort2dx = new SimplexNoise(new double[] { 14, 9, 6, 3 }, new double[] { 1 / 100.0, 1 / 50.0, 1 / 25.0, 1 / 12.5 }, api.World.SeaLevel + 20980);
            distort2dz = new SimplexNoise(new double[] { 14, 9, 6, 3 }, new double[] { 1 / 100.0, 1 / 50.0, 1 / 25.0, 1 / 12.5 }, api.World.SeaLevel + 20981);
        }
コード例 #4
0
        public static float SoilThickness(float rainRel, float temp, int distToSealevel, RockStrataVariant rock)
        {
            float f = 5f * rock.WeatheringFactor; //(5f * rain * temp) / (255f * 255f) * rock.WeatheringFactor;

            float weight = 1 - Math.Max(0, (4 - f) / 4);

            return
                (f - distToSealevel / 35 * weight
                 - Math.Min(0, (30 - temp) / 6)
                );
        }