PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/Engine/Game/WaitProcess.cs

#
C# | 44 lines | 23 code | 2 blank | 19 comment | 0 complexity | feb34655e3c760de5fe1a119dce4d2dd MD5 | raw file
Possible License(s): Apache-2.0
  1. namespace Delta.Engine.Game
  2. {
  3. /// <summary>
  4. /// Simple process running as long as the wait time isn't exceeded.
  5. /// </summary>
  6. public class WaitProcess : BaseProcess
  7. {
  8. #region WaitTime (Public)
  9. /// <summary>
  10. /// How long to wait until this process is done, can be changed at any
  11. /// time. When this reaches 0, this process is killed and the next is
  12. /// invoked automatically.
  13. /// </summary>
  14. public float WaitTime;
  15. #endregion
  16. #region Constructors
  17. /// <summary>
  18. /// Create wait process and execute a certain process after the wait time
  19. /// is over.
  20. /// </summary>
  21. /// <param name="setWaitTime">How long to wait in seconds</param>
  22. /// <param name="setNextProcess">The next process to be executed once the
  23. /// wait time is over</param>
  24. public WaitProcess(float setWaitTime, BaseProcess setNextProcess)
  25. {
  26. WaitTime = setWaitTime;
  27. Next = setNextProcess;
  28. }
  29. #endregion
  30. #region Run (Public)
  31. /// <summary>
  32. /// Run is called for all active processes by the ProcessManager each tick
  33. /// </summary>
  34. /// <returns>True if the process finished, otherwise false.</returns>
  35. public override bool Run()
  36. {
  37. WaitTime -= Time.Delta;
  38. return WaitTime <= 0;
  39. }
  40. #endregion
  41. }
  42. }