private void GenHere(IBlockAccessor blockAccessor, BlockPos pos, LCGRandom worldGenRand)
        {
            int rnd = worldGenRand.NextInt(bases.Length);

            Block placeblock = api.World.GetBlock(CodeWithVariant("type", bases[rnd]));

            blockAccessor.SetBlock(placeblock.Id, pos);

            if (segments[rnd] != null)
            {
                placeblock = api.World.GetBlock(CodeWithVariant("type", segments[rnd]));

                int len = worldGenRand.NextInt(3);
                while (len-- > 0)
                {
                    pos.Down();
                    if (blockAccessor.GetBlock(pos).Replaceable > 6000)
                    {
                        blockAccessor.SetBlock(placeblock.Id, pos);
                    }
                }

                pos.Down();
                placeblock = api.World.GetBlock(CodeWithVariant("type", ends[rnd]));
                if (blockAccessor.GetBlock(pos).Replaceable > 6000)
                {
                    blockAccessor.SetBlock(placeblock.Id, pos);
                }
            }
        }
Beispiel #2
0
        public virtual void initWorldGen()
        {
            LoadGlobalConfig(api);

            worldheight = api.WorldManager.MapSizeY;
            chunkRand   = new LCGRandom(api.WorldManager.Seed);
        }
Beispiel #3
0
        public override void OnLoaded(ICoreAPI api)
        {
            base.OnLoaded(api);
            axe = new ItemAxe();
            //if (LastCodePart(1) != "bottom") return;

            bottomOffsets   = AreaMethods.AreaBelowOffsetList().ToArray();
            offsets         = AreaMethods.AreaAroundOffsetList().ToArray();
            cardinaloffsets = AreaMethods.CardinalOffsetList().ToArray();

            rand = new LCGRandom(api.World.Seed);

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

            List <Block> nannerblocks = new List <Block>();
            List <Block> cocoblocks   = new List <Block>();

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

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

            tip = api.World.BlockAccessor.GetBlock(CodeWithPart("tip", 1));
        }
Beispiel #4
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);
 }
        private void tryPlaceDecoUp(BlockPos blockPos, IBlockAccessor blockAccessor, LCGRandom worldgenRand)
        {
            if (blockAccessor.GetBlockId(blockPos) != 0)
            {
                return;
            }

            int tries = 7;

            while (tries-- > 0)
            {
                blockPos.Y++;
                Block block = blockAccessor.GetBlock(blockPos);
                if (block.IsLiquid())
                {
                    return;
                }
                if (block.SideSolid[BlockFacing.DOWN.Index])
                {
                    blockPos.Y--;
                    Block placeblock = DecoBlocksCeiling[worldgenRand.NextInt(DecoBlocksCeiling.Length)];
                    blockAccessor.SetBlock(placeblock.BlockId, blockPos);
                    return;
                }
            }
        }
Beispiel #6
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);
 }
Beispiel #7
0
        public WeatherSimulationRegion(WeatherSystemBase ws, int regionX, int regionZ)
        {
            this.ws      = ws;
            this.regionX = regionX;
            this.regionZ = regionZ;

            int regsize = ws.api.World.BlockAccessor.RegionSize;

            cloudTilebasePosX = (regionX * regsize) / ws.CloudTileSize;
            cloudTilebasePosZ = (regionZ * regsize) / ws.CloudTileSize;


            regionCenterPos = new BlockPos(regionX * regsize + regsize / 2, 0, regionZ * regsize + regsize / 2);


            Rand = new LCGRandom(ws.api.World.Seed);
            Rand.InitPositionSeed(regionX / 3, regionZ / 3);
            weatherData.Ambient = new AmbientModifier().EnsurePopulated();

            if (ws.api.Side == EnumAppSide.Client)
            {
                capi = ws.api as ICoreClientAPI;

                weatherData.Ambient.FogColor = capi.Ambient.Base.FogColor.Clone();
            }
            else
            {
                wsServer = ws as WeatherSystemServer;
            }

            ReloadPatterns(ws.api.World.Seed);
        }
Beispiel #8
0
        public WeatherSimulationRegion(WeatherSystemBase ws, int regionX, int regionZ)
        {
            this.ws                 = ws;
            this.regionX            = regionX;
            this.regionZ            = regionZ;
            this.SnowAccumSnapshots = new RingArray <SnowAccumSnapshot>((int)(ws.api.World.Calendar.DaysPerYear * ws.api.World.Calendar.HoursPerDay) + 1);


            int regsize = ws.api.World.BlockAccessor.RegionSize;

            LastUpdateTotalHours = ws.api.World.Calendar.TotalHours;

            cloudTilebasePosX = (regionX * regsize) / ws.CloudTileSize;
            cloudTilebasePosZ = (regionZ * regsize) / ws.CloudTileSize;

            regionCenterPos = new BlockPos(regionX * regsize + regsize / 2, 0, regionZ * regsize + regsize / 2);


            Rand = new LCGRandom(ws.api.World.Seed);
            Rand.InitPositionSeed(regionX / 3, regionZ / 3);
            weatherData.Ambient = new AmbientModifier().EnsurePopulated();

            if (ws.api.Side == EnumAppSide.Client)
            {
                capi = ws.api as ICoreClientAPI;

                weatherData.Ambient.FogColor = capi.Ambient.Base.FogColor.Clone();
            }
            else
            {
                wsServer = ws as WeatherSystemServer;
            }

            ReloadPatterns(ws.api.World.Seed);
        }
Beispiel #9
0
        public void initWorldGen()
        {
            LoadGlobalConfig(api);

            rnd       = new LCGRandom(api.WorldManager.Seed - 87698);
            chunksize = api.WorldManager.ChunkSize;

            treeSupplier.LoadTrees();

            worldheight     = api.WorldManager.MapSizeY;
            chunkMapSizeY   = api.WorldManager.MapSizeY / chunksize;
            regionChunkSize = api.WorldManager.RegionSize / chunksize;

            RockBlockIdsByType = new Dictionary <string, int>();
            RockStrataConfig rockstrata = api.Assets.Get("worldgen/rockstrata.json").ToObject <RockStrataConfig>();

            for (int i = 0; i < rockstrata.Variants.Length; i++)
            {
                Block block = api.World.GetBlock(rockstrata.Variants[i].BlockCode);
                RockBlockIdsByType[block.LastCodePart()] = block.BlockId;
            }
            IAsset asset = api.Assets.Get("worldgen/blockpatches.json");

            bpc = asset.ToObject <BlockPatchConfig>();
            bpc.ResolveBlockIds(api, rockstrata);



            ITreeAttribute worldConfig = api.WorldManager.SaveGame.WorldConfiguration;

            forestMod = worldConfig.GetString("globalForestation").ToFloat(0);
        }
Beispiel #10
0
        public void Generate(IBlockAccessor blockAccessor, LCGRandom rnd, int posX, int posY, int posZ, int firstBlockId)
        {
            float quantity  = Quantity.nextFloat() + 1;
            int   chunkSize = blockAccessor.ChunkSize;

            Block[] blocks = getBlocks(firstBlockId);
            if (blocks.Length == 0)
            {
                return;
            }

            while (quantity-- > 0)
            {
                if (quantity < 1 && rnd.NextDouble() > quantity)
                {
                    break;
                }

                pos.X = posX + (int)OffsetX.nextFloat();
                pos.Z = posZ + (int)OffsetZ.nextFloat();

                int index = GameMath.Mod((int)BlockCodeIndex.nextFloat(), blocks.Length);

                IServerChunk chunk = (IServerChunk)blockAccessor.GetChunk(pos.X / chunkSize, 0, pos.Z / chunkSize);
                if (chunk == null)
                {
                    break;
                }

                int lx = GameMath.Mod(pos.X, chunkSize);
                int lz = GameMath.Mod(pos.Z, chunkSize);

                if (Placement == EnumBlockPatchPlacement.Underground)
                {
                    pos.Y = rnd.NextInt(Math.Max(1, chunk.MapChunk.WorldGenTerrainHeightMap[lz * blockAccessor.ChunkSize + lx] - 1));
                }
                else
                {
                    pos.Y = chunk.MapChunk.RainHeightMap[lz * blockAccessor.ChunkSize + lx] + 1;

                    if (Math.Abs(pos.Y - posY) > 8 || pos.Y >= blockAccessor.MapSizeY - 1)
                    {
                        continue;
                    }

                    if (Placement == EnumBlockPatchPlacement.UnderWater)
                    {
                        tempPos.Set(pos.X, pos.Y - GameMath.Max(1, MinWaterDepth), pos.Z);
                        Block downBlock = blockAccessor.GetBlock(tempPos);
                        if (downBlock == null || downBlock.LiquidCode != "water")
                        {
                            continue;
                        }
                    }
                }

                blocks[index].TryPlaceBlockForWorldGen(blockAccessor, pos, BlockFacing.UP, rnd);
            }
        }
        public void initWorldGen()
        {
            regionSize          = sapi.WorldManager.RegionSize;
            chunksize           = sapi.World.BlockAccessor.ChunkSize;
            noiseSizeDensityMap = regionSize / TerraGenConfig.blockPatchesMapScale;

            LoadGlobalConfig(sapi);

            rnd       = new LCGRandom(sapi.WorldManager.Seed - 87698);
            chunksize = sapi.WorldManager.ChunkSize;

            treeSupplier.LoadTrees();

            worldheight     = sapi.WorldManager.MapSizeY;
            chunkMapSizeY   = sapi.WorldManager.MapSizeY / chunksize;
            regionChunkSize = sapi.WorldManager.RegionSize / chunksize;

            RockBlockIdsByType = new Dictionary <string, int>();
            RockStrataConfig rockstrata = sapi.Assets.Get("worldgen/rockstrata.json").ToObject <RockStrataConfig>();

            for (int i = 0; i < rockstrata.Variants.Length; i++)
            {
                Block block = sapi.World.GetBlock(rockstrata.Variants[i].BlockCode);
                RockBlockIdsByType[block.LastCodePart()] = block.BlockId;
            }
            IAsset asset = sapi.Assets.Get("worldgen/blockpatches.json");

            bpc = asset.ToObject <BlockPatchConfig>();

            var blockpatchesfiles = sapi.Assets.GetMany <BlockPatch[]>(sapi.World.Logger, "worldgen/blockpatches/");

            foreach (var patches in blockpatchesfiles.Values)
            {
                bpc.Patches = bpc.Patches.Append(patches);
            }

            bpc.ResolveBlockIds(sapi, rockstrata, rnd);
            treeSupplier.treeGenerators.forestFloorSystem.SetBlockPatches(bpc);


            ITreeAttribute worldConfig = sapi.WorldManager.SaveGame.WorldConfiguration;

            forestMod = worldConfig.GetString("globalForestation").ToFloat(0);

            blockPatchMapGens.Clear();
            foreach (var patch in bpc.Patches)
            {
                if (patch.MapCode == null || blockPatchMapGens.ContainsKey(patch.MapCode))
                {
                    continue;
                }

                int hs   = patch.MapCode.GetHashCode();
                int seed = sapi.World.Seed + 112897 + hs;
                blockPatchMapGens[patch.MapCode] = new MapLayerWobbled(seed, 2, 0.9f, TerraGenConfig.forestMapScale, 4000, -3000);
            }
        }
        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);
        }
Beispiel #13
0
 public WeatherPattern(WeatherSystemBase ws, WeatherPatternConfig config, LCGRandom rand, int cloudTilebasePosX, int cloudTilebasePosZ)
 {
     this.ws                = ws;
     this.rand              = rand;
     this.config            = config;
     this.api               = ws.api;
     this.cloudTilebasePosX = cloudTilebasePosX;
     this.cloudTilebasePosZ = cloudTilebasePosZ;
 }
Beispiel #14
0
    public CloudFractal(int size, int seed, float[] startVals)
    {
        _lcg = new LCGRandom((uint)seed);
        _size = size;
        _startVals = startVals;

        _field = new float[(_size) * (_size)];
        for(int i=0; i<_field.Length; ++i)
            _field[i] = -1.0f;
    }
Beispiel #15
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);
        }
Beispiel #16
0
    public CloudFractal(int size, int seed, CloudOptions options)
    {
        _size = size;
        _startVals = options.GetStartArray();

        _lcg = new LCGRandom((uint)seed);
        _field = new float[(_size) * (_size)];
        for(int i=0; i<_field.Length; ++i)
            _field[i] = -1.0f;
    }
Beispiel #17
0
        public void Init(ICoreServerAPI api, RockStrataConfig rockstrata, LCGRandom rnd, int i)
        {
            List <Block> blocks = new List <Block>();

            for (int j = 0; j < blockCodes.Length; j++)
            {
                AssetLocation code = blockCodes[j];

                if (code.Path.Contains("{rocktype}"))
                {
                    if (BlocksByRockType == null)
                    {
                        BlocksByRockType = new Dictionary <int, Block[]>();
                    }

                    for (int k = 0; k < rockstrata.Variants.Length; k++)
                    {
                        string        rocktype      = rockstrata.Variants[k].BlockCode.Path.Split('-')[1];
                        AssetLocation rocktypedCode = code.CopyWithPath(code.Path.Replace("{rocktype}", rocktype));

                        Block rockBlock = api.World.GetBlock(rockstrata.Variants[k].BlockCode);

                        if (rockBlock != null)
                        {
                            BlocksByRockType[rockBlock.BlockId] = new Block[] { api.World.GetBlock(rocktypedCode) };
                        }
                    }
                }
                else
                {
                    Block block = api.World.GetBlock(code);
                    if (block != null)
                    {
                        blocks.Add(block);
                    }
                    else
                    {
                        api.World.Logger.Warning("Block patch Nr. {0}: Unable to resolve block with code {1}. Will ignore.", i, code);
                    }
                }
            }

            Blocks = blocks.ToArray();

            if (BlockCodeIndex == null)
            {
                BlockCodeIndex = NatFloat.createUniform(0, Blocks.Length);
            }

            if (RandomMapCodePool != null)
            {
                int index = rnd.NextInt(RandomMapCodePool.Length);
                MapCode = RandomMapCodePool[index];
            }
        }
Beispiel #18
0
        public WindPattern(ICoreAPI api, WindPatternConfig config, int index, LCGRandom rand, int seed)
        {
            this.rand        = rand;
            this.config      = config;
            this.api         = api;
            this.State.Index = index;

            if (config.StrengthNoise != null)
            {
                strengthNoiseGen = new SimplexNoise(config.StrengthNoise.Amplitudes, config.StrengthNoise.Frequencies, seed + index);
            }
        }
Beispiel #19
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;
        }
        public override void StartServerSide(ICoreServerAPI api)
        {
            this.api = api;
            this.worldBlockAccessor = api.World.BlockAccessor;
            this.chunkSize          = worldBlockAccessor.ChunkSize;

            this.worldSeedRand = new LCGRandom(api.World.Seed);

            this.api.Event.GetWorldgenBlockAccessor(OnWorldGenBlockAccessor);

            this.api.Event.ChunkColumnGeneration(CrystalGen, EnumWorldGenPass.Vegetation, "standard");
        }
Beispiel #21
0
        public void OnGenerated(IBlockAccessor blockAccessor, LCGRandom rnd, BlockMushroom block)
        {
            setMushroomBlock(block);

            MyceliumSystem.lcgrnd.InitPositionSeed(mushroomBlockCode.GetHashCode(), (int)(mushroomBlock as BlockMushroom).Api.World.Calendar.GetHemisphere(Pos));
            if (MyceliumSystem.lcgrnd.NextDouble() < 0.33)
            {
                mushroomsGrowingDays = MyceliumSystem.lcgrnd.NextDouble() * 10;
                return;
            }
            growMushrooms(blockAccessor, rnd);
        }
Beispiel #22
0
    public VoronoiDiagram(int size, int seed, VoronoiOptions options)
    {
        mSize = size;
        delDistanceFunc = DistanceFunctions.GetDistanceFunction(options.metric);
        delCombiningFunc = CombinerFunctions.GetFunction(options.combiner);
        mNumFeaturePoints = options.numberOfFeaturePoints;
        mNumSubregions = options.numberOfSubregions;
        mMultiplier = options.multiplier;

        aFeaturePoints = new int[0];
        mRNG = new LCGRandom(seed);
    }
Beispiel #23
0
        /// <summary>
        /// Performs a Fisher-Yates shuffle in linear time or O(n)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="rand"></param>
        /// <param name="array"></param>
        public static T[] Shuffle <T>(this T[] array, LCGRandom rand)
        {
            int n = array.Length;        // The number of items left to shuffle (loop invariant).

            while (n > 1)
            {
                int k = rand.NextInt(n); // 0 <= k < n.
                n--;                     // n is now the last pertinent index;
                T temp = array[n];       // swap array[n] with array[k] (does nothing if k == n).
                array[n] = array[k];
                array[k] = temp;
            }

            return(array);
        }
        public void InitDummySim()
        {
            dummySim         = new WeatherSimulationRegion(this, 0, 0);
            dummySim.IsDummy = true;
            dummySim.Initialize();

            var rand = new LCGRandom(api.World.Seed);

            rand.InitPositionSeed(3, 3);

            rainOverlayPattern = new WeatherPattern(this, GeneralConfig.RainOverlayPattern, rand, 0, 0);
            rainOverlayPattern.Initialize(0, api.World.Seed);
            rainOverlayPattern.OnBeginUse();

            rainOverlaySnap = new WeatherDataSnapshot();
        }
        internal void Init(ICoreServerAPI api)
        {
            IAsset           asset      = api.Assets.Get("worldgen/rockstrata.json");
            RockStrataConfig rockstrata = asset.ToObject <RockStrataConfig>();

            asset            = api.Assets.Get("worldgen/blocklayers.json");
            blockLayerConfig = asset.ToObject <BlockLayerConfig>();
            blockLayerConfig.ResolveBlockIds(api, rockstrata);


            for (int i = 0; i < Structures.Length; i++)
            {
                LCGRandom rand = new LCGRandom(api.World.Seed + i + 512);
                Structures[i].Init(api, blockLayerConfig, rand);
            }
        }
        public void InitWorldGen()
        {
            LoadGlobalConfig(api);

            IAsset           asset      = api.Assets.Get("worldgen/rockstrata.json");
            RockStrataConfig rockstrata = asset.ToObject <RockStrataConfig>();

            asset            = api.Assets.Get("worldgen/blocklayers.json");
            blockLayerConfig = asset.ToObject <BlockLayerConfig>();
            blockLayerConfig.ResolveBlockIds(api, rockstrata);

            rnd          = new LCGRandom(api.WorldManager.Seed);
            grassDensity = new ClampedSimplexNoise(new double[] { 4 }, new double[] { 0.5 }, rnd.NextInt());
            grassHeight  = new ClampedSimplexNoise(new double[] { 1.5 }, new double[] { 0.5 }, rnd.NextInt());

            mapheight = api.WorldManager.MapSizeY;
        }
Beispiel #27
0
        internal void initWorldGen()
        {
            chunksize       = api.WorldManager.ChunkSize;
            worldheight     = api.WorldManager.MapSizeY;
            chunkMapSizeY   = api.WorldManager.MapSizeY / chunksize;
            regionChunkSize = api.WorldManager.RegionSize / chunksize;

            strucRand = new LCGRandom(api.WorldManager.Seed + 1090);

            IAsset asset = api.Assets.Get("worldgen/structures.json");

            scfg = asset.ToObject <WorldGenStructuresConfig>();
            scfg.Init(api);

            asset = api.Assets.Get("worldgen/villages.json");
            vcfg  = asset.ToObject <WorldGenVillageConfig>();
            vcfg.Init(api);
        }
        private bool TryGenGlowWorm(IBlockAccessor blockAccessor, BlockPos pos, LCGRandom worldGenRand)
        {
            bool didplace = false;

            for (int dy = 0; dy < 5; dy++)
            {
                Block block = blockAccessor.GetBlock(pos.X, pos.Y + dy, pos.Z);
                if (block.SideSolid[BlockFacing.DOWN.Index])
                {
                    GenHere(blockAccessor, pos.AddCopy(0, dy - 1, 0), worldGenRand);
                    break;
                }
                else if (block.Id != 0)
                {
                    break;
                }
            }

            return(didplace);
        }
Beispiel #29
0
        public override void OnLoaded(ICoreAPI api)
        {
            base.OnLoaded(api);

            rnd = new LCGRandom(api.World.Seed);

            JsonItemStack[]  jstacks   = Attributes["craftingResults"].AsObject <JsonItemStack[]>();
            List <ItemStack> stacklist = new List <ItemStack>();

            for (int i = 0; i < jstacks.Length; i++)
            {
                JsonItemStack jstack = jstacks[i];
                jstack.Resolve(api.World, "Scrap weapon kit craft result");
                if (jstack.ResolvedItemstack != null)
                {
                    stacklist.Add(jstack.ResolvedItemstack);
                }
            }

            craftResultStacks = stacklist.ToArray();
        }
Beispiel #30
0
        public AirBrushTool(WorldEditWorkspace workspace, IBlockAccessorRevertable blockAccessor) : base(workspace, blockAccessor)
        {
            if (!workspace.FloatValues.ContainsKey("std.airBrushRadius"))
            {
                Radius = 8;
            }
            if (!workspace.FloatValues.ContainsKey("std.airBrushQuantity"))
            {
                Quantity = 10;
            }
            if (!workspace.IntValues.ContainsKey("std.airBrushApply"))
            {
                Apply = EnumAirBrushApply.AnyFace;
            }
            if (!workspace.IntValues.ContainsKey("std.airBrushMode"))
            {
                Mode = EnumAirBrushMode.Add;
            }

            lcgRand = new LCGRandom(workspace.world.Seed);
        }
Beispiel #31
0
        public void initWorldGen()
        {
            LoadGlobalConfig(api);

            rand             = new LCGRandom(api.WorldManager.Seed - 12);
            searchSize       = 3 * chunksize;
            mapOffset        = chunksize;
            minBoundary      = -chunksize + 1;
            maxBoundary      = 2 * chunksize - 1;
            mapheight        = api.WorldManager.MapSizeY;
            didCheckPosition = new bool[searchSize * searchSize];

            IAsset           asset      = api.Assets.Get("worldgen/rockstrata.json");
            RockStrataConfig rockstrata = asset.ToObject <RockStrataConfig>();

            asset = api.Assets.Get("worldgen/blocklayers.json");
            BlockLayerConfig blockLayerConfig = asset.ToObject <BlockLayerConfig>();

            blockLayerConfig.ResolveBlockIds(api, rockstrata);

            lakebedLayerConfig = blockLayerConfig.LakeBedLayer;
        }
Beispiel #32
0
        public void initWorldGen()
        {
            LoadGlobalConfig(api);

            rnd       = new LCGRandom(api.WorldManager.Seed);
            chunksize = api.WorldManager.ChunkSize;

            worldheight     = api.WorldManager.MapSizeY;
            chunkMapSizeY   = api.WorldManager.MapSizeY / chunksize;
            regionChunkSize = api.WorldManager.RegionSize / chunksize;

            RockBlockIdsByType = new Dictionary <string, int>();
            RockStrataConfig rockstrata = api.Assets.Get("worldgen/rockstrata.json").ToObject <RockStrataConfig>();

            for (int i = 0; i < rockstrata.Variants.Length; i++)
            {
                Block block = api.World.GetBlock(rockstrata.Variants[i].BlockCode);
                RockBlockIdsByType.Add(block.LastCodePart(), block.BlockId);
            }
            IAsset asset = api.Assets.Get("worldgen/blockpatches.json");

            bpc = asset.ToObject <BlockPatchConfig>();
            bpc.ResolveBlockIds(api, rockstrata, rnd);
        }
Beispiel #33
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";
            }
        }