123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System;
- namespace XGame.Framework.Time
- {
- public interface ITimeModule
- {
- /// <summary>
- /// 获取当前服务端or客户端时间戳(单位:毫秒,默认获取服务端时间)
- /// </summary>
- /// <param name="clockTyp">时钟类型(客户端时间or服务端时间,默认服务端时间)</param>
- /// <returns></returns>
- long GetNowTime(ClockType clockTyp = ClockType.Server);
- /// <summary>
- /// 设置服务端or客户端时间戳(默认设置服务端时间)
- /// </summary>
- /// <param name="timestamp">时间戳(毫秒)</param>
- /// <param name="clockTyp">时钟类型(客户端时间or服务端时间,默认服务端时间)</param>
- void SetTime(long timestamp, ClockType clockTyp = ClockType.Server);
- /// <summary>
- /// 添加闹钟(默认使用服务端时间)
- /// </summary>
- /// <param name="triggerTimestamp">结束时间戳(毫秒)</param>
- /// <param name="action">回调</param>
- /// <param name="clockTyp">时钟类型(客户端时间or服务端时间,默认服务端时间)</param>
- /// <returns>此闹钟</returns>
- IAlarm AddAlarm(Action action, long triggerTimeStamp, ClockType clockTyp = ClockType.Server);
- /// <summary>
- /// 添加计时器(使用客户端时间)
- /// </summary>
- /// <param name="delay">延时,单位:毫秒</param>
- /// <param name="action">回调</param>
- /// <returns>此计时器</returns>
- ITimer AddDelayTimer(int delay, Action action);
- /// <summary>
- /// 添加循环定时器(使用客户端时间)
- /// </summary>
- /// <param name="interval">循环间隔,单位:毫秒</param>
- /// <param name="action">触发事件,参数为循环的次数</param>
- /// <param name="loopTimes">循环次数(-1为无限,0和1都是1次)</param>
- /// <returns>定时器</returns>
- ITimer AddLooperTimer(int interval, Action<int> action, int loopTimes = -1);
- /// <summary>
- /// 添加循环定时器(使用客户端时间)
- /// </summary>
- /// <param name="delay">延迟,单位:毫秒</param>
- /// <param name="interval">循环间隔,单位:毫秒</param>
- /// <param name="action">触发事件</param>
- /// <param name="loopTimes">循环次数(-1为无限,0和1都是1次)</param>
- ITimer AddDelayLooperTimer(int delay, int interval, Action<int> action, int loopTimes = -1);
- }
- }
|