private void CheckAndAdd() { if (jobs.Count < concurrent) { int num = concurrent - jobs.Count; for (int i = 0; i < num; i++) { if (coroutines.Count > 0) { IEnumerator coroutine = coroutines.Dequeue(); CM_Job job = CM_Job.Make(coroutine).NotifyOnJobComplete(notifyOnJobComplete); if (isRunning) { job.Start(); } jobs.Add(job); if (NotifyOnJobStarted != null) { NotifyOnJobStarted(coroutine); } } else { break; } } } }
/// <summary> /// Creates coroutine job, starts job immediately and then pauses coroutine after 4 seconds. This /// paused job is then stored and can be resumed/killed from any class that has a reference to that job. /// </summary> public IEnumerator JobTestWithDelayedPause() { var job = CM_Job.Make(InfiniteTest("Job test with delayed pause running")).Start(); job.Pause(4f); yield return(null); }
public ConsumptionShapesClearedReason(IStateTransitioner controller, IConsumerListener consumed, FSMStateID goToState) : base(FSMTransistion.AllConsumableShapesConsumed, goToState, controller) { m_Consumed = consumed; m_MarkCompleteJob = CM_Job.Make(MarkShouldTransition()).Repeatable(); }
/// <summary> /// Creates a new job to spawn prefabs, subscribes to JobComplete event (to log a message informing user that an object has spawned), /// sets the job to repeat, and finally starts the job. /// </summary> void Start() { CM_Job.Make(SpawnPrefab()) .Repeat(numToSpawn) .NotifyOnJobComplete((object sender, CM_JobEventArgs e) => { Debug.Log("Object Spawned"); }).Start(); }
/// <summary> /// Creates and starts a job that will repeat for 3 seconds. /// The job complete event is subscribed to, this is used to display how many times the job will be repeated. /// </summary> public IEnumerator InfinitelyRepeatableJobTest() { CM_Job.Make(PrintStringAfterDelay("Infinitely repeatable Test")) .NotifyOnJobComplete((object sender, CM_JobEventArgs e) => { Debug.Log("Job repeated " + e.job.numOfTimesExecuted + " times"); }) .Repeat().StopRepeat(3f).Start(); yield return(null); }
void Start() { _jobsToQueue = new CM_Job[queueSize]; for (int i = 0; i < queueSize; i++) { _jobsToQueue [i] = CM_Job.Make(SmallJobForLargeQueue(i + 1)); } CM_JobQueue.Make().Enqueue(_jobsToQueue).Start(); }
/// <summary> /// Creates new job, subscribes to the job start and end events and then starts job to be /// run immediately. /// </summary> public IEnumerator JobTestWithStartAndEndEvents() { CM_Job.Make(PrintStringAfterDelay("Job test with start and end event subscription")) .NotifyOnJobStarted((object sender, CM_JobEventArgs e) => { Debug.Log("Started: job test with event subscription"); }) .NotifyOnJobComplete((object sender, CM_JobEventArgs e) => { Debug.Log("Finished: job test with event subscription"); }).Start(); yield return(null); }
void Start() { _text = GetComponent <Text> (); CM_JobManager.Global.AddJob( CM_Job.Make(UpdateTime()) .NotifyOnJobPaused((object sender, CM_JobEventArgs e) => { Debug.Log("Job Paused"); }) .NotifyOnJobResumed((object sender, CM_JobEventArgs e) => { Debug.Log("Job Resumed"); }).Start()); }
/// <summary> /// Creates and starts a job that will repeat three times. /// The job complete event is subscribed to, this is used to display how many times the job will be repeated. /// </summary> public IEnumerator MultipleRepeatableJobTest() { int numOfTimesToRepeat = 3; CM_Job.Make(PrintStringAfterDelay("Multiple repeatable test")) .NotifyOnJobComplete((object sender, CM_JobEventArgs e) => { Debug.Log("Job repeated " + e.job.numOfTimesExecuted + " of " + numOfTimesToRepeat + " times"); }) .Repeat(numOfTimesToRepeat).Start(); yield return(null); }
protected virtual CM_Job MakeJob(string id, IEnumerator routine, bool addListenerToOnComplete = true) { var job = CM_Job.Make(routine); job.id = (id.IsNullOrEmpty()) ? uniqueGeneratedID : id; if (addListenerToOnComplete) { job.NotifyOnJobComplete(HandlejobComplete); } return(job); }
private CM_Job GetSimpleInfiniteTestJob(string output, string id) { return(CM_Job.Make(InfiniteTest(output), id) .NotifyOnJobPaused((object sender, CM_JobEventArgs e) => { Debug.Log(e.job.id + ": paused"); }) .NotifyOnJobResumed((object sender, CM_JobEventArgs e) => { Debug.Log(e.job.id + ": resumed"); }) .NotifyOnJobComplete((object sender, CM_JobEventArgs e) => { Debug.Log(e.job.id + ": complete, killed = " + e.job.jobKilled); })); }
/// <summary> /// Creates a list of jobs, adds them to a newly created local queue and starts the queue. /// </summary> public IEnumerator SimpleLocalQueueTest() { // Creates a list of jobs with three entries. var jobsToQueue = new List <CM_Job> () { CM_Job.Make(PrintStringAfterDelay("Simple global queue test: job one"), "job_1"), CM_Job.Make(PrintStringAfterDelay("Simple global queue test: job two"), "job_2"), CM_Job.Make(PrintStringAfterDelay("Simple global queue test: job three"), "job_3") }; CM_JobQueue.Make().Enqueue(jobsToQueue).Start(); yield return(null); }
/// <summary> /// Adds a repeating job to a queue. /// Queue will not progress if a repeating job is added until that job is manually killed /// or has reached its set number of times to repeat. /// </summary> public IEnumerator AddRepeatingJobToQueueTest() { var jobsToQueue = new List <CM_Job> () { CM_Job.Make(PrintStringAfterDelay("Repeating job added to queue test, job one")), CM_Job.Make(PrintStringAfterDelay("Repeating job added to queue test, job two")).Repeat(5), CM_Job.Make(PrintStringAfterDelay("Repeating job added to queue test, , job one")) }; CM_JobQueue.Make() .Enqueue(jobsToQueue).Start(); yield return(null); }
/// <summary> /// Creates and starts a job that will repeat three times. Adds a child job that will also repeat three times. /// The job complete event and child job complete events are subscribed to, this is used to display how many times the job will be repeated. /// </summary> public IEnumerator MutltipleRepeatableJobTestWithChild() { int numOfTimesToRepeat = 3; CM_Job.Make(PrintStringAfterDelay("Repeating test with child")) .AddChild(PrintStringAfterDelay("Repeating test (child)")) .NotifyOnJobComplete((object sender, CM_JobEventArgs e) => { Debug.Log("Parent job repeated " + e.job.numOfTimesExecuted + " of " + numOfTimesToRepeat + " times"); }) .NotifyOnChildJobComplete((object sender, CM_JobEventArgs e) => { Debug.Log("Child job repeated " + (e.job.numOfTimesExecuted + 1) + " of " + numOfTimesToRepeat + " times"); }) .Repeat(numOfTimesToRepeat).Start(); yield return(null); }
/// <summary> /// Child job test. Creates new job, adds two children (parent will not complete until children have finished processing) /// and starts the job. /// </summary> public IEnumerator ChildJobTest() { CM_Job.Make(PrintStringAfterDelay("Parent job test")).AddChild(PrintStringAfterDelay("Child1 job test")).AddChild(PrintStringAfterDelay("Child2 job test")) .NotifyOnChildJobStarted((object sender, CM_JobEventArgs e) => { if (e.hasChildJobs) { Debug.Log(e.childJobs.Length + " child jobs to process"); } }) .NotifyOnChildJobComplete((object sender, CM_JobEventArgs e) => { if (e.hasChildJobs) { Debug.Log("Finished processing " + e.childJobs.Length + " child jobs"); } }) .NotifyOnJobComplete((object sender, CM_JobEventArgs e) => { Debug.Log("Parent job completed"); }).Start(); yield return(null); }
IEnumerator Duel_WaitInput() { DebugAdd("# 입력 대기 시작"); m_Count = 0; CM_Job.Make(Duel_Counting()) .Repeat(10) .NotifyOnJobComplete((object sender, CM_JobEventArgs e) => { DebugAdd(string.Format("input Count {0}", m_Count)); }).Start(); while (true) { if (m_Count == 10) { break; } yield return(null); } DebugAdd("# 입력 대기 종료"); }
/// <summary> /// Creates and returns a job to be cloned in tests. /// </summary> /// <returns>The job to clone.</returns> private CM_Job GetJobToClone() { return(CM_Job.Make(PrintStringAfterDelay("Clone job test"), "cloned_id") .NotifyOnJobStarted((object sender, CM_JobEventArgs e) => { Debug.Log("Cloned job started"); }) .NotifyOnJobPaused((object sender, CM_JobEventArgs e) => { Debug.Log("Cloned job paused"); }) .NotifyOnJobResumed((object sender, CM_JobEventArgs e) => { Debug.Log("Cloned job resumed"); }) .NotifyOnJobComplete((object sender, CM_JobEventArgs e) => { Debug.Log("Cloned job complete"); }) .NotifyOnChildJobStarted((object sender, CM_JobEventArgs e) => { Debug.Log("Cloned child jobs started"); }) .NotifyOnChildJobComplete((object sender, CM_JobEventArgs e) => { Debug.Log("Cloned child jobs completed"); }) .AddChild(PrintStringAfterDelay("Clone Child Test"))); }
/// <summary> /// Creates and starts a job after a delay. /// </summary> public IEnumerator JobTestWithDelayedStart() { CM_Job.Make(PrintStringAfterDelay("Job test with delayed start running")).Start(1.5f); yield return(null); }
/// <summary> /// Creates new job, pauses after 1 second, and resumes after 3 seconds. /// </summary> public IEnumerator JobTestWithDelayedResume() { CM_Job.Make(InfiniteTest("Job test with delayed resume running")).Start().Pause(1f).Resume(3f); yield return(null); }
public ShowShapesAction(List <ShapeControl> shapes) { m_ConsumableShapes = shapes; m_ShowShapesJob = CM_Job.Make(ShowShapes()).Repeatable().Start(); }
/// <summary> /// Creates coroutine job, starts job immediately and then sets the job to be killed after 4 seconds. /// </summary> public IEnumerator JobTestWithDelayedKill() { CM_Job.Make(InfiniteTest("Job test with delayed kill running")).Start().Kill(4f); yield return(null); }
/// <summary> /// Instantiates three jobs to be sent to the character. /// </summary> void Start() { fireDamage = CM_Job.Make(character.ApplyDamage("fire damage", 1f)); poisonDamage = CM_Job.Make(character.ApplyDamage("poison damage", 1f)); heal = CM_Job.Make(character.RestoreHealth(1f)); }
void Start() { m_ButtonBounceJob = CM_Job.Make(PlayButtonBounceAnimation()).Repeatable(); }
public ShowConsumedShapesAction(IConsumerListener consumables) { m_Consumables = consumables; m_ShowShapesJob = CM_Job.Make(ShowShapes()).Repeatable(); }
/// <summary> /// Creates and starts a job. /// </summary> public IEnumerator SimpleJobTest() { CM_Job.Make(PrintStringAfterDelay("Simple job test running")).Start(); yield return(null); }