using System;
using UnityEngine;
namespace UnityAtoms
{
///
/// Generic abstract base class for Functions. Inherits from `BaseAtom`.
///
/// The type to return from the Function.
[EditorIcon("atom-icon-sand")]
public abstract class AtomFunction : BaseAtom
{
///
/// The actual function.
///
[HideInInspector]
public Func Func;
///
/// Call the Function.
///
/// Whatever the function decides to return of type `R`.
public virtual R Call()
{
if (Func != null)
{
return Func();
}
throw new Exception("Either set Func or override the Call method.");
}
///
/// Set the Function providing a `Func<R>`.
///
/// The `Func<R>` to set.
/// An `AtomFunction<R>`.
public AtomFunction SetFunc(Func func)
{
Func = func;
return this;
}
}
///
/// Generic abstract base class for Functions. Inherits from `BaseAtom`.
///
/// The type to return from the Function.
/// The parameter type for this Function.
[EditorIcon("atom-icon-sand")]
public abstract class AtomFunction : BaseAtom
{
///
/// The actual function.
///
[HideInInspector]
public Func Func;
///
/// Call the Function.
///
/// The first parameter.
/// Whatever the function decides to return of type `R`.
public virtual R Call(T1 t1)
{
if (Func != null)
{
return Func(t1);
}
throw new Exception("Either set Func or override the Call method.");
}
///
/// Set the Function providing a `Func<T1, R>`.
///
/// The `Func<T1, R>` to set.
/// An `AtomFunction<R, T1>`.
public AtomFunction SetFunc(Func func)
{
Func = func;
return this;
}
}
///
/// Generic abstract base class for Functions. Inherits from `BaseAtom`.
///
/// The type to return from the Function.
/// The first parameter type for this Function.
/// The second parameter type for this Function.
[EditorIcon("atom-icon-sand")]
public abstract class AtomFunction : BaseAtom
{
///
/// The actual function.
///
[HideInInspector]
public Func Func;
///
/// Call the Function.
///
/// The first parameter.
/// The second parameter.
/// Whatever the function decides to return of type `R`.
public virtual R Call(T1 t1, T2 t2)
{
if (Func != null)
{
return Func(t1, t2);
}
throw new Exception("Either set Func or override the Call method.");
}
///
/// Set the Function providing a `Func<T1, T2, R>`.
///
/// The `Func<T1, T2, R>` to set.
/// An `AtomFunction<R, T1, T2>`.
public AtomFunction SetFunc(Func func)
{
Func = func;
return this;
}
}
///
/// Generic abstract base class for Functions. Inherits from `BaseAtom`.
///
/// The type to return from the Function.
/// The first parameter type for this Function.
/// The second parameter type for this Function.
/// The third parameter type for this Function.
[EditorIcon("atom-icon-sand")]
public abstract class AtomFunction : BaseAtom
{
///
/// The actual function.
///
[HideInInspector]
public Func Func;
///
/// Call the Function.
///
/// The first parameter.
/// The second parameter.
/// The third parameter.
/// Whatever the function decides to return of type `R`.
public virtual R Call(T1 t1, T2 t2, T3 t3)
{
if (Func != null)
{
return Func(t1, t2, t3);
}
throw new Exception("Either set Func or override the Call method.");
}
///
/// Set the Function providing a `Func<T1, T2, T3, R>`.
///
/// The `Func<T1, T2, T3, R>` to set.
/// An `AtomFunction<R, T1, T2, T3>`.
public AtomFunction SetFunc(Func func)
{
Func = func;
return this;
}
}
///
/// Generic abstract base class for Functions. Inherits from `BaseAtom`.
///
/// The type to return from the Function.
/// The first parameter type for this Function.
/// The second parameter type for this Function.
/// The third parameter type for this Function.
/// The fourth parameter type for this Function.
[EditorIcon("atom-icon-sand")]
public abstract class AtomFunction : BaseAtom
{
///
/// The actual function.
///
[HideInInspector]
public Func Func;
///
/// Call the Function.
///
/// The first parameter.
/// The second parameter.
/// The third parameter.
/// The fourth parameter.
/// Whatever the function decides to return of type `R`.
public virtual R Call(T1 t1, T2 t2, T3 t3, T4 t4)
{
if (Func != null)
{
return Func(t1, t2, t3, t4);
}
throw new Exception("Either set Func or override the Call method.");
}
///
/// Set the Function providing a `Func<T1, T2, T3, T4 R>`.
///
/// The `Func<T1, T2, T3, T4, R>` to set.
/// An `AtomFunction<R, T1, T2, T3, T4>`.
public AtomFunction SetFunc(Func func)
{
Func = func;
return this;
}
}
///
/// Generic abstract base class for Functions. Inherits from `BaseAtom`.
///
/// The type to return from the Function.
/// The first parameter type for this Function.
/// The second parameter type for this Function.
/// The third parameter type for this Function.
/// The fourth parameter type for this Function.
/// The fifth parameter type for this Function.
[EditorIcon("atom-icon-sand")]
public abstract class AtomFunction : BaseAtom
{
///
/// The actual function.
///
[HideInInspector]
public Func Func;
///
/// Call the Function.
///
/// The first parameter.
/// The second parameter.
/// The third parameter.
/// The fourth parameter.
/// The fifth parameter.
/// Whatever the function decides to return of type `R`.
public virtual R Call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
{
if (Func != null)
{
return Func(t1, t2, t3, t4, t5);
}
throw new Exception("Either set Func or override the Call method.");
}
///
/// Set the Function providing a `Func<T1, T2, T3, T4, T5 R>`.
///
/// The `Func<T1, T2, T3, T4, T5, R>` to set.
/// An `AtomFunction<R, T1, T2, T3, T4, T5>`.
public AtomFunction SetFunc(Func func)
{
Func = func;
return this;
}
}
}