IEventDispatcher.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /**
  2. * The MIT License (MIT)
  3. *
  4. * Copyright (c) 2012-2017 DragonBones team and other contributors
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  7. * this software and associated documentation files (the "Software"), to deal in
  8. * the Software without restriction, including without limitation the rights to
  9. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10. * the Software, and to permit persons to whom the Software is furnished to do so,
  11. * subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all
  14. * copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. namespace DragonBones
  24. {
  25. public delegate void ListenerDelegate<T>(string type, T eventObject);
  26. /// <summary>
  27. /// - The event dispatcher interface.
  28. /// Dragonbones event dispatch usually relies on docking engine to implement, which defines the event method to be implemented when docking the engine.
  29. /// </summary>
  30. /// <version>DragonBones 4.5</version>
  31. /// <language>en_US</language>
  32. /// <summary>
  33. /// - 事件派发接口。
  34. /// DragonBones 的事件派发通常依赖于对接的引擎来实现,该接口定义了对接引擎时需要实现的事件方法。
  35. /// </summary>
  36. /// <version>DragonBones 4.5</version>
  37. /// <language>zh_CN</language>
  38. public interface IEventDispatcher<T>
  39. {
  40. /// <summary>
  41. /// - Checks whether the object has any listeners registered for a specific type of event。
  42. /// </summary>
  43. /// <param name="type">- Event type.</param>
  44. /// <version>DragonBones 4.5</version>
  45. /// <language>en_US</language>
  46. /// <summary>
  47. /// - 检查是否为特定的事件类型注册了任何侦听器。
  48. /// </summary>
  49. /// <param name="type">- 事件类型。</param>
  50. /// <version>DragonBones 4.5</version>
  51. /// <language>zh_CN</language>
  52. bool HasDBEventListener(string type);
  53. /// <summary>
  54. /// - Dispatches an event into the event flow.
  55. /// </summary>
  56. /// <param name="type">- Event type.</param>
  57. /// <param name="eventObject">- Event object.</param>
  58. /// <see cref="DragonBones.EventObject"/>
  59. /// <version>DragonBones 4.5</version>
  60. /// <language>en_US</language>
  61. /// <summary>
  62. /// - 分派特定的事件到事件流中。
  63. /// </summary>
  64. /// <param name="type">- 事件类型。</param>
  65. /// <param name="eventObject">- 事件数据。</param>
  66. /// <see cref="DragonBones.EventObject"/>
  67. /// <version>DragonBones 4.5</version>
  68. /// <language>zh_CN</language>
  69. void DispatchDBEvent(string type, T eventObject);
  70. /// <summary>
  71. /// - Add an event listener object so that the listener receives notification of an event.
  72. /// </summary>
  73. /// <param name="type">- Event type.</param>
  74. /// <param name="listener">- Event listener.</param>
  75. /// <param name="thisObject">- The listener function's "this".</param>
  76. /// <version>DragonBones 4.5</version>
  77. /// <language>en_US</language>
  78. /// <summary>
  79. /// - 添加特定事件类型的事件侦听器,以使侦听器能够接收事件通知。
  80. /// </summary>
  81. /// <param name="type">- 事件类型。</param>
  82. /// <param name="listener">- 事件侦听器。</param>
  83. /// <param name="thisObject">- 侦听函数绑定的 this 对象。</param>
  84. /// <version>DragonBones 4.5</version>
  85. /// <language>zh_CN</language>
  86. void AddDBEventListener(string type, ListenerDelegate<T> listener);
  87. /// <summary>
  88. /// - Removes a listener from the object.
  89. /// </summary>
  90. /// <param name="type">- Event type.</param>
  91. /// <param name="listener">- Event listener.</param>
  92. /// <param name="thisObject">- The listener function's "this".</param>
  93. /// <version>DragonBones 4.5</version>
  94. /// <language>en_US</language>
  95. /// <summary>
  96. /// - 删除特定事件类型的侦听器。
  97. /// </summary>
  98. /// <param name="type">- 事件类型。</param>
  99. /// <param name="listener">- 事件侦听器。</param>
  100. /// <param name="thisObject">- 侦听函数绑定的 this 对象。</param>
  101. /// <version>DragonBones 4.5</version>
  102. /// <language>zh_CN</language>
  103. void RemoveDBEventListener(string type, ListenerDelegate<T> listener);
  104. }
  105. }