public static Timer CreateConnectedTimer(this Node node, Node target, string method, Timer.TimerProcessMode processMode = Timer.TimerProcessMode.Idle, float waitTime = 1f, bool oneShot = false, bool autostart = false) { Timer timer = node.AddAndReturnChild(new Timer()); timer.ProcessMode = processMode; timer.WaitTime = waitTime; timer.OneShot = oneShot; timer.Autostart = autostart; target.ConnectTimer(timer, method); timer.Name = method; return(timer); }
public void Wire(Node node, CachedNodeStateInfo state) { TimerSystem timerSystem = node.AddAndReturnChild(new TimerSystem()); timerSystem.Name = Utils.NormalizeMemberName(state.Name); timerSystem.Parent = node; // Field-Defined TimerReceivers foreach (TimerReceiverAttribute attribute in state.GetAttributes().OfType <TimerReceiverAttribute>()) { timerSystem.AddTimer(attribute.TimeoutMethod, attribute.ProcessMode, attribute.WaitTime, attribute.OneShot, attribute.Autostart); } // Method-Defined TimerReceivers CachedNodeMethodInfo[] compatibleMethods = state.DeclaringType.GetMethods().Where(m => m.GetAttribute <TimerReceiverAttribute>() != null).ToArray(); foreach (CachedNodeMethodInfo method in compatibleMethods) { TimerReceiverAttribute attribute = method.GetAttribute <TimerReceiverAttribute>(); timerSystem.AddTimer(method.Name, attribute.ProcessMode, attribute.WaitTime, attribute.OneShot, attribute.Autostart); } state.SetValue(node, timerSystem); }