//-------------------------------------------------------------------------------------- public Guid createTimer <T>(TimerCreationInfo createionInfo) where T : ITimer, new() { ITimer timer = new T(); timer.initialize(createionInfo.start_time); switch (createionInfo.finish_behaviour) { case TimerFinishedBehaviour.REMOVE_ON_FINISHED: timer.onFinished += scheduleForRemove; break; case TimerFinishedBehaviour.RESET_START_ON_FINSHED: timer.onFinished += scheduleForResetStart; break; case TimerFinishedBehaviour.RESET_STOP_ON_FINISHED: timer.onFinished += scheduleForResetStop; break; default: timer.onFinished += scheduleForRemove; break; } if (createionInfo.finished_delegate != null) { timer.onFinished += createionInfo.finished_delegate; } if (createionInfo.started_delegate != null) { timer.onStarted += createionInfo.started_delegate; } if (createionInfo.stopped_delegate != null) { timer.onStopped += createionInfo.stopped_delegate; } if (createionInfo.updated_delegate != null) { timer.onUpdate += createionInfo.updated_delegate; } timers_active.Add(timer.TimerID, timer); if (createionInfo.start_on_creation) { timer.start(); } return(timer.TimerID); }
//-------------------------------------------------------------------------------------- public static TimerCreationInfo createRemoveOnFinishedCreationInfo(float startTime, bool startOnCreation, TimerEventInfo eventInfo) { TimerCreationInfo info = new TimerCreationInfo { start_time = startTime, start_on_creation = startOnCreation, finish_behaviour = TimerFinishedBehaviour.REMOVE_ON_FINISHED, finished_delegate = eventInfo.finished_delegate, started_delegate = eventInfo.started_delegate, stopped_delegate = eventInfo.stopped_delegate, updated_delegate = eventInfo.updated_delegate }; return(info); }
//-------------------------------------------------------------------------------------- public static TimerCreationInfo createResetOnFinishedCreationInfo(float startTime, bool shouldStartOnReset, bool startOnCreation, TimerEventInfo eventInfo) { TimerCreationInfo info = new TimerCreationInfo { start_time = startTime, start_on_creation = startOnCreation, finish_behaviour = shouldStartOnReset ? TimerFinishedBehaviour.RESET_START_ON_FINSHED : TimerFinishedBehaviour.RESET_STOP_ON_FINISHED, finished_delegate = eventInfo.finished_delegate, started_delegate = eventInfo.started_delegate, stopped_delegate = eventInfo.stopped_delegate, updated_delegate = eventInfo.updated_delegate }; return(info); }