示例#1
0
 /// <summary>
 /// Setups a routine that will be executed. You should normally call this method from the OnEnabled
 /// </summary>
 protected void SetupRoutine(RoutineDefinition routine)
 {
     TaskFactory.StartNew(() =>
     {
         if (routine.Execution == RoutineExecution.FixedUpdate && !FixedUpdateRoutines.ContainsKey(routine.Name))
         {
             if (routine.RunOnce)
             {
                 FixedUpdateRunOnceRoutines.TryAdd(routine.Name, routine);
             }
             else
             {
                 FixedUpdateRoutines.TryAdd(routine.Name, routine);
             }
         }
         else if (routine.Execution == RoutineExecution.Update && !UpdateRoutines.ContainsKey(routine.Name))
         {
             if (routine.RunOnce)
             {
                 UpdateRunOnceRoutines.TryAdd(routine.Name, routine);
             }
             else
             {
                 UpdateRoutines.TryAdd(routine.Name, routine);
             }
         }
         else if (routine.Execution == RoutineExecution.LateUpdate &&
                  !LateUpdateRoutines.ContainsKey(routine.Name))
         {
             if (routine.RunOnce)
             {
                 LateUpdateRunOnceRoutines.TryAdd(routine.Name, routine);
             }
             else
             {
                 LateUpdateRoutines.TryAdd(routine.Name, routine);
             }
         }
         else
         {
             LunaLog.LogError($"[LMP]: Routine {routine.Name} already defined");
         }
     });
 }
示例#2
0
 /// <summary>
 /// Changes the routine execution interval on the fly
 /// </summary>
 protected void ChangeRoutineExecutionInterval(string routineName, int newIntervalInMs)
 {
     TaskFactory.StartNew(() =>
     {
         if (FixedUpdateRoutines.ContainsKey(routineName))
         {
             FixedUpdateRoutines[routineName].IntervalInMs = newIntervalInMs;
         }
         else if (UpdateRoutines.ContainsKey(routineName))
         {
             UpdateRoutines[routineName].IntervalInMs = newIntervalInMs;
         }
         else if (LateUpdateRoutines.ContainsKey(routineName))
         {
             LateUpdateRoutines[routineName].IntervalInMs = newIntervalInMs;
         }
         else
         {
             LunaLog.LogError($"[LMP]: Routine {routineName} not defined");
         }
     });
 }