using System;
using Unity.Collections;
using Unity.Jobs;
using UnityEngine.Experimental.Perception.Randomization.Samplers;
namespace UnityEngine.Experimental.Perception.Randomization.Parameters
{
///
/// Numeric parameters use samplers to generate randomized structs
///
/// The sample type of the parameter
[Serializable]
public abstract class NumericParameter : Parameter where T : struct
{
///
/// The sample type of parameter
///
public sealed override Type sampleType => typeof(T);
///
/// Generates one parameter sample
///
/// The generated sample
public abstract T Sample();
///
/// Schedules a job to generate an array of parameter samples.
/// Call Complete() on the JobHandle returned by this function to wait on the job generating the parameter samples.
///
/// Number of parameter samples to generate
/// The JobHandle returned from scheduling the sampling job
/// A NativeArray containing generated samples
public abstract NativeArray Samples(int sampleCount, out JobHandle jobHandle);
///
/// Generates a generic sample
///
/// The generated sample
public override object GenericSample()
{
return Sample();
}
///
/// Validate the settings of this parameter
///
public override void Validate()
{
base.Validate();
foreach (var sampler in samplers)
sampler.range.Validate();
}
}
}