コード例 #1
0
        /// <summary>
        /// Changes the routine execution interval on the fly
        /// </summary>
        protected void ChangeRoutineExecutionInterval(string routineName, int newIntervalInMs)
        {
            var routine = FixedUpdateRoutines.FirstOrDefault(r => r.Name == routineName);

            if (routine != null)
            {
                routine.IntervalInMs = newIntervalInMs;
                return;
            }

            routine = UpdateRoutines.FirstOrDefault(r => r.Name == routineName);
            if (routine != null)
            {
                routine.IntervalInMs = newIntervalInMs;
                return;
            }

            routine = LateUpdateRoutines.FirstOrDefault(r => r.Name == routineName);
            if (routine != null)
            {
                routine.IntervalInMs = newIntervalInMs;
                return;
            }

            LunaLog.LogError($"[LMP]: Routine {routineName} not defined");
        }
コード例 #2
0
        /// <summary>
        /// Setups a routine that will be executed. You should normally call this method from the OnEnabled
        /// </summary>
        protected void SetupRoutine(RoutineDefinition routine)
        {
            if (routine == null)
            {
                LunaLog.LogError($"[LMP]: Cannot set a null routine!");
                return;
            }

            if (routine.Execution == RoutineExecution.FixedUpdate && !FixedUpdateRoutines.Any(r => r.Name == routine.Name))
            {
                FixedUpdateRoutines.Add(routine);
            }
            else if (routine.Execution == RoutineExecution.Update && !UpdateRoutines.Any(r => r.Name == routine.Name))
            {
                UpdateRoutines.Add(routine);
            }
            else if (routine.Execution == RoutineExecution.LateUpdate && !LateUpdateRoutines.Any(r => r.Name == routine.Name))
            {
                LateUpdateRoutines.Add(routine);
            }
            else
            {
                LunaLog.LogError($"[LMP]: Routine {routine.Name} already defined");
            }
        }
コード例 #3
0
        /// <summary>
        /// Changes the routine execution interval on the fly
        /// </summary>
        protected void ChangeRoutineExecutionInterval(RoutineExecution execution, string routineName, int newIntervalInMs)
        {
            RoutineDefinition routine;

            switch (execution)
            {
            case RoutineExecution.FixedUpdate:
                routine = FixedUpdateRoutines.FirstOrDefault(r => r.Name == routineName);
                break;

            case RoutineExecution.Update:
                routine = UpdateRoutines.FirstOrDefault(r => r.Name == routineName);
                break;

            case RoutineExecution.LateUpdate:
                routine = LateUpdateRoutines.FirstOrDefault(r => r.Name == routineName);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(execution), execution, null);
            }

            if (routine != null)
            {
                routine.IntervalInMs = newIntervalInMs;
            }
            else
            {
                LunaLog.LogError($"[LMP]: Routine {execution}/{routineName} not defined");
            }
        }
コード例 #4
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");
         }
     });
 }
コード例 #5
0
ファイル: System.cs プロジェクト: Fierce-Cat/LunaMultiPlayer
 /// <summary>
 /// Changes the routine execution interval on the fly
 /// </summary>
 protected void ChangeRoutineExecutionInterval(string routineName, int newIntervalInMs)
 {
     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");
     }
 }
コード例 #6
0
ファイル: System.cs プロジェクト: Fierce-Cat/LunaMultiPlayer
 /// <summary>
 /// Setups a routine that will be executed. You should normally call this method from the OnEnabled
 /// </summary>
 protected void SetupRoutine(RoutineDefinition routine)
 {
     if (routine.Execution == RoutineExecution.FixedUpdate && !FixedUpdateRoutines.ContainsKey(routine.Name))
     {
         FixedUpdateRoutines.Add(routine.Name, routine);
     }
     else if (routine.Execution == RoutineExecution.Update && !UpdateRoutines.ContainsKey(routine.Name))
     {
         UpdateRoutines.Add(routine.Name, routine);
     }
     else if (routine.Execution == RoutineExecution.LateUpdate && !LateUpdateRoutines.ContainsKey(routine.Name))
     {
         LateUpdateRoutines.Add(routine.Name, routine);
     }
     else
     {
         LunaLog.LogError($"[LMP]: Routine {routine.Name} already defined");
     }
 }