コード例 #1
0
        /// <summary>
        /// 在几秒内只取最后一条消息
        /// *该功能不支持同步的单提供器*
        /// </summary>
        /// <param name="command"></param>
        /// <param name="time"></param>
        /// <returns></returns>
        public static BaseCommand PoolInTime(this BaseCommand command, float time)
        {
            command.usePool       = true;
            command.poolEventTime = time;
            command.conditionList.Add((args) =>
            {
                if (command is BaseSingleProvidCommand || command is BaseMultProvidCommand)
                {
                    throw new Exception("所有提供器都提供器不支持池功能");
                }
                return(!(command.poolEventTime > 0 && command.poolTime < command.poolEventTime));
            });
            command.AddEveryFrameCall(() =>
            {
                if (command.poolEventTime > 0 && command.poolTime > command.poolEventTime)
                {
                    if (command.callPool.Count != 0)
                    {
                        command.CallActDirectly(command.lastCommand);
                    }
                    else
                    {
                        command.ResetPool();
                    }
                }
            });
            //池时间调用

            return(command);
        }
コード例 #2
0
 /// <summary>
 /// 在一段时间之后重置池
 /// </summary>
 /// <param name="command"></param>
 /// <param name="time"></param>
 /// <returns></returns>
 public static BaseCommand ResetPoolByTime(this BaseCommand command, float time)
 {
     command.usePool       = true;
     command.resetPoolTime = time;
     command.AddEveryFrameCall(() => {
         //重置池
         if (command.resetPoolTime > 0 && command.poolTime > command.resetPoolTime)
         {
             command.ResetPool();
         }
     });
     return(command);
 }