2025-10-25 07:49:39 -04:00
|
|
|
using System;
|
2025-10-23 00:49:44 -04:00
|
|
|
using SLSFramework.General;
|
2025-10-03 00:02:43 -04:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
|
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
namespace SLSFramework.General
|
2025-10-03 00:02:43 -04:00
|
|
|
{
|
2025-10-31 10:02:30 -04:00
|
|
|
public class PrioritizedAction : IPrioritized
|
2025-10-03 00:02:43 -04:00
|
|
|
{
|
2025-10-31 10:02:30 -04:00
|
|
|
private readonly Action action;
|
2025-10-03 00:02:43 -04:00
|
|
|
public int Priority { get; set; }
|
|
|
|
|
|
2025-10-31 10:02:30 -04:00
|
|
|
public PrioritizedAction(Action action, int priority = 0)
|
2025-10-03 00:02:43 -04:00
|
|
|
{
|
|
|
|
|
this.action = action;
|
|
|
|
|
this.Priority = priority;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Invoke()
|
|
|
|
|
{
|
|
|
|
|
action.Invoke();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-31 10:02:30 -04:00
|
|
|
public class PrioritizedAction<T> : IPrioritized
|
2025-10-03 00:02:43 -04:00
|
|
|
{
|
2025-10-31 10:02:30 -04:00
|
|
|
private readonly Action<T> action;
|
2025-10-03 00:02:43 -04:00
|
|
|
public int Priority { get; set; }
|
|
|
|
|
|
2025-10-31 10:02:30 -04:00
|
|
|
public PrioritizedAction(Action<T> action, int priority = 0)
|
2025-10-03 00:02:43 -04:00
|
|
|
{
|
|
|
|
|
this.action = action;
|
|
|
|
|
this.Priority = priority;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Invoke(T arg)
|
|
|
|
|
{
|
|
|
|
|
action.Invoke(arg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-31 10:02:30 -04:00
|
|
|
public class PrioritizedAction<T1, T2> : IPrioritized
|
2025-10-03 00:02:43 -04:00
|
|
|
{
|
2025-10-31 10:02:30 -04:00
|
|
|
private readonly Action<T1, T2> action;
|
2025-10-03 00:02:43 -04:00
|
|
|
public int Priority { get; set; }
|
|
|
|
|
|
2025-10-31 10:02:30 -04:00
|
|
|
public PrioritizedAction(Action<T1, T2> action, int priority = 0)
|
2025-10-03 00:02:43 -04:00
|
|
|
{
|
|
|
|
|
this.action = action;
|
|
|
|
|
this.Priority = priority;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Invoke(T1 arg1, T2 arg2)
|
|
|
|
|
{
|
|
|
|
|
action.Invoke(arg1, arg2);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-25 07:49:39 -04:00
|
|
|
|
2025-10-31 10:02:30 -04:00
|
|
|
public class PrioritizedAction<T1, T2, T3> : IPrioritized
|
2025-10-25 07:49:39 -04:00
|
|
|
{
|
2025-10-31 10:02:30 -04:00
|
|
|
private readonly Action<T1, T2, T3> action;
|
2025-10-25 07:49:39 -04:00
|
|
|
public int Priority { get; set; }
|
|
|
|
|
|
2025-10-31 10:02:30 -04:00
|
|
|
public PrioritizedAction(Action<T1, T2, T3> action, int priority = 0)
|
2025-10-25 07:49:39 -04:00
|
|
|
{
|
|
|
|
|
this.action = action;
|
|
|
|
|
this.Priority = priority;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Invoke(T1 arg1, T2 arg2, T3 arg3)
|
|
|
|
|
{
|
|
|
|
|
action.Invoke(arg1, arg2, arg3);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-31 10:02:30 -04:00
|
|
|
public class PrioritizedFunc<TR> : IPrioritized
|
|
|
|
|
{
|
|
|
|
|
private readonly Func<TR> func;
|
|
|
|
|
public int Priority { get; set; }
|
|
|
|
|
|
|
|
|
|
public PrioritizedFunc(Func<TR> func, int priority = 0)
|
|
|
|
|
{
|
|
|
|
|
this.func = func;
|
|
|
|
|
this.Priority = priority;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TR Invoke()
|
|
|
|
|
{
|
|
|
|
|
return func.Invoke();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class PrioritizedFunc<T, TR> : IPrioritized
|
|
|
|
|
{
|
|
|
|
|
private readonly Func<T, TR> func;
|
|
|
|
|
public int Priority { get; set; }
|
|
|
|
|
|
|
|
|
|
public PrioritizedFunc(Func<T, TR> func, int priority = 0)
|
|
|
|
|
{
|
|
|
|
|
this.func = func;
|
|
|
|
|
this.Priority = priority;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TR Invoke(T arg)
|
|
|
|
|
{
|
|
|
|
|
return func.Invoke(arg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class PrioritizedFunc<T1, T2, TR> : IPrioritized
|
|
|
|
|
{
|
|
|
|
|
private readonly Func<T1, T2, TR> func;
|
|
|
|
|
public int Priority { get; set; }
|
|
|
|
|
|
|
|
|
|
public PrioritizedFunc(Func<T1, T2, TR> func, int priority = 0)
|
|
|
|
|
{
|
|
|
|
|
this.func = func;
|
|
|
|
|
this.Priority = priority;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TR Invoke(T1 arg1, T2 arg2)
|
|
|
|
|
{
|
|
|
|
|
return func.Invoke(arg1, arg2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-10-25 07:49:39 -04:00
|
|
|
public class PrioritizedFunc<T1, T2, T3, TR> : IPrioritized
|
|
|
|
|
{
|
|
|
|
|
private readonly Func<T1, T2, T3, TR> func;
|
|
|
|
|
public int Priority { get; set; }
|
|
|
|
|
|
|
|
|
|
public PrioritizedFunc(Func<T1, T2, T3, TR> func, int priority = 0)
|
|
|
|
|
{
|
|
|
|
|
this.func = func;
|
|
|
|
|
this.Priority = priority;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TR Invoke(T1 arg1, T2 arg2, T3 arg3)
|
|
|
|
|
{
|
|
|
|
|
return func.Invoke(arg1, arg2, arg3);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-31 10:02:30 -04:00
|
|
|
|
|
|
|
|
public class PrioritizedCheckAndEffect : IPrioritized
|
|
|
|
|
{
|
|
|
|
|
public readonly Func<bool> check;
|
|
|
|
|
public readonly Action effect;
|
|
|
|
|
public int Priority { get; set; }
|
|
|
|
|
|
|
|
|
|
public PrioritizedCheckAndEffect(Func<bool> check, Action effect, int priority = 0)
|
|
|
|
|
{
|
|
|
|
|
this.check = check;
|
|
|
|
|
this.effect = effect;
|
|
|
|
|
this.Priority = priority;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Invoke()
|
|
|
|
|
{
|
|
|
|
|
if (check.Invoke())
|
|
|
|
|
{
|
|
|
|
|
effect.Invoke();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-03 00:02:43 -04:00
|
|
|
}
|
|
|
|
|
|