Example #1
0
        static Quadratic2D parseQuadratic2D(string val)
        {
            // This regex is very chonky, I'm sorry for that
            Regex regex = new Regex(@"^\((?<xQuad>-?[0-9.]+), (?<yQuad>-?[0-9.]+), (?<xyLin>-?[0-9.]+), (?<xLin>-?[0-9.]+), (?<yLin>-?[0-9.]+), (?<Const>-?[0-9.]+); (?<Clamp>True|False), (?<TopClamp>-?[0-9.]+), (?<BottomClamp>-?[0-9.]+)\)$");
            Match m     = regex.Match(val);

            if (m.Success)
            {
                Quadratic2D func = new Quadratic2D();
                func.xQuad       = float.Parse(m.Groups["xQuad"].Value);
                func.yQuad       = float.Parse(m.Groups["yQuad"].Value);
                func.xyLin       = float.Parse(m.Groups["xyLin"].Value);
                func.xLin        = float.Parse(m.Groups["xLin"].Value);
                func.yLin        = float.Parse(m.Groups["yLin"].Value);
                func.Const       = float.Parse(m.Groups["Const"].Value);
                func.Clamp       = bool.Parse(m.Groups["Clamp"].Value);
                func.TopClamp    = float.Parse(m.Groups["TopClamp"].Value);
                func.BottomClamp = float.Parse(m.Groups["BottomClamp"].Value);

                return(func);
            }
            else
            {
                return(new Quadratic2D());
            }
        }
Example #2
0
 public static string Serialize(this Quadratic2D val)
 {
     return("(" + val.xQuad + ", " + val.yQuad + ", " + val.xyLin + ", " + val.xLin + ", " + val.yLin + ", " + val.Const + "; " + val.Clamp + ", " + val.TopClamp + ", " + val.BottomClamp + ")");
 }
 public TerrainGenerator()
 {
     TerrainRadius  = 30;
     FuncMultiplier = new Quadratic2D();
 }