com.alicizax.unity.framework/Runtime/Timer/ITimerService.cs

56 lines
1.5 KiB
C#
Raw Normal View History

2025-09-05 19:46:30 +08:00
using System;
2026-04-28 16:29:44 +08:00
public static class TimerDebugFlags
{
public const byte Running = 1 << 0;
public const byte Loop = 1 << 1;
public const byte Unscaled = 1 << 2;
}
public struct TimerDebugInfo
{
public ulong TimerHandle;
public float LeftTime;
public float Duration;
public float Age;
public byte Flags;
}
namespace AlicizaX.Timer.Runtime
2025-09-05 19:46:30 +08:00
{
[UnityEngine.Scripting.Preserve]
2026-04-20 13:46:44 +08:00
public interface ITimerService : IService
2025-09-05 19:46:30 +08:00
{
2026-04-27 12:06:09 +08:00
ulong AddTimer(TimerHandlerNoArgs callback, float time, bool isLoop = false, bool isUnscaled = false);
ulong AddTimer<T>(Action<T> callback, T arg, float time, bool isLoop = false, bool isUnscaled = false) where T : class;
void Stop(ulong timerHandle);
void Resume(ulong timerHandle);
bool IsRunning(ulong timerHandle);
float GetLeftTime(ulong timerHandle);
void Restart(ulong timerHandle);
void RemoveTimer(ulong timerHandle);
}
[UnityEngine.Scripting.Preserve]
public interface ITimerCapacityService
{
void Prewarm(int capacity);
}
2026-04-28 16:29:44 +08:00
[UnityEngine.Scripting.Preserve]
public interface ITimerDebugService
{
2026-04-28 16:29:44 +08:00
int GetAllTimers(TimerDebugInfo[] results);
void GetStatistics(out int activeCount, out int poolCapacity, out int peakActiveCount, out int freeCount);
}
2026-04-28 16:29:44 +08:00
#if UNITY_EDITOR
[UnityEngine.Scripting.Preserve]
public interface ITimerEditorDebugService
{
2026-04-28 16:29:44 +08:00
int GetStaleOneShotTimers(TimerDebugInfo[] results);
2025-09-05 19:46:30 +08:00
}
#endif
2025-09-05 19:46:30 +08:00
}