コード例 #1
0
        public CloudyBrush(ExtBlock[] blocks, int[] counts, NoiseArgs n)
        {
            this.blocks     = blocks;
            this.counts     = counts;
            this.thresholds = new float[counts.Length];
            Random r = n.Seed == int.MinValue ? new Random() : new Random(n.Seed);

            noise = new ImprovedNoise(r);

            noise.Frequency   = n.Frequency;
            noise.Amplitude   = n.Amplitude;
            noise.Octaves     = n.Octaves;
            noise.Lacunarity  = n.Lacunarity;
            noise.Persistence = n.Persistence;
        }
コード例 #2
0
        static bool Handler(string arg, Player p, ref NoiseArgs args)
        {
            char opt = arg[0];

            arg = arg.Substring(2); // get part after _ or =

            if (opt == 'l')
            {
                return(ParseDecimal(p, arg, ref args.Lacunarity, 2.00f));
            }
            if (opt == 'a')
            {
                return(ParseDecimal(p, arg, ref args.Amplitude, 1.00f));
            }
            if (opt == 'f')
            {
                return(ParseDecimal(p, arg, ref args.Frequency, 0.08f));
            }
            if (opt == 'p')
            {
                return(ParseDecimal(p, arg, ref args.Persistence, 0.75f));
            }

            if (opt == 'o')
            {
                if (byte.TryParse(arg, out args.Octaves) &&
                    args.Octaves > 0 && args.Octaves <= 16)
                {
                    return(true);
                }
                Player.Message(p, "\"{0}\" was not an integer between 1 and 16.", arg);
            }
            else if (opt == 's')
            {
                if (int.TryParse(arg, out args.Seed))
                {
                    return(true);
                }
                Player.Message(p, "\"{0}\" was not a valid integer.", arg);
            }
            else
            {
                Player.Message(p, "\"{0}\" was not a valid argument name.", opt);
            }
            return(false);
        }
コード例 #3
0
ファイル: CloudyBrush.cs プロジェクト: takaaptech/MCGalaxy
        static bool Handler(string arg, Player p, ref NoiseArgs args)
        {
            char opt = arg[0];

            arg = arg.Substring(2); // get part after _ or =

            if (opt == 'l')
            {
                return(ParseDecimal(p, arg, ref args.Lacunarity, 2.00f));
            }
            if (opt == 'a')
            {
                return(ParseDecimal(p, arg, ref args.Amplitude, 1.00f));
            }
            if (opt == 'f')
            {
                return(ParseDecimal(p, arg, ref args.Frequency, 0.08f));
            }
            if (opt == 'p')
            {
                return(ParseDecimal(p, arg, ref args.Persistence, 0.75f));
            }

            if (opt == 'o')
            {
                if (!CommandParser.GetInt(p, arg, "Octaves", ref args.Octaves, 1, 16))
                {
                    return(false);
                }
            }
            else if (opt == 's')
            {
                if (!CommandParser.GetInt(p, arg, "Seed", ref args.Seed))
                {
                    return(false);
                }
            }
            else
            {
                p.Message("\"{0}\" was not a valid argument name.", opt);
                return(false);
            }
            return(true);
        }
コード例 #4
0
ファイル: CloudyBrush.cs プロジェクト: takaaptech/MCGalaxy
        public override Brush Construct(BrushArgs args)
        {
            NoiseArgs n = default(NoiseArgs);

            // Constants borrowed from fCraft to match it
            n.Amplitude   = 1;
            n.Frequency   = 0.08f;
            n.Octaves     = 3;
            n.Seed        = int.MinValue;
            n.Persistence = 0.75f;
            n.Lacunarity  = 2;

            int[]     count;
            BlockID[] toAffect = FrequencyBrush.GetBlocks(args, out count,
                                                          Filter, arg => Handler(arg, args.Player, ref n));

            if (toAffect == null)
            {
                return(null);
            }
            return(new CloudyBrush(toAffect, count, n));
        }