IEvent.cs 644 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. namespace ET
  3. {
  4. public interface IEvent
  5. {
  6. Type Type { get; }
  7. }
  8. public abstract class AEvent<A>: IEvent where A: struct
  9. {
  10. public Type Type
  11. {
  12. get
  13. {
  14. return typeof (A);
  15. }
  16. }
  17. protected abstract ETTask Run(Scene scene, A a);
  18. public async ETTask Handle(Scene scene, A a)
  19. {
  20. try
  21. {
  22. await Run(scene, a);
  23. }
  24. catch (Exception e)
  25. {
  26. Log.Error(e);
  27. }
  28. }
  29. }
  30. public abstract class BEvent<A>: IEvent
  31. {
  32. public Type Type
  33. {
  34. get
  35. {
  36. return typeof(A);
  37. }
  38. }
  39. public abstract void OnEvent(A a);
  40. }
  41. }