mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-24 00:58:59 -05:00
36 lines
834 B
C#
36 lines
834 B
C#
namespace UnityAtoms
|
|
{
|
|
public abstract class ScriptableObjectReference<T, V, E1, E2>
|
|
where E1 : GameEvent<T>
|
|
where E2 : GameEvent<T, T>
|
|
where V : ScriptableObjectVariable<T, E1, E2>
|
|
{
|
|
public bool UseConstant;
|
|
|
|
public T ConstantValue;
|
|
|
|
public V Variable;
|
|
|
|
protected ScriptableObjectReference()
|
|
{
|
|
UseConstant = true;
|
|
}
|
|
|
|
protected ScriptableObjectReference(T value) : this()
|
|
{
|
|
UseConstant = true;
|
|
ConstantValue = value;
|
|
}
|
|
|
|
public T Value
|
|
{
|
|
get { return UseConstant ? ConstantValue : Variable.Value; }
|
|
}
|
|
|
|
public static implicit operator T(ScriptableObjectReference<T, V, E1, E2> reference)
|
|
{
|
|
return reference.Value;
|
|
}
|
|
}
|
|
}
|