PageRenderTime 53ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/Engine/Game/BaseProcess.cs

#
C# | 44 lines | 21 code | 3 blank | 20 comment | 0 complexity | d6840e457cf46f00f818dfdeecc618e7 MD5 | raw file
Possible License(s): Apache-2.0
  1. namespace Delta.Engine.Game
  2. {
  3. /// <summary>
  4. /// Base class for all processes, defines what all processes can do.
  5. /// Basically they all have a Run method and can be active (then Run is
  6. /// called) or not (then they needed to be activated).
  7. /// </summary>
  8. public abstract class BaseProcess
  9. {
  10. #region IsActive (Public)
  11. /// <summary>
  12. /// Is this process active? Run is only called if this is true, inactive
  13. /// processes just sit there waiting to be killed or re-activated.
  14. /// </summary>
  15. public bool IsActive = true;
  16. #endregion
  17. #region Next (Public)
  18. /// <summary>
  19. /// Next process if this one is finished. Automatically made active if
  20. /// this process ends (once Run returns true).
  21. /// </summary>
  22. public BaseProcess Next;
  23. #endregion
  24. #region Constructors
  25. /// <summary>
  26. /// Initializes a new instance of the <see cref="BaseProcess"/> class.
  27. /// </summary>
  28. public BaseProcess()
  29. {
  30. ProcessManager.Instance.processes.Add(this);
  31. }
  32. #endregion
  33. #region Run (Public)
  34. /// <summary>
  35. /// Run is called for all active processes by the ProcessManager each tick
  36. /// </summary>
  37. /// <returns>True if the process finished, otherwise false.</returns>
  38. public abstract bool Run();
  39. #endregion
  40. }
  41. }