private static void innerAdd(int deadline, LuaTimer.Timer tm) { tm.deadline = deadline; int num = Math.Max(0, deadline - LuaTimer.now()); LuaTimer.Wheel wheel = LuaTimer.wheels[LuaTimer.wheels.Length - 1]; for (int i = 0; i < LuaTimer.wheels.Length; i++) { LuaTimer.Wheel wheel2 = LuaTimer.wheels[i]; if (num < wheel2.timeRange) { wheel = wheel2; break; } } wheel.add(num, tm); }
internal static void tick(float deltaTime) { LuaTimer.nowTime += deltaTime; LuaTimer.pileSecs += deltaTime; int num = 0; while (LuaTimer.pileSecs >= LuaTimer.jiffies_sec) { LuaTimer.pileSecs -= LuaTimer.jiffies_sec; num++; } for (int i = 0; i < num; i++) { LinkedList <LuaTimer.Timer> linkedList = LuaTimer.wheels[0].nextDial(); LinkedListNode <LuaTimer.Timer> linkedListNode = linkedList.First; for (int j = 0; j < linkedList.Count; j++) { LuaTimer.Timer value = linkedListNode.Value; LuaTimer.executeTimers.AddLast(LuaTimer.GetTimerNodeFormPool(value)); linkedListNode = linkedListNode.Next; } while (linkedList.Count > 0) { LinkedListNode <LuaTimer.Timer> first = linkedList.First; linkedList.RemoveFirst(); LuaTimer.RecycleTimerNodeToPool(first); } for (int k = 0; k < LuaTimer.wheels.Length; k++) { LuaTimer.Wheel wheel = LuaTimer.wheels[k]; if (wheel.head != LuaTimer.Wheel.dial_scale) { break; } wheel.head = 0; if (wheel.nextWheel != null) { LinkedList <LuaTimer.Timer> linkedList2 = wheel.nextWheel.nextDial(); LinkedListNode <LuaTimer.Timer> linkedListNode2 = linkedList2.First; for (int l = 0; l < linkedList2.Count; l++) { LuaTimer.Timer value2 = linkedListNode2.Value; if (value2.delete) { LuaTimer.mapSnTimer.Remove(value2.sn); } else { LuaTimer.innerAdd(value2.deadline, value2); } linkedListNode2 = linkedListNode2.Next; } while (linkedList2.Count > 0) { LinkedListNode <LuaTimer.Timer> first2 = linkedList2.First; linkedList2.RemoveFirst(); LuaTimer.RecycleTimerNodeToPool(first2); } } } } while (LuaTimer.executeTimers.Count > 0) { LinkedListNode <LuaTimer.Timer> first3 = LuaTimer.executeTimers.First; LuaTimer.Timer value3 = first3.Value; LuaTimer.RecycleTimerNodeToPool(first3); LuaTimer.executeTimers.RemoveFirst(); if (!value3.delete && value3.handler(value3.sn) && value3.cycle > 0) { LuaTimer.innerAdd(LuaTimer.now() + value3.cycle, value3); } else { LuaTimer.mapSnTimer.Remove(value3.sn); } } }