Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        public static AnimationMetaData FromBytes(BinaryReader reader, string version)
        {
            AnimationMetaData animdata = new AnimationMetaData();

            animdata.Code      = reader.ReadString();
            animdata.Animation = reader.ReadString();
            animdata.Weight    = reader.ReadSingle();

            int weightCount = reader.ReadInt32();

            for (int i = 0; i < weightCount; i++)
            {
                animdata.ElementWeight[reader.ReadString()] = reader.ReadSingle();
            }

            animdata.AnimationSpeed = reader.ReadSingle();
            animdata.EaseInSpeed    = reader.ReadSingle();
            animdata.EaseOutSpeed   = reader.ReadSingle();

            bool haveTrigger = reader.ReadBoolean();

            if (haveTrigger)
            {
                animdata.TriggeredBy            = new AnimationTrigger();
                animdata.TriggeredBy.MatchExact = reader.ReadBoolean();
                weightCount = reader.ReadInt32();
                animdata.TriggeredBy.OnControls = new EnumEntityActivity[weightCount];

                for (int i = 0; i < weightCount; i++)
                {
                    animdata.TriggeredBy.OnControls[i] = (EnumEntityActivity)reader.ReadInt32();
                }
                animdata.TriggeredBy.DefaultAnim = reader.ReadBoolean();
            }

            animdata.BlendMode = (EnumAnimationBlendMode)reader.ReadInt32();

            weightCount = reader.ReadInt32();
            for (int i = 0; i < weightCount; i++)
            {
                animdata.ElementBlendMode[reader.ReadString()] = (EnumAnimationBlendMode)reader.ReadInt32();
            }

            animdata.MulWithWalkSpeed = reader.ReadBoolean();

            if (GameVersion.IsAtLeastVersion(version, "1.12.5-dev.1"))
            {
                animdata.StartFrameOnce = reader.ReadSingle();
            }
            if (GameVersion.IsAtLeastVersion(version, "1.13.0-dev.3"))
            {
                animdata.HoldEyePosAfterEasein = reader.ReadSingle();
            }

            animdata.Init();

            return(animdata);
        }
Exemplo n.º 4
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);
        }