コード例 #1
0
        public MapLayerWobbledForest(long seed, int octaves, float persistence, float scale, float multiplier = 255, int offset = 0) : base(seed)
        {
            //noisegen = NormalizedPerlinNoise.FromDefaultOctaves(octaves, 1 / scale, persistence, seed);

            double[] frequencies = new double[3];
            double[] amplitudes  = new double[3];

            for (int i = 0; i < octaves; i++)
            {
                frequencies[i] = Math.Pow(3, i) * 1 / scale;
                amplitudes[i]  = Math.Pow(persistence, i);
            }

            noisegen = new NormalizedSimplexNoise(amplitudes, frequencies, seed);

            this.offset     = offset;
            this.multiplier = multiplier;

            int   woctaves     = 3;
            float wscale       = 128;
            float wpersistence = 0.9f;

            wobbleIntensity = scale / 3f;
            noisegenX       = NormalizedSimplexNoise.FromDefaultOctaves(woctaves, 1 / wscale, wpersistence, seed + 2);
            noisegenY       = NormalizedSimplexNoise.FromDefaultOctaves(woctaves, 1 / wscale, wpersistence, seed + 1231296);
        }
コード例 #2
0
 public void InitWorldGen()
 {
     LoadGlobalConfig(Api);
     sNoise   = NormalizedSimplexNoise.FromDefaultOctaves(2, 4.0, 1.0, Api.WorldManager.Seed + 1492);
     Deposits = Api.ModLoader.GetModSystem <GenDeposits>().Deposits;
     rand     = new LCGRandom(Api.WorldManager.Seed + 1546);
 }
コード例 #3
0
        public void initWorldGen()
        {
            LoadGlobalConfig(api);
            LandformMapByRegion.Clear();

            chunksize = api.WorldManager.ChunkSize;

            // Amount of landform regions in all of the map
            // Until v1.12.9 this calculation was incorrect
            if (GameVersion.IsAtLeastVersion(api.WorldManager.SaveGame.CreatedGameVersion, "1.12.9"))
            {
                regionMapSize = (int)Math.Ceiling((double)api.WorldManager.MapSizeX / api.WorldManager.RegionSize);
            }
            else
            {
                regionMapSize = api.WorldManager.MapSizeX / api.WorldManager.RegionSize;
            }


            // Starting from v1.11 the world height also horizontally scales the world
            horizontalScale = 1f;
            if (GameVersion.IsAtLeastVersion(api.WorldManager.SaveGame.CreatedGameVersion, "1.11.0-dev.1"))
            {
                horizontalScale = Math.Max(1, api.WorldManager.MapSizeY / 256f);
            }
            TerrainNoise = NormalizedSimplexNoise.FromDefaultOctaves(
                TerraGenConfig.terrainGenOctaves, 0.002 / horizontalScale, 0.9, api.WorldManager.Seed
                );

            // We generate the whole terrain here so we instantly know the heightmap
            lerpHor = TerraGenConfig.lerpHorizontal;
            lerpVer = TerraGenConfig.lerpVertical;


            noiseWidth  = chunksize / lerpHor;
            noiseHeight = api.WorldManager.MapSizeY / lerpVer;

            paddedNoiseWidth  = noiseWidth + 1;
            paddedNoiseHeight = noiseHeight + 1;

            lerpDeltaHor  = 1f / lerpHor;
            lerpDeltaVert = 1f / lerpVer;

            noiseTemp = new double[paddedNoiseWidth * paddedNoiseWidth * paddedNoiseHeight];

            TerraGenConfig.seaLevel = (int)(0.4313725490196078 * api.WorldManager.MapSizeY);
            api.WorldManager.SetSeaLevel(TerraGenConfig.seaLevel);

            if (GameVersion.IsAtLeastVersion(api.WorldManager.SaveGame.CreatedGameVersion, "1.12.0-dev.1"))
            {
                distort2dx = new SimplexNoise(new double[] { 55, 40, 30, 10 }, new double[] { 1 / 500.0, 1 / 250.0, 1 / 125.0, 1 / 65 }, api.World.Seed + 9876 + 0);
                distort2dz = new SimplexNoise(new double[] { 55, 40, 30, 10 }, new double[] { 1 / 500.0, 1 / 250.0, 1 / 125.0, 1 / 65 }, api.World.Seed + 9877 + 0);
            }
            else
            {
                // Whoops, looks like we made a typo here. Old code stays so we don't break worldgen on old worlds
                distort2dx = new SimplexNoise(new double[] { 55, 40, 30, 10 }, new double[] { 1 / 500.0, 1 / 250.0, 1 / 125.0, 1 / 65 }, api.World.SeaLevel + 9876 + 0);
                distort2dz = new SimplexNoise(new double[] { 55, 40, 30, 10 }, new double[] { 1 / 500.0, 1 / 250.0, 1 / 125.0, 1 / 65 }, api.World.SeaLevel + 9877 + 0);
            }
        }
コード例 #4
0
 public override void initWorldGen()
 {
     base.initWorldGen();
     caveRand       = new LCGRandom(api.WorldManager.Seed + 123128);
     basaltNoise    = NormalizedSimplexNoise.FromDefaultOctaves(2, 1f / 3.5f, 0.9f, api.World.Seed + 12);
     heightvarNoise = NormalizedSimplexNoise.FromDefaultOctaves(3, 1f / 20f, 0.9f, api.World.Seed + 12);
 }
コード例 #5
0
        public void initWorldGen()
        {
            //dominionsmod
            saltWater = api.World.GetBlock(new AssetLocation("saltwater-still-7")).Id;

            LoadGlobalConfig(api);
            LandformMapByRegion.Clear();

            chunksize = api.WorldManager.ChunkSize;

            // Unpadded region noise size in chunks
            regionChunkSize = api.WorldManager.RegionSize / chunksize;
            // Amount of landform regions in all of the map
            regionMapSize = api.WorldManager.MapSizeX / api.WorldManager.RegionSize;



            horizontalScale = 1f;
            if (GameVersion.IsAtLeastVersion(api.WorldManager.SaveGame.CreatedGameVersion, "1.11.0-dev.1"))
            {
                horizontalScale = Math.Max(1, api.WorldManager.MapSizeY / 256f);
            }
            TerrainNoise = NormalizedSimplexNoise.FromDefaultOctaves(
                TerraGenConfig.terrainGenOctaves, 0.002 / horizontalScale, 0.9, api.WorldManager.Seed
                );

            // We generate the whole terrain here so we instantly know the heightmap
            lerpHor = TerraGenConfig.lerpHorizontal;
            lerpVer = TerraGenConfig.lerpVertical;


            noiseWidth  = chunksize / lerpHor;
            noiseHeight = api.WorldManager.MapSizeY / lerpVer;

            paddedNoiseWidth  = noiseWidth + 1;
            paddedNoiseHeight = noiseHeight + 1;

            lerpDeltaHor  = 1f / lerpHor;
            lerpDeltaVert = 1f / lerpVer;

            //rockstrataGen.initWorldGen();

            noiseTemp = new double[paddedNoiseWidth * paddedNoiseWidth * paddedNoiseHeight];

            TerraGenConfig.seaLevel = (int)(0.4313725490196078 * api.WorldManager.MapSizeY);
            api.WorldManager.SetSealLevel(TerraGenConfig.seaLevel);

            if (GameVersion.IsAtLeastVersion(api.WorldManager.SaveGame.CreatedGameVersion, "1.12.0-dev.1"))
            {
                distort2dx = new SimplexNoise(new double[] { 55, 40, 30, 10 }, new double[] { 1 / 500.0, 1 / 250.0, 1 / 125.0, 1 / 65 }, api.World.Seed + 9876 + 0);
                distort2dz = new SimplexNoise(new double[] { 55, 40, 30, 10 }, new double[] { 1 / 500.0, 1 / 250.0, 1 / 125.0, 1 / 65 }, api.World.Seed + 9877 + 0);
            }
            else
            {
                // Whoops, looks like we made a typo here. Old code stays so    we don't break worldgen on old worlds
                distort2dx = new SimplexNoise(new double[] { 55, 40, 30, 10 }, new double[] { 1 / 500.0, 1 / 250.0, 1 / 125.0, 1 / 65 }, api.World.SeaLevel + 9876 + 0);
                distort2dz = new SimplexNoise(new double[] { 55, 40, 30, 10 }, new double[] { 1 / 500.0, 1 / 250.0, 1 / 125.0, 1 / 65 }, api.World.SeaLevel + 9877 + 0);
            }
        }
コード例 #6
0
        public MapLayerPerlinWobble(long seed, MapLayerBase parent, int octaves, float persistence, float scale, float intensity = 1) : base(seed, parent)
        {
            noisegenX = NormalizedSimplexNoise.FromDefaultOctaves(octaves, 1 / scale, persistence, seed);
            noisegenY = NormalizedSimplexNoise.FromDefaultOctaves(octaves, 1 / scale, persistence, seed + 1231296);

            this.scale     = scale;
            this.intensity = intensity;
        }
コード例 #7
0
        public DepositGeneratorBase(ICoreServerAPI api, DepositVariant variant, LCGRandom depositRand, NormalizedSimplexNoise noiseGen)
        {
            this.variant         = variant;
            this.Api             = api;
            this.DepositRand     = depositRand;
            this.DistortNoiseGen = noiseGen;

            rand = new Random(api.World.Seed);
        }
コード例 #8
0
        public void Initialize()
        {
            windNoise = NormalizedSimplexNoise.FromDefaultOctaves(6, 0.1, 0.8, api.World.Seed + 2323182);

            weatherPatternNoise = NormalizedSimplexNoise.FromDefaultOctaves(6, 0.1, 0.8, api.World.Seed + 9867910);

            dummySim         = new WeatherSimulationRegion(this, 0, 0);
            dummySim.IsDummy = true;
        }
コード例 #9
0
        public override void initWorldGen()
        {
            base.initWorldGen();

            saltWater = api.World.GetBlock(new AssetLocation("saltwater-still-7")).Id;

            caveRand       = new LCGRandom(api.WorldManager.Seed + 123128);
            basaltNoise    = NormalizedSimplexNoise.FromDefaultOctaves(2, 1f / 3.5f, 0.9f, api.World.Seed + 12);
            heightvarNoise = NormalizedSimplexNoise.FromDefaultOctaves(3, 1f / 20f, 0.9f, api.World.Seed + 12);
        }
コード例 #10
0
        public void OnGameWorldLoaded()
        {
            LoadGlobalConfig(api);

            chunksize  = api.WorldManager.ChunkSize;
            regionSize = api.WorldManager.RegionSize;
            chunkRatio = (float)chunksize / regionSize;

            // Unpadded region noise size in blocks
            regionNoiseSize = regionSize / TerraGenConfig.geoProvMapScale;

            // Unpadded region noise size in chunks
            regionChunkSize = regionSize / chunksize;

            // Amount of regions in all of the map (actually the square of that - regionMapSize*regionMapSize)
            regionMapSize = api.WorldManager.MapSizeX / (chunksize * regionNoiseSize);


            rand = new Random(api.WorldManager.Seed);

            noiseGen   = NormalizedSimplexNoise.FromDefaultOctaves(1, 0.0005, 1, api.WorldManager.Seed);
            distort2dX = new NormalizedSimplexNoise(new double[] { 0.9, 0.5 }, new double[] { 0.01 / 3, 0.05 / 3 }, api.WorldManager.Seed + 7123);
            distort2dZ = new NormalizedSimplexNoise(new double[] { 0.9, 0.5 }, new double[] { 0.01 / 3, 0.05 / 3 }, api.WorldManager.Seed + 7123);

            Random rnd = new Random(api.WorldManager.Seed);
            Dictionary <EnumRockGroup, List <RockStrataVariant> > variantsByRockGroup = new Dictionary <EnumRockGroup, List <RockStrataVariant> >();
            var values = Enum.GetValues(typeof(EnumRockGroup));

            foreach (EnumRockGroup rockgroup in values)
            {
                variantsByRockGroup[rockgroup] = new List <RockStrataVariant>();
            }
            foreach (RockStrataVariant variant in rockstrata.Variants)
            {
                variantsByRockGroup[variant.RockGroup].Add(variant);
            }

            foreach (GeologicProvinceVariant variant in provinces.Variants)
            {
                variant.InitRockStrataGen(api, rnd, variantsByRockGroup);
            }

            rockBlockId = (ushort)api.WorldManager.GetBlockId(new AssetLocation("rock-granite"));
            worldHeight = api.WorldManager.MapSizeY;

            layerBlockIds = new ushort[][]
            {
                new ushort[worldHeight],
                new ushort[worldHeight],
                new ushort[worldHeight],
                new ushort[worldHeight]
            };

            finalBlockIds = new List <ushort>(api.WorldManager.MapSizeY);
        }
コード例 #11
0
        private void TestNoise(IServerPlayer player, CmdArgs arguments)
        {
            bool use3d   = false;
            int  octaves = 1;

            if (arguments.Length > 1)
            {
                if (!int.TryParse(arguments[1], out octaves))
                {
                    octaves = 1;
                }
            }


            Random rnd  = new Random();
            long   seed = rnd.Next();

            NormalizedSimplexNoise noise = NormalizedSimplexNoise.FromDefaultOctaves(octaves, 5, 0.7, seed);
            int    size = 800;
            Bitmap bmp  = new Bitmap(size, size);

            int   underflows = 0;
            int   overflows  = 0;
            float min        = 1;
            float max        = 0;

            for (int x = 0; x < size; x++)
            {
                for (int y = 0; y < size; y++)
                {
                    double value = use3d ? noise.Noise((double)x / size, 0, (double)y / size) : noise.Noise((double)x / size, (double)y / size);
                    if (value < 0)
                    {
                        underflows++;
                        value = 0;
                    }
                    if (value > 1)
                    {
                        overflows++;
                        value = 1;
                    }

                    min = Math.Min((float)value, min);
                    max = Math.Max((float)value, max);

                    int light = (int)(value * 255);
                    bmp.SetPixel(x, y, Color.FromArgb(255, light, light, light));
                }
            }

            bmp.Save("noise.png");
            player.SendMessage(groupId, (use3d ? "3D" : "2D") + " Noise (" + octaves + " Octaves) saved to noise.png. Overflows: " + overflows + ", Underflows: " + underflows, EnumChatType.CommandSuccess);
            player.SendMessage(groupId, "Noise min = " + min.ToString("0.##") + ", max= " + max.ToString("0.##"), EnumChatType.CommandSuccess);
        }
コード例 #12
0
        public MapLayerGeoProvince(long seed, ICoreServerAPI api) : base(seed)
        {
            noiseGeoProvince = new NoiseGeoProvince(seed, api);

            int   woctaves     = 4;
            float wscale       = 1.5f * TerraGenConfig.geoProvMapScale;
            float wpersistence = 0.9f;

            wobbleIntensity = TerraGenConfig.geoProvMapScale * 1.5f;
            noisegenX       = NormalizedSimplexNoise.FromDefaultOctaves(woctaves, 0.4f / wscale, wpersistence, seed + 2);
            noisegenY       = NormalizedSimplexNoise.FromDefaultOctaves(woctaves, 0.4f / wscale, wpersistence, seed + 1231296);
        }
コード例 #13
0
        public WeatherPatternSimulation(int worldSeed, IWorldAccessor world)
        {
            this.worldSeed = worldSeed;
            this.world     = world;

            chunksize = world.BlockAccessor.ChunkSize;

            //NoiseGens = new NormalizedPerlinNoise[Enum.GetValues(typeof(EnumWeatherPattern)).Length];
            for (int i = 0; i < NoiseGens.Length; i++)
            {
                NoiseGens[i] = NormalizedSimplexNoise.FromDefaultOctaves(3, 0.1, 0.8, worldSeed + i + 1231212);
            }
        }
コード例 #14
0
        public void Init(ICoreAPI api, ClothManager cm)
        {
            this.api  = api;
            this.capi = api as ICoreClientAPI;
            pp        = cm.partPhysics;

            noiseGen = NormalizedSimplexNoise.FromDefaultOctaves(4, 100, 0.9, api.World.Seed + CenterPosition.GetHashCode());

            if (capi != null && LineDebug)
            {
                debugUpdateMesh = new MeshData(20, 15, false, false, true, true);
            }
        }
コード例 #15
0
        public MapLayerLandforms(long seed, NoiseClimate climateNoise, ICoreServerAPI api) : base(seed)
        {
            this.climateNoise = climateNoise;
            noiseLandforms    = new NoiseLandforms(seed, api);

            int   woctaves     = 2;
            float wscale       = 2f * TerraGenConfig.landformMapScale;
            float wpersistence = 0.9f;

            wobbleIntensity = TerraGenConfig.landformMapScale * 1.5f;
            noisegenX       = NormalizedSimplexNoise.FromDefaultOctaves(woctaves, 1 / wscale, wpersistence, seed + 2);
            noisegenY       = NormalizedSimplexNoise.FromDefaultOctaves(woctaves, 1 / wscale, wpersistence, seed + 1231296);
        }
コード例 #16
0
        public void initWorldGen()
        {
            LoadGlobalConfig(api);
            LandformMapByRegion.Clear();

            chunksize = api.WorldManager.ChunkSize;
            // Unpadded region noise size in blocks
            int landFormRegionNoiseSize = api.WorldManager.RegionSize / TerraGenConfig.landformMapScale;

            // Unpadded region noise size in chunks
            regionChunkSize = api.WorldManager.RegionSize / chunksize;
            // Amount of landform regions in all of the map
            regionMapSize = api.WorldManager.MapSizeX / api.WorldManager.RegionSize;


            TerrainNoise = NormalizedSimplexNoise.FromDefaultOctaves(
                TerraGenConfig.terrainGenOctaves, 0.002, 0.9, api.WorldManager.Seed
                );

            // We generate the whole terrain here so we instantly know the heightmap
            lerpHor = TerraGenConfig.lerpHorizontal;
            lerpVer = TerraGenConfig.lerpVertical;

            noiseWidth  = chunksize / lerpHor;
            noiseHeight = api.WorldManager.MapSizeY / lerpVer;

            paddedNoiseWidth  = noiseWidth + 1;
            paddedNoiseHeight = noiseHeight + 1;

            lerpDeltaHor  = 1f / lerpHor;
            lerpDeltaVert = 1f / lerpVer;

            //rockstrataGen.initWorldGen();

            noiseTemp = new double[paddedNoiseWidth * paddedNoiseWidth * paddedNoiseHeight];

            TerraGenConfig.seaLevel = (int)(0.4313725490196078 * api.WorldManager.MapSizeY);
            api.WorldManager.SetSealLevel(TerraGenConfig.seaLevel);

            distort2dx = new SimplexNoise(new double[] { 55, 40, 30, 10 }, new double[] { 1 / 500.0, 1 / 250.0, 1 / 125.0, 1 / 65 }, api.World.SeaLevel + 9876 + 0);
            distort2dz = new SimplexNoise(new double[] { 55, 40, 30, 10 }, new double[] { 1 / 500.0, 1 / 250.0, 1 / 125.0, 1 / 65 }, api.World.SeaLevel + 9877 + 0);
        }
コード例 #17
0
ファイル: GenTerra.cs プロジェクト: bitcynth/vssurvivalmod
        public void GameWorldLoaded()
        {
            LoadGlobalConfig(api);
            LandformMapByRegion.Clear();

            chunksize = api.WorldManager.ChunkSize;
            // Unpadded region noise size in blocks
            int landFormRegionNoiseSize = api.WorldManager.RegionSize / TerraGenConfig.landformMapScale;

            // Unpadded region noise size in chunks
            regionChunkSize = api.WorldManager.RegionSize / chunksize;
            // Amount of landform regions in all of the map
            regionMapSize = api.WorldManager.MapSizeX / api.WorldManager.RegionSize;


            TerrainNoise = NormalizedSimplexNoise.FromDefaultOctaves(
                TerraGenConfig.terrainGenOctaves, 0.001, 0.9, api.WorldManager.Seed
                );

            // We generate the whole terrain here so we instantly know the heightmap
            lerpHor = TerraGenConfig.lerpHorizontal;
            lerpVer = TerraGenConfig.lerpVertical;

            noiseWidth  = chunksize / lerpHor;
            noiseHeight = api.WorldManager.MapSizeY / lerpVer;

            paddedNoiseWidth  = noiseWidth + 1;
            paddedNoiseHeight = noiseHeight + 1;

            lerpDeltaHor  = 1f / lerpHor;
            lerpDeltaVert = 1f / lerpVer;

            rockstrataGen.OnGameWorldLoaded();

            noiseTemp = new double[paddedNoiseWidth * paddedNoiseWidth * paddedNoiseHeight];

            if (api.WorldManager.SaveGame.WorldPlayStyle != EnumPlayStyle.CreativeBuilding)
            {
                TerraGenConfig.seaLevel = (int)(0.4313725490196078 * api.WorldManager.MapSizeY);
                api.WorldManager.SetSealLevel(TerraGenConfig.seaLevel);
            }
        }
コード例 #18
0
        public MapLayerLandforms(long seed, NoiseClimate climateNoise, ICoreServerAPI api) : base(seed)
        {
            this.climateNoise = climateNoise;

            float scale = TerraGenConfig.landformMapScale;

            if (GameVersion.IsAtLeastVersion(api.WorldManager.SaveGame.CreatedGameVersion, "1.11.0-dev.1"))
            {
                scale *= Math.Max(1, api.WorldManager.MapSizeY / 256f);
            }

            noiseLandforms = new NoiseLandforms(seed, api, scale);

            int   woctaves     = 2;
            float wscale       = 2f * TerraGenConfig.landformMapScale;
            float wpersistence = 0.9f;

            wobbleIntensity = TerraGenConfig.landformMapScale * 1.5f;
            noisegenX       = NormalizedSimplexNoise.FromDefaultOctaves(woctaves, 1 / wscale, wpersistence, seed + 2);
            noisegenY       = NormalizedSimplexNoise.FromDefaultOctaves(woctaves, 1 / wscale, wpersistence, seed + 1231296);
        }
コード例 #19
0
        public void SetupPalm(Block palmBase)
        {
            bottomOffsets   = AreaMethods.AreaBelowOffsetList().ToArray();
            offsets         = AreaMethods.AreaAroundOffsetList().ToArray();
            cardinaloffsets = AreaMethods.CardinalOffsetList().ToArray();
            sNoise          = NormalizedSimplexNoise.FromDefaultOctaves(16, 8.0, 0.5, api.WorldManager.Seed + 6514);
            sizeNoise       = NormalizedSimplexNoise.FromDefaultOctaves(4, 2.0, 1.0, api.WorldManager.Seed + 2361);
            frondNoise      = NormalizedSimplexNoise.FromDefaultOctaves(4, 2.0, 1.0, api.WorldManager.Seed + 6151);
            fruitNoise      = NormalizedSimplexNoise.FromDefaultOctaves(4, 2.0, 1.0, api.WorldManager.Seed + 4987);

            List <int> trunkblocks = new List <int>();
            List <int> frondblocks = new List <int>();

            List <int> bananablocks  = new List <int>();
            List <int> coconutblocks = new List <int>();

            for (int i = 0; i < parts.Length; i++)
            {
                trunkblocks.Add(api.World.BlockAccessor.GetBlock(palmBase.CodeWithPart(parts[i], 1)).Id);
            }
            trunk = trunkblocks.ToArray();

            for (int i = 0; i < directions.Length; i++)
            {
                frondblocks.Add(api.World.BlockAccessor.GetBlock(new AssetLocation("immersion:palmfrond-1-grown-" + directions[i])).Id);
                bananablocks.Add(api.World.BlockAccessor.GetBlock(new AssetLocation("immersion:palmfruits-bananna-" + directions[i])).Id);
                coconutblocks.Add(api.World.BlockAccessor.GetBlock(new AssetLocation("immersion:palmfruits-coconut-" + directions[i])).Id);
            }
            frond  = frondblocks.ToArray();
            fruits = new int[][] { bananablocks.ToArray(), coconutblocks.ToArray(), null };

            tip = api.World.BlockAccessor.GetBlock(palmBase.CodeWithPart("tip", 1)).Id;
            int c = api.World.BlockAccessor.GetBlock(new AssetLocation("game:sapling-palmcoconut")).Id;
            int b = api.World.BlockAccessor.GetBlock(new AssetLocation("game:sapling-palmbanana")).Id;
            int p = api.World.BlockAccessor.GetBlock(new AssetLocation("game:sapling-palm")).Id;

            saplings = new int[] { c, b, p };
        }
コード例 #20
0
        public void Init(ICoreServerAPI api, LCGRandom depositRand, NormalizedSimplexNoise noiseGen)
        {
            this.api = api;
            InitWithoutGenerator(api);

            if (Generator == null)
            {
                api.World.Logger.Error("Error in deposit variant in file {0}: No generator defined! Must define a generator.", fromFile, Generator);
            }
            else
            {
                GeneratorInst = DepositGeneratorRegistry.CreateGenerator(Generator, Attributes, api, this, depositRand, noiseGen);
                if (GeneratorInst == null)
                {
                    api.World.Logger.Error("Error in deposit variant in file {0}: No generator with code '{1}' found!", fromFile, Generator);
                }
            }

            if (Code == null)
            {
                api.World.Logger.Error("Error in deposit variant in file {0}: Deposit has no code! Defaulting to 'unknown'", fromFile);
                Code = "unknown";
            }
        }
コード例 #21
0
        public void initWorldGen(bool blockCallbacks)
        {
            base.initWorldGen();

            chanceMultiplier = api.Assets.Get("worldgen/deposits.json").ToObject <Deposits>().ChanceMultiplier;

            Dictionary <AssetLocation, DepositVariant[]> depositFiles = api.Assets.GetMany <DepositVariant[]>(api.World.Logger, "worldgen/deposits/");
            List <DepositVariant> variants = new List <DepositVariant>();


            foreach (var val in depositFiles)
            {
                foreach (var depo in val.Value)
                {
                    depo.fromFile           = val.Key.ToString();
                    depo.WithBlockCallback &= blockCallbacks;

                    variants.Add(depo);

                    if (depo.ChildDeposits != null)
                    {
                        foreach (var childdepo in depo.ChildDeposits)
                        {
                            childdepo.fromFile           = val.Key.ToString();
                            childdepo.parentDeposit      = depo;
                            childdepo.WithBlockCallback &= blockCallbacks;
                        }
                    }
                }
            }

            Deposits = variants.ToArray();


            depositShapeDistortNoise = NormalizedSimplexNoise.FromDefaultOctaves(3, 1 / 10f, 0.9f, 1);

            regionSize       = api.WorldManager.RegionSize;
            noiseSizeClimate = regionSize / TerraGenConfig.climateMapScale;


            int seed = api.WorldManager.Seed;

            depositRand = new LCGRandom(api.WorldManager.Seed + 34613);

            Dictionary <string, MapLayerBase> maplayersByCode = new Dictionary <string, MapLayerBase>();

            for (int i = 0; i < Deposits.Length; i++)
            {
                DepositVariant variant = Deposits[i];
                variant.Init(api, depositRand, depositShapeDistortNoise);

                if (variant.WithOreMap)
                {
                    variant.OreMapLayer = getOrCreateMapLayer(seed, variant.Code, maplayersByCode, variant.OreMapScale, variant.OreMapContrast, variant.OreMapSub);
                }

                if (variant.ChildDeposits != null)
                {
                    for (int k = 0; k < variant.ChildDeposits.Length; k++)
                    {
                        DepositVariant childVariant = variant.ChildDeposits[k];
                        if (childVariant.WithOreMap)
                        {
                            childVariant.OreMapLayer = getOrCreateMapLayer(seed, childVariant.Code, maplayersByCode, variant.OreMapScale, variant.OreMapContrast, variant.OreMapSub);
                        }
                    }
                }
            }

            verticalDistortBottom = GenMaps.GetDepositVerticalDistort(seed + 12);
            verticalDistortTop    = GenMaps.GetDepositVerticalDistort(seed + 28);
        }
コード例 #22
0
        void initSoundsAndEffects()
        {
            capi   = entity.Api as ICoreClientAPI;
            isSelf = capi.World.Player.Entity.EntityId == entity.EntityId;
            if (!isSelf)
            {
                return;
            }

            // Effects
            fogNoise = NormalizedSimplexNoise.FromDefaultOctaves(4, 1, 0.9, 123);

            rustParticles = new SimpleParticleProperties()
            {
                Color                = ColorUtil.ToRgba(150, 50, 25, 15),
                ParticleModel        = EnumParticleModel.Quad,
                MinSize              = 0.1f,
                MaxSize              = 0.5f,
                GravityEffect        = 0,
                LifeLength           = 2f,
                WithTerrainCollision = false,
                ShouldDieInLiquid    = false,
                RandomVelocityChange = true,
                MinVelocity          = new Vec3f(-1f, -1f, -1f),
                AddVelocity          = new Vec3f(2f, 2f, 2f),
                MinQuantity          = 1,
                AddQuantity          = 0,
            };

            rustParticles.AddVelocity   = new Vec3f(0f, 30f, 0);
            rustParticles.OpacityEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -8);


            float b = 0.25f;

            capi.Ambient.CurrentModifiers["brownrainandfog"] = rainfogAmbient = new AmbientModifier()
            {
                AmbientColor = new WeightedFloatArray(new float[] { 0.5f * 132 / 255f, 0.5f * 115 / 255f, 0.5f * 112f / 255f, 1 }, 0),
                FogColor     = new WeightedFloatArray(new float[] { b * 132 / 255f, b * 115 / 255f, b * 112f / 255f, 1 }, 0),
                FogDensity   = new WeightedFloat(0.05f, 0),
            }.EnsurePopulated();



            // Sounds
            tempStabSoundDrain = capi.World.LoadSound(new SoundParams()
            {
                Location         = new AssetLocation("sounds/effect/tempstab-drain.ogg"),
                ShouldLoop       = true,
                RelativePosition = true,
                DisposeOnFinish  = false,
                SoundType        = EnumSoundType.SoundGlitchunaffected,
                Volume           = 0f
            });

            tempStabSoundLow = capi.World.LoadSound(new SoundParams()
            {
                Location         = new AssetLocation("sounds/effect/tempstab-low.ogg"),
                ShouldLoop       = true,
                RelativePosition = true,
                DisposeOnFinish  = false,
                SoundType        = EnumSoundType.SoundGlitchunaffected,
                Volume           = 0f
            });

            tempStabSoundVeryLow = capi.World.LoadSound(new SoundParams()
            {
                Location         = new AssetLocation("sounds/effect/tempstab-verylow.ogg"),
                ShouldLoop       = true,
                RelativePosition = true,
                DisposeOnFinish  = false,
                SoundType        = EnumSoundType.SoundGlitchunaffected,
                Volume           = 0f
            });
        }
コード例 #23
0
 public ChildDepositGenerator(ICoreServerAPI api, DepositVariant variant, LCGRandom depositRand, NormalizedSimplexNoise noiseGen) : base(api, variant, depositRand, noiseGen)
 {
 }
コード例 #24
0
 public MapLayerDoublePerlin(long seed, int octaves, float persistence, int scale, int multiplier) : base(seed)
 {
     noisegenX       = NormalizedSimplexNoise.FromDefaultOctaves(octaves, 1f / scale, persistence, seed);
     noisegenY       = NormalizedSimplexNoise.FromDefaultOctaves(octaves, 1f / scale, persistence, seed + 1232);
     this.multiplier = multiplier;
 }
コード例 #25
0
 public MapLayerPerlin(long seed, int octaves, float persistence, int scale, int multiplier, double[] thresholds) : base(seed)
 {
     noisegen        = NormalizedSimplexNoise.FromDefaultOctaves(octaves, 1f / scale, persistence, seed + 12321);
     this.multiplier = multiplier;
     this.thresholds = thresholds;
 }
コード例 #26
0
        protected DiscDepositGenerator(ICoreServerAPI api, DepositVariant variant, LCGRandom depositRand, NormalizedSimplexNoise noiseGen) : base(api, variant, depositRand, noiseGen)
        {
            chunksize   = api.World.BlockAccessor.ChunkSize;
            worldheight = api.World.BlockAccessor.MapSizeY;



            regionSize       = api.WorldManager.RegionSize;
            regionChunkSize  = api.WorldManager.RegionSize / chunksize;
            noiseSizeClimate = regionSize / TerraGenConfig.climateMapScale;
            noiseSizeOre     = regionSize / TerraGenConfig.oreMapScale;
        }
コード例 #27
0
 public AlluvialDepositGenerator(ICoreServerAPI api, DepositVariant variant, LCGRandom depositRand, NormalizedSimplexNoise noiseGen) : base(api, variant, depositRand, noiseGen)
 {
     chunksize   = api.World.BlockAccessor.ChunkSize;
     worldheight = api.World.BlockAccessor.MapSizeY;
 }
コード例 #28
0
        private static bool Patch_SystemRenderPlayerEffects_onBeforeRender(
            ref SystemRenderPlayerEffects __instance, float dt, ref ClientMain ___game, ref int ___maxDynLights,
            ref NormalizedSimplexNoise ___noisegen, ref float ___curFreezingVal, ref long ___damangeVignettingUntil,
            ref int ___duration, float ___strength)
        {
            var shUniforms = ___game.GetField <DefaultShaderUniforms>("shUniforms");
            var mouseYaw   = ___game.GetField <float>("mouseYaw");
            var mousePitch = ___game.GetField <float>("mousePitch");

            shUniforms.PointLightsCount = 0;
            var plrPos = ___game.EntityPlayer.Pos.XYZ;
            var array  = ___game.GetEntitiesAround(plrPos, 60f, 60f, e => e.LightHsv != null && e.LightHsv[2] > 0);

            if (array.Length > ___maxDynLights)
            {
                array = (from e in array
                         orderby e.Pos.SquareDistanceTo(plrPos)
                         select e).ToArray();
            }
            foreach (var entity in array)
            {
                var lightHsv = entity.LightHsv;
                __instance.CallMethod("AddPointLight", lightHsv, entity.Pos);
            }

            if (Api.IsGamePaused)
            {
                return(false);
            }
            var treeAttribute = ___game.EntityPlayer.WatchedAttributes.GetTreeAttribute("health");
            var num           = treeAttribute.GetFloat("currenthealth") / treeAttribute.GetFloat("maxhealth");
            var num2          = Math.Max(0f, (0.23f - num) * 1f / 0.18f);
            var num3          = 0f;

            if (num2 > 0f)
            {
                var num4 = (float)(___game.InWorldEllapsedMs / 1000.0);
                var num5 = (float)___noisegen.Noise(12412.0, num4 / 2f) * 0.5f + (float)Math.Pow(Math.Abs(GameMath.Sin(num4 * 1f / 0.7f)), 30.0) * 0.5f;
                num3 = Math.Min(num2 * 1.5f, 1f) * (num5 * 0.75f + 0.5f);
                if (___game.EntityPlayer.Alive && Settings.AllowCameraShake)
                {
                    shUniforms.ExtraSepia = GameMath.Clamp(num2 * (float)___noisegen.Noise(0.0, num4 / 3f) * 1.2f, 0f, 1.2f);
                    if (___game.Rand.NextDouble() < 0.01)
                    {
                        ___game.AddCameraShake(0.15f * num2);
                    }
                    ___game.SetField("mouseYaw", mouseYaw + num2 * (float)(___noisegen.Noise(76.0, num4 / 50f) - 0.5) * 0.003f);
                    var num6 = num2 * (float)(___noisegen.Noise(num4 / 50f, 987.0) - 0.5) * 0.003f;
                    ___game.EntityPlayer.Pos.Pitch += num6;
                    ___game.SetField("mousePitch", mousePitch + num6);
                }
            }
            else
            {
                shUniforms.ExtraSepia = 0f;
            }
            var num7 = GameMath.Clamp((int)(___damangeVignettingUntil - ___game.ElapsedMilliseconds), 0, ___duration);

            shUniforms.DamageVignetting = GameMath.Clamp(GameMath.Clamp(___strength / 2f, 0.5f, 3.5f) * (num7 / (float)Math.Max(1, ___duration)) + num3, 0f, 1.5f);
            var @float = ___game.EntityPlayer.WatchedAttributes.GetFloat("freezingEffectStrength");

            ___curFreezingVal += (@float - ___curFreezingVal) * dt;
            if (___curFreezingVal > 0.1 && Api.World.Player.CameraMode == EnumCameraMode.FirstPerson && Settings.AllowCameraShake)
            {
                var num8 = (float)(___game.InWorldEllapsedMs / 1000.0);
                ___game.SetField("mouseYaw", mouseYaw + ClientSettings.CameraShakeStrength * (float)(Math.Max(0.0, ___noisegen.Noise(num8, 12.0) - 0.40000000596046448) * Math.Sin(num8 * 90f) * 0.01) * GameMath.Clamp(___curFreezingVal * 3f, 0f, 1f));
            }
            shUniforms.FrostVignetting = ___curFreezingVal;
            return(false);
        }
コード例 #29
0
 public FollowSealevelDiscGenerator(ICoreServerAPI api, DepositVariant variant, LCGRandom depositRand, NormalizedSimplexNoise noiseGen) : base(api, variant, depositRand, noiseGen)
 {
 }