namespace UnityAtoms
{
///
/// None generic base class for `AtomReference<T, V>`.
///
public abstract class AtomReference { }
public abstract class AtomReference : AtomReference
where V : AtomBaseVariable
{
///
/// If set to `true` then use constant instead of Variable value.
///
public bool UseConstant;
///
/// Constant value used if `UseConstant` is set to `true`.
///
public T ConstantValue;
///
/// Variable used if `UseConstant` is set to `false`.
///
public V Variable;
protected AtomReference()
{
UseConstant = true;
}
protected AtomReference(T value) : this()
{
UseConstant = true;
ConstantValue = value;
}
///
/// Get the value for the Reference.
///
/// The value of type `T`.
public T Value
{
get { return UseConstant ? ConstantValue : Variable.Value; }
}
public static implicit operator T(AtomReference reference)
{
return reference.Value;
}
}
}