using System; using System.Collections.Generic; using System.Text; using CubicNoise.Builders; using CubicNoise.Contracts; using CubicNoise.Noisers; namespace CubicNoise { public sealed class NoiseEngine : INoiseEngine { private readonly INoiseEngine engine; private NoiseEngine(NoiseTypes type, int seed, Dictionary intParameters) { this.engine = type switch { NoiseTypes.UNKNOWN => new RandomNumberEngine(seed), NoiseTypes.CUBIC_NOISE => new CubicNoiseEngine(seed, intParameters), _ => throw new ArgumentOutOfRangeException(nameof(type), type, "The provided noise type is unknown.") }; } public static NoiseEngine CreateEngine(NoiseBuilder builder) => new NoiseEngine(builder.NoiseType, builder.NoiseSeed, builder.NoiseIntParameters); public float Get(float x) => this.engine.Get(x); public float Get(float x, float y) => this.engine.Get(x, y); } }