NoiseEngine/CubicNoise/NoiseEngine.cs

33 lines
1.1 KiB
C#
Raw Normal View History

2020-01-11 18:00:46 +00:00
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<IParameterName, int> 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);
}
}