ShowEntitySuccessEventArgs.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 ShowEntitySuccessEventArgs : GameEventArgs
  16. {
  17. /// <summary>
  18. /// 显示实体成功事件编号。
  19. /// </summary>
  20. public static readonly int EventId = typeof(ShowEntitySuccessEventArgs).GetHashCode();
  21. /// <summary>
  22. /// 初始化显示实体成功事件的新实例。
  23. /// </summary>
  24. public ShowEntitySuccessEventArgs()
  25. {
  26. EntityLogicType = null;
  27. Entity = null;
  28. Duration = 0f;
  29. UserData = null;
  30. }
  31. /// <summary>
  32. /// 获取显示实体成功事件编号。
  33. /// </summary>
  34. public override int Id
  35. {
  36. get
  37. {
  38. return EventId;
  39. }
  40. }
  41. /// <summary>
  42. /// 获取实体逻辑类型。
  43. /// </summary>
  44. public Type EntityLogicType
  45. {
  46. get;
  47. private set;
  48. }
  49. /// <summary>
  50. /// 获取显示成功的实体。
  51. /// </summary>
  52. public Entity Entity
  53. {
  54. get;
  55. private set;
  56. }
  57. /// <summary>
  58. /// 获取加载持续时间。
  59. /// </summary>
  60. public float Duration
  61. {
  62. get;
  63. private set;
  64. }
  65. /// <summary>
  66. /// 获取用户自定义数据。
  67. /// </summary>
  68. public object UserData
  69. {
  70. get;
  71. private set;
  72. }
  73. /// <summary>
  74. /// 创建显示实体成功事件。
  75. /// </summary>
  76. /// <param name="e">内部事件。</param>
  77. /// <returns>创建的显示实体成功事件。</returns>
  78. public static ShowEntitySuccessEventArgs Create(GameFramework.Entity.ShowEntitySuccessEventArgs e)
  79. {
  80. ShowEntityInfo showEntityInfo = (ShowEntityInfo)e.UserData;
  81. ShowEntitySuccessEventArgs showEntitySuccessEventArgs = ReferencePool.Acquire<ShowEntitySuccessEventArgs>();
  82. showEntitySuccessEventArgs.EntityLogicType = showEntityInfo.EntityLogicType;
  83. showEntitySuccessEventArgs.Entity = (Entity)e.Entity;
  84. showEntitySuccessEventArgs.Duration = e.Duration;
  85. showEntitySuccessEventArgs.UserData = showEntityInfo.UserData;
  86. ReferencePool.Release(showEntityInfo);
  87. return showEntitySuccessEventArgs;
  88. }
  89. /// <summary>
  90. /// 清理显示实体成功事件。
  91. /// </summary>
  92. public override void Clear()
  93. {
  94. EntityLogicType = null;
  95. Entity = null;
  96. Duration = 0f;
  97. UserData = null;
  98. }
  99. }
  100. }