2019-04-12 04:09:54 -04:00
|
|
|
using System;
|
2018-10-30 15:05:06 -04:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace UnityAtoms
|
|
|
|
{
|
2019-06-16 15:27:24 -04:00
|
|
|
public abstract class GameFunction<R> : ScriptableObject, IFunctionIcon
|
2018-10-30 15:05:06 -04:00
|
|
|
{
|
2019-04-12 04:09:54 -04:00
|
|
|
[HideInInspector]
|
|
|
|
public Func<R> Func;
|
|
|
|
|
|
|
|
public virtual R Call()
|
|
|
|
{
|
|
|
|
if (Func != null)
|
|
|
|
{
|
|
|
|
return Func();
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Exception("Either set Func or override the Call method.");
|
|
|
|
}
|
2019-04-12 10:41:54 -04:00
|
|
|
|
|
|
|
public GameFunction<R> SetFunc(Func<R> func)
|
|
|
|
{
|
|
|
|
Func = func;
|
|
|
|
return this;
|
|
|
|
}
|
2018-10-30 15:05:06 -04:00
|
|
|
}
|
|
|
|
|
2019-06-16 17:41:19 -04:00
|
|
|
public abstract class GameFunction<R, T1> : ScriptableObject, IFunctionIcon
|
2018-10-30 15:05:06 -04:00
|
|
|
{
|
2019-04-12 04:09:54 -04:00
|
|
|
[HideInInspector]
|
2019-04-12 04:19:25 -04:00
|
|
|
public Func<T1, R> Func;
|
2019-04-12 04:09:54 -04:00
|
|
|
|
|
|
|
public virtual R Call(T1 t1)
|
|
|
|
{
|
2019-04-12 04:19:25 -04:00
|
|
|
if (Func != null)
|
2019-04-12 04:09:54 -04:00
|
|
|
{
|
2019-04-12 04:19:25 -04:00
|
|
|
return Func(t1);
|
2019-04-12 04:09:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
throw new Exception("Either set Func or override the Call method.");
|
|
|
|
}
|
2019-04-12 10:41:54 -04:00
|
|
|
|
|
|
|
public GameFunction<R, T1> SetFunc(Func<T1, R> func)
|
|
|
|
{
|
|
|
|
Func = func;
|
|
|
|
return this;
|
|
|
|
}
|
2018-10-30 15:05:06 -04:00
|
|
|
}
|
|
|
|
|
2019-06-16 17:41:19 -04:00
|
|
|
public abstract class GameFunction<R, T1, T2> : ScriptableObject, IFunctionIcon
|
2018-10-30 15:05:06 -04:00
|
|
|
{
|
2019-04-12 04:09:54 -04:00
|
|
|
[HideInInspector]
|
2019-04-12 04:19:25 -04:00
|
|
|
public Func<T1, T2, R> Func;
|
2019-04-12 04:09:54 -04:00
|
|
|
|
|
|
|
public virtual R Call(T1 t1, T2 t2)
|
|
|
|
{
|
2019-04-12 04:19:25 -04:00
|
|
|
if (Func != null)
|
2019-04-12 04:09:54 -04:00
|
|
|
{
|
2019-04-12 04:19:25 -04:00
|
|
|
return Func(t1, t2);
|
2019-04-12 04:09:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
throw new Exception("Either set Func or override the Call method.");
|
|
|
|
}
|
2019-04-12 10:41:54 -04:00
|
|
|
|
|
|
|
public GameFunction<R, T1, T2> SetFunc(Func<T1, T2, R> func)
|
|
|
|
{
|
|
|
|
Func = func;
|
|
|
|
return this;
|
|
|
|
}
|
2018-10-30 15:05:06 -04:00
|
|
|
}
|
|
|
|
|
2019-06-16 17:41:19 -04:00
|
|
|
public abstract class GameFunction<R, T1, T2, T3> : ScriptableObject, IFunctionIcon
|
2018-10-30 15:05:06 -04:00
|
|
|
{
|
2019-04-12 04:09:54 -04:00
|
|
|
[HideInInspector]
|
2019-04-12 04:19:25 -04:00
|
|
|
public Func<T1, T2, T3, R> Func;
|
2019-04-12 04:09:54 -04:00
|
|
|
|
|
|
|
public virtual R Call(T1 t1, T2 t2, T3 t3)
|
|
|
|
{
|
2019-04-12 04:19:25 -04:00
|
|
|
if (Func != null)
|
2019-04-12 04:09:54 -04:00
|
|
|
{
|
2019-04-12 04:19:25 -04:00
|
|
|
return Func(t1, t2, t3);
|
2019-04-12 04:09:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
throw new Exception("Either set Func or override the Call method.");
|
|
|
|
}
|
2019-04-12 10:41:54 -04:00
|
|
|
|
|
|
|
public GameFunction<R, T1, T2, T3> SetFunc(Func<T1, T2, T3, R> func)
|
|
|
|
{
|
|
|
|
Func = func;
|
|
|
|
return this;
|
|
|
|
}
|
2018-10-30 15:05:06 -04:00
|
|
|
}
|
|
|
|
|
2019-06-16 17:41:19 -04:00
|
|
|
public abstract class GameFunction<R, T1, T2, T3, T4> : ScriptableObject, IFunctionIcon
|
2018-10-30 15:05:06 -04:00
|
|
|
{
|
2019-04-12 04:09:54 -04:00
|
|
|
[HideInInspector]
|
2019-04-12 04:19:25 -04:00
|
|
|
public Func<T1, T2, T3, T4, R> Func;
|
2019-04-12 04:09:54 -04:00
|
|
|
|
|
|
|
public virtual R Call(T1 t1, T2 t2, T3 t3, T4 t4)
|
|
|
|
{
|
2019-04-12 04:19:25 -04:00
|
|
|
if (Func != null)
|
2019-04-12 04:09:54 -04:00
|
|
|
{
|
2019-04-12 04:19:25 -04:00
|
|
|
return Func(t1, t2, t3, t4);
|
2019-04-12 04:09:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
throw new Exception("Either set Func or override the Call method.");
|
|
|
|
}
|
2019-04-12 10:41:54 -04:00
|
|
|
|
|
|
|
public GameFunction<R, T1, T2, T3, T4> SetFunc(Func<T1, T2, T3, T4, R> func)
|
|
|
|
{
|
|
|
|
Func = func;
|
|
|
|
return this;
|
|
|
|
}
|
2018-10-30 15:05:06 -04:00
|
|
|
}
|
|
|
|
|
2019-06-16 17:41:19 -04:00
|
|
|
public abstract class GameFunction<R, T1, T2, T3, T4, T5> : ScriptableObject, IFunctionIcon
|
2018-10-30 15:05:06 -04:00
|
|
|
{
|
2019-04-12 04:09:54 -04:00
|
|
|
[HideInInspector]
|
2019-04-12 04:19:25 -04:00
|
|
|
public Func<T1, T2, T3, T4, T5, R> Func;
|
2019-04-12 04:09:54 -04:00
|
|
|
|
|
|
|
public virtual R Call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
|
|
|
|
{
|
2019-04-12 04:19:25 -04:00
|
|
|
if (Func != null)
|
2019-04-12 04:09:54 -04:00
|
|
|
{
|
2019-04-12 04:19:25 -04:00
|
|
|
return Func(t1, t2, t3, t4, t5);
|
2019-04-12 04:09:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
throw new Exception("Either set Func or override the Call method.");
|
|
|
|
}
|
2019-04-12 10:41:54 -04:00
|
|
|
|
|
|
|
public GameFunction<R, T1, T2, T3, T4, T5> SetFunc(Func<T1, T2, T3, T4, T5, R> func)
|
|
|
|
{
|
|
|
|
Func = func;
|
|
|
|
return this;
|
|
|
|
}
|
2018-10-30 15:05:06 -04:00
|
|
|
}
|
2019-04-07 05:10:09 -04:00
|
|
|
}
|