/// <summary> /// Constructor method for the Stepper class. /// </summary> /// <param name="_stepValue">Execution frequency for this stepper. Default (1) means every frame</param> /// <param name="callback">Name of method to be called. Should be provided as the method name, i.e. MethodName, not "MethodName" or MethodName()</param> /// <param name="_stepperQueuePrompt">Where to place the stepper in the scheduler queue, using StepperQueueOrder values (EARLY, NORMAL, LATE)</param> /// <param name="_owner">The agent this stepper belongs to</param> public Stepper(int _stepValue, Utilities.Del callback, StepperQueueOrder _stepperQueuePrompt, Steppable _owner) { _step = _stepValue; funcToCall = callback; _stepperQueue = _stepperQueuePrompt; _name = callback.Method.Name; _startFrame = Time.frameCount; owner = _owner; switch (stepperQueue) { case StepperQueueOrder.EARLY: _priority = 166; break; case StepperQueueOrder.NORMAL: _priority = 500; break; case StepperQueueOrder.LATE: _priority = 833; break; default: _priority = 500; break; } }
/// <summary> /// Delayed registration of stepper /// </summary> /// <param name="_delayStartByFrames">The number of frames to delay stepper registration by</param> /// <param name="_stepValue">The stepper step value, to be used for the actual stepper registration</param> /// <param name="callback">Name of the stepper callback method</param> /// <param name="_stepperQueuePrompt">The stepper stepperQueue slot, to be used for the actual stepper registration</param> /// <returns>null, standard Coroutine return value</returns> IEnumerator CreateStepperAfterFrames(int _delayStartByFrames, int _stepValue, Utilities.Del callback, Stepper.StepperQueueOrder _stepperQueuePrompt) { int frameToRegisterOn = Time.frameCount + _delayStartByFrames; while (Time.frameCount < frameToRegisterOn) { yield return(null); } Stepper s = new Stepper(_stepValue, callback, _stepperQueuePrompt, this); RegisterStepper(s); }
/// <summary> /// Creates a stepper /// </summary> /// <param name="callback">Name of method to be called. Should be provided as the method name, i.e. MethodName, not "MethodName" or MethodName()</param> /// <param name="_stepValue">The stepper execution frequency, in positive integer values (min = default = 1)</param> /// <param name="_stepperQueuePrompt">Where to place the stepper in the scheduler queue, using StepperQueueOrder values (EARLY, NORMAL, LATE) (default = NORMAL)</param> /// <param name="_delayStartByFrames">The number of frames to delay stepper registration by (default = 0)</param> public void CreateStepper(Utilities.Del callback, int _stepValue = 1, Stepper.StepperQueueOrder _stepperQueuePrompt = Stepper.StepperQueueOrder.NORMAL, int _delayStartByFrames = 0) { if (_delayStartByFrames == 0) { Stepper s = new Stepper(_stepValue, callback, _stepperQueuePrompt, this); RegisterStepper(s); } else { StartCoroutine(CreateStepperAfterFrames(_delayStartByFrames, _stepValue, callback, _stepperQueuePrompt)); } }
/// <summary> /// Creates a stepper /// </summary> /// <param name="callback">Name of method to be called. Should be provided as the method name, i.e. MethodName, not "MethodName" or MethodName()</param> /// <param name="_stepValue">The stepper execution frequency, in positive integer values (min = default = 1)</param> /// <param name="_priorityValue">Where to place the stepper in the scheduler queue, using priority values (soft range 0-1000, lower is earlier)</param> /// <param name="_delayStartByFrames">The number of frames to delay stepper registration by (default = 0)</param> public void CreateStepper(Utilities.Del callback, int _stepValue = 1, int _priorityValue = 500, int _delayStartByFrames = 0) { if (_delayStartByFrames == 0) { Stepper s = new Stepper(_stepValue, callback, _priorityValue, this); RegisterStepper(s); } else { StartCoroutine(CreateStepperAfterFrames(_delayStartByFrames, _stepValue, callback, _priorityValue)); } }
/// <summary> /// Constructor method for the Stepper class. /// </summary> /// <param name="_stepValue">Execution frequency for this stepper. Default (1) means every frame</param> /// <param name="callback">Name of method to be called. Should be provided as the method name, i.e. MethodName, not "MethodName" or MethodName()</param> /// <param name="_priorityValue">Where to place the stepper in the scheduler queue, using priority values (soft range 0-1000, lower is earlier)</param> /// <param name="_owner">The agent this stepper belongs to</param> public Stepper(int _stepValue, Utilities.Del callback, int _priorityValue, Steppable _owner) { _step = _stepValue; funcToCall = callback; _priority = _priorityValue; _name = callback.Method.Name; _startFrame = Time.frameCount; owner = _owner; if (priority < 333) { _stepperQueue = Stepper.StepperQueueOrder.EARLY; } else if (priority < 666) { _stepperQueue = Stepper.StepperQueueOrder.NORMAL; } else { _stepperQueue = Stepper.StepperQueueOrder.LATE; } }
/// <summary> /// Creates a stepper /// </summary> /// <param name="callback">Name of method to be called. Should be provided as the method name, i.e. MethodName, not "MethodName" or MethodName()</param> /// <param name="_stepValue">The stepper execution frequency, in positive integer values (min = default = 1)</param> public void CreateStepper(Utilities.Del callback, int _stepValue) { CreateStepper(callback, _stepValue, 500, 0); }
/// <summary> /// Creates a stepper /// </summary> /// <param name="callback">Name of method to be called. Should be provided as the method name, i.e. MethodName, not "MethodName" or MethodName()</param> public void CreateStepper(Utilities.Del callback) { CreateStepper(callback, 1, 500, 0); }
/// <summary> /// Creates a stepper /// </summary> /// <param name="callback">Name of method to be called. Should be provided as the method name, i.e. MethodName, not "MethodName" or MethodName()</param> /// <param name="_stepValue">The stepper execution frequency, in positive integer values (min = default = 1)</param> /// <param name="_stepperQueuePrompt">Where to place the stepper in the scheduler queue, using StepperQueueOrder values (EARLY, NORMAL, LATE) (default = NORMAL)</param> public void CreateStepper(Utilities.Del callback, int _stepValue, Stepper.StepperQueueOrder _stepperQueuePrompt) { CreateStepper(callback, _stepValue, _stepperQueuePrompt, 0); }
/// <summary> /// Creates a stepper /// </summary> /// <param name="callback">Name of method to be called. Should be provided as the method name, i.e. MethodName, not "MethodName" or MethodName()</param> /// <param name="_stepValue">The stepper execution frequency, in positive integer values (min = default = 1)</param> /// <param name="_priorityValue">Where to place the stepper in the scheduler queue, using priority values (soft range 0-1000, lower is earlier)</param> public void CreateStepper(Utilities.Del callback, int _stepValue, int _priorityValue) { CreateStepper(callback, _stepValue, _priorityValue, 0); }