public HeightBrush(int width, int height, float power, int precision, SampleFunction sample = null, BlendFunction blend = null) { Width = width; Height = height; Power = power; Precision = precision; Sample = sample; Blend = blend; }
public static CompileResult CompileFunctions(CSScript script, out SampleFunction sample, out BlendFunction blend, out string errors) { if (script != null) { script.RequiredTypes.Clear(); script.RequiredTypes.Add(typeof(Math)); script.RequiredTypes.Add(typeof(Numerics)); script.RequiredTypes.Add(typeof(PerlinNoise)); if (script.Compile(out errors)) { MethodInfo sampleInfo; if (script.TryGetMember <MethodInfo>("Sample", out sampleInfo)) { try { sample = (HeightBrush.SampleFunction)sampleInfo.CreateDelegate(typeof(HeightBrush.SampleFunction), script.ScriptObject); } catch { sample = null; blend = null; return(CompileResult.WrongSampleSignature); } } else { sample = null; blend = null; return(CompileResult.MissingSampleFunction); } MethodInfo blendInfo; if (script.TryGetMember <MethodInfo>("Blend", out blendInfo)) { try { blend = (HeightBrush.BlendFunction)blendInfo.CreateDelegate(typeof(HeightBrush.BlendFunction), script.ScriptObject); } catch { sample = null; blend = null; return(CompileResult.WrongBlendSignature); } } else { sample = null; blend = null; return(CompileResult.MissingBlendFunction); } return(CompileResult.Success); } else { sample = null; blend = null; return(CompileResult.SyntaxError); } } else { throw new Exception("The supplied script was null."); } }