Advertisement
dimmpixeye

Untitled

Jun 9th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. namespace Homebrew
  2. {
  3. public class ProcessingUpdate : IDisposable
  4. {
  5. private List<ITick> ticks = new List<ITick>();
  6. private List<ITickFixed> ticksFixed = new List<ITickFixed>();
  7. private List<ITickLate> ticksLate = new List<ITickLate>();
  8.  
  9. public static ProcessingUpdate Default;
  10.  
  11. private int countTicks;
  12. private int countTicksFixed;
  13. private int countTicksLate;
  14.  
  15. public int GetTicksCount()
  16. {
  17. return countTicks;
  18. }
  19.  
  20. public ProcessingUpdate()
  21. {
  22. GameObject.Find("[KERNEL]").AddComponent<ComponentUpdate>().Setup(this);
  23. }
  24.  
  25. public void Add(object updateble)
  26. {
  27. if (updateble is ITick)
  28. ticks.Add(updateble as ITick);
  29.  
  30. if (updateble is ITickFixed)
  31. ticksFixed.Add(updateble as ITickFixed);
  32.  
  33. if (updateble is ITickLate)
  34. ticksLate.Add(updateble as ITickLate);
  35.  
  36. countTicks = ticks.Count;
  37. countTicksFixed = ticksFixed.Count;
  38. countTicksLate = ticksLate.Count;
  39. }
  40.  
  41. public void Remove(object updateble)
  42. {
  43. if (Toolbox.applicationIsQuitting) return;
  44.  
  45. if (updateble is ITick)
  46. ticks.Remove(updateble as ITick);
  47.  
  48. if (updateble is ITickFixed)
  49. ticksFixed.Remove(updateble as ITickFixed);
  50.  
  51. if (updateble is ITickLate)
  52. ticksLate.Remove(updateble as ITickLate);
  53.  
  54. countTicks = ticks.Count;
  55. countTicksFixed = ticksFixed.Count;
  56. countTicksLate = ticksLate.Count;
  57. }
  58.  
  59. public void Tick()
  60. {
  61. if (Toolbox.changingScene) return;
  62. for (var i = 0; i < countTicks; i++)
  63. {
  64. ticks[i].Tick();
  65. }
  66. }
  67.  
  68. public void TickFixed()
  69. {
  70. if (Toolbox.changingScene) return;
  71. for (var i = 0; i < countTicksFixed; i++)
  72. ticksFixed[i].TickFixed();
  73. }
  74.  
  75. public void TickLate()
  76. {
  77. if (Toolbox.changingScene) return;
  78. for (var i = 0; i < countTicksLate; i++)
  79. ticksLate[i].TickLate();
  80. }
  81.  
  82. public void Dispose()
  83. {
  84. countTicks = 0;
  85. countTicksFixed = 0;
  86. countTicksLate = 0;
  87. ticks.RemoveAll(t => t is IKernel == false);
  88. ticksFixed.Clear();
  89. ticksLate.Clear();
  90.  
  91. countTicks = ticks.Count;
  92.  
  93. }
  94.  
  95.  
  96. }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement