ShowEntityFailureEventArgs.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 GameFramework;
  8. using GameFramework.Event;
  9. using System;
  10. namespace UnityGameFramework.Runtime
  11. {
  12. /// <summary>
  13. /// 显示实体失败事件。
  14. /// </summary>
  15. public sealed class ShowEntityFailureEventArgs : GameEventArgs
  16. {
  17. /// <summary>
  18. /// 显示实体失败事件编号。
  19. /// </summary>
  20. public static readonly int EventId = typeof(ShowEntityFailureEventArgs).GetHashCode();
  21. /// <summary>
  22. /// 初始化显示实体失败事件的新实例。
  23. /// </summary>
  24. public ShowEntityFailureEventArgs()
  25. {
  26. EntityId = 0;
  27. EntityLogicType = null;
  28. EntityAssetName = null;
  29. EntityGroupName = null;
  30. ErrorMessage = null;
  31. UserData = null;
  32. }
  33. /// <summary>
  34. /// 获取显示实体失败事件编号。
  35. /// </summary>
  36. public override int Id
  37. {
  38. get
  39. {
  40. return EventId;
  41. }
  42. }
  43. /// <summary>
  44. /// 获取实体编号。
  45. /// </summary>
  46. public int EntityId
  47. {
  48. get;
  49. private set;
  50. }
  51. /// <summary>
  52. /// 获取实体逻辑类型。
  53. /// </summary>
  54. public Type EntityLogicType
  55. {
  56. get;
  57. private set;
  58. }
  59. /// <summary>
  60. /// 获取实体资源名称。
  61. /// </summary>
  62. public string EntityAssetName
  63. {
  64. get;
  65. private set;
  66. }
  67. /// <summary>
  68. /// 获取实体组名称。
  69. /// </summary>
  70. public string EntityGroupName
  71. {
  72. get;
  73. private set;
  74. }
  75. /// <summary>
  76. /// 获取错误信息。
  77. /// </summary>
  78. public string ErrorMessage
  79. {
  80. get;
  81. private set;
  82. }
  83. /// <summary>
  84. /// 获取用户自定义数据。
  85. /// </summary>
  86. public object UserData
  87. {
  88. get;
  89. private set;
  90. }
  91. /// <summary>
  92. /// 创建显示实体失败事件。
  93. /// </summary>
  94. /// <param name="e">内部事件。</param>
  95. /// <returns>创建的显示实体失败事件。</returns>
  96. public static ShowEntityFailureEventArgs Create(GameFramework.Entity.ShowEntityFailureEventArgs e)
  97. {
  98. ShowEntityInfo showEntityInfo = (ShowEntityInfo)e.UserData;
  99. ShowEntityFailureEventArgs showEntityFailureEventArgs = ReferencePool.Acquire<ShowEntityFailureEventArgs>();
  100. showEntityFailureEventArgs.EntityId = e.EntityId;
  101. showEntityFailureEventArgs.EntityLogicType = showEntityInfo.EntityLogicType;
  102. showEntityFailureEventArgs.EntityAssetName = e.EntityAssetName;
  103. showEntityFailureEventArgs.EntityGroupName = e.EntityGroupName;
  104. showEntityFailureEventArgs.ErrorMessage = e.ErrorMessage;
  105. showEntityFailureEventArgs.UserData = showEntityInfo.UserData;
  106. ReferencePool.Release(showEntityInfo);
  107. return showEntityFailureEventArgs;
  108. }
  109. /// <summary>
  110. /// 清理显示实体失败事件。
  111. /// </summary>
  112. public override void Clear()
  113. {
  114. EntityId = 0;
  115. EntityLogicType = null;
  116. EntityAssetName = null;
  117. EntityGroupName = null;
  118. ErrorMessage = null;
  119. UserData = null;
  120. }
  121. }
  122. }