ModulePriority.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. namespace IFramework
  2. {
  3. /// <summary>
  4. /// 默认的模块的优先级
  5. /// </summary>
  6. public struct ModulePriority:IValueContainer<int>
  7. {
  8. /// <summary>
  9. /// 配置表
  10. /// </summary>
  11. public const int Config = 0;
  12. /// <summary>
  13. /// 环境等待
  14. /// </summary>
  15. public const int Loom = 10;
  16. /// <summary>
  17. /// undo
  18. /// </summary>
  19. public const int Recorder = 30;
  20. /// <summary>
  21. /// 协程
  22. /// </summary>
  23. public const int Coroutine = 70;
  24. /// <summary>
  25. /// 消息转发
  26. /// </summary>
  27. public const int Message = 120;
  28. /// <summary>
  29. /// ecs
  30. /// </summary>
  31. public const int ECS = 400;
  32. /// <summary>
  33. /// fsm
  34. /// </summary>
  35. public const int FSM = 500;
  36. /// <summary>
  37. /// 计时器
  38. /// </summary>
  39. public const int Timer = 600;
  40. /// <summary>
  41. /// 其他
  42. /// </summary>
  43. public const int Custom = 1000;
  44. private int _value;
  45. /// <summary>
  46. /// ctor
  47. /// </summary>
  48. /// <param name="value"></param>
  49. public ModulePriority(int value)
  50. {
  51. _value = value;
  52. }
  53. /// <summary>
  54. /// 具体的值
  55. /// </summary>
  56. public int value { get { return _value; }set { _value = value; } }
  57. /// <summary>
  58. ///
  59. /// </summary>
  60. /// <param name="value"></param>
  61. /// <returns></returns>
  62. public static ModulePriority FromValue(int value)
  63. {
  64. return new ModulePriority(value);
  65. }
  66. /// <summary>
  67. ///
  68. /// </summary>
  69. /// <param name="value"></param>
  70. public static implicit operator int(ModulePriority value)
  71. {
  72. return value.value;
  73. }
  74. /// <summary>
  75. ///
  76. /// </summary>
  77. /// <param name="value"></param>
  78. public static implicit operator ModulePriority(int value)
  79. {
  80. return new ModulePriority(value);
  81. }
  82. /// <summary>
  83. ///
  84. /// </summary>
  85. /// <param name="a"></param>
  86. /// <param name="b"></param>
  87. /// <returns></returns>
  88. public static ModulePriority operator +(ModulePriority a, ModulePriority b)
  89. {
  90. return new ModulePriority(a.value + b.value);
  91. }
  92. /// <summary>
  93. ///
  94. /// </summary>
  95. /// <param name="a"></param>
  96. /// <param name="b"></param>
  97. /// <returns></returns>
  98. public static ModulePriority operator -(ModulePriority a, ModulePriority b)
  99. {
  100. return new ModulePriority(a.value - b.value);
  101. }
  102. }
  103. }