ObjectInfo.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //------------------------------------------------------------
  2. // Game Framework
  3. // Copyright © 2013-2021 loyalsoft. All rights reserved.
  4. // Homepage: http://www.game7000.com/
  5. // Feedback: http://www.game7000.com/
  6. //------------------------------------------------------------
  7. using System;
  8. using System.Runtime.InteropServices;
  9. namespace GameFramework.ObjectPool
  10. {
  11. /// <summary>
  12. /// 对象信息。
  13. /// </summary>
  14. [StructLayout(LayoutKind.Auto)]
  15. public struct ObjectInfo
  16. {
  17. private readonly string m_Name;
  18. private readonly bool m_Locked;
  19. private readonly bool m_CustomCanReleaseFlag;
  20. private readonly int m_Priority;
  21. private readonly DateTime m_LastUseTime;
  22. private readonly int m_SpawnCount;
  23. /// <summary>
  24. /// 初始化对象信息的新实例。
  25. /// </summary>
  26. /// <param name="name">对象名称。</param>
  27. /// <param name="locked">对象是否被加锁。</param>
  28. /// <param name="customCanReleaseFlag">对象自定义释放检查标记。</param>
  29. /// <param name="priority">对象的优先级。</param>
  30. /// <param name="lastUseTime">对象上次使用时间。</param>
  31. /// <param name="spawnCount">对象的获取计数。</param>
  32. public ObjectInfo(string name, bool locked, bool customCanReleaseFlag, int priority, DateTime lastUseTime, int spawnCount)
  33. {
  34. m_Name = name;
  35. m_Locked = locked;
  36. m_CustomCanReleaseFlag = customCanReleaseFlag;
  37. m_Priority = priority;
  38. m_LastUseTime = lastUseTime;
  39. m_SpawnCount = spawnCount;
  40. }
  41. /// <summary>
  42. /// 获取对象名称。
  43. /// </summary>
  44. public string Name
  45. {
  46. get
  47. {
  48. return m_Name;
  49. }
  50. }
  51. /// <summary>
  52. /// 获取对象是否被加锁。
  53. /// </summary>
  54. public bool Locked
  55. {
  56. get
  57. {
  58. return m_Locked;
  59. }
  60. }
  61. /// <summary>
  62. /// 获取对象自定义释放检查标记。
  63. /// </summary>
  64. public bool CustomCanReleaseFlag
  65. {
  66. get
  67. {
  68. return m_CustomCanReleaseFlag;
  69. }
  70. }
  71. /// <summary>
  72. /// 获取对象的优先级。
  73. /// </summary>
  74. public int Priority
  75. {
  76. get
  77. {
  78. return m_Priority;
  79. }
  80. }
  81. /// <summary>
  82. /// 获取对象上次使用时间。
  83. /// </summary>
  84. public DateTime LastUseTime
  85. {
  86. get
  87. {
  88. return m_LastUseTime;
  89. }
  90. }
  91. /// <summary>
  92. /// 获取对象是否正在使用。
  93. /// </summary>
  94. public bool IsInUse
  95. {
  96. get
  97. {
  98. return m_SpawnCount > 0;
  99. }
  100. }
  101. /// <summary>
  102. /// 获取对象的获取计数。
  103. /// </summary>
  104. public int SpawnCount
  105. {
  106. get
  107. {
  108. return m_SpawnCount;
  109. }
  110. }
  111. }
  112. }