Closed Redforce04 closed 10 months ago
What would this pr have use for?
What would this pr have use for?
Its an "asynchronous" Timing API without using Asynchronous. This can be used by us and other developers to make more effective coroutines, and do various functions.
For Instance:
public static void RunThings()
{
Timing.CallDelayed(5f, () => {
Log.Debug("This will be called after 5 seconds.");
});
}
Or you can use the custom coroutines.
private CoroutineHandle _coolCoroutine;
public static void DoCoolCoroutine()
{
_coolCoroutine = Timing.RunCoroutine(DoCoroutine, "My Cool Coroutine");
}
public static void StopCoroutine()
{
// Kill a coroutine by the handle.
Timing.KillAllCoroutines(_coolCoroutine);
// Kill a coroutine by the tag.
Timing.KillAllCoroutine("My Cool Coroutine");
// Kill all running coroutines.
Timing.KillAllCoroutine();
}
public static IEnumerator<float> DoCoroutine()
{
while(true)
{
Log.Debug("1 seconds waited.");
yield return Timing.WaitForSeconds(1f);
yield return Timing.WaitOneFrame(); // waits one frame.
}
CouroutineHandle handle = Timing.WaitForSeconds(12f, () => {
Log.Debug("Wait for me!");
});
// Won't continue until the "Wait for me!" is displayed. - Like Thread.Join
yield return Timing.WaitUntilDone(handle);
}
I didn't mean to close this lol
Look goods. Let hold it for now until it is needed.
Not all developers will use this, but some would find it very helpful. I personally would like to use it, and I feel like it's best to add it to the api, so all our modders have access to the tool.
It's in the MEC
namespace, so modders who have previously used this tool, can use it normally.
Look goods. Let hold it for now until it is needed.
I need it for the main api for some other features
Look goods. Let hold it for now until it is needed.
I need it for the main api for some other features
I think we might need to put it in ./MEC/**
ok, every seem so good so far, approved
Note: This is the free version, and we have permission to use it in the api.