MailBoxComponentSystem.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using ETModel;
  3. namespace ETHotfix
  4. {
  5. [ObjectSystem]
  6. public class MailBoxComponentAwakeSystem : AwakeSystem<MailBoxComponent>
  7. {
  8. public override void Awake(MailBoxComponent self)
  9. {
  10. self.MailboxType = MailboxType.MessageDispatcher;
  11. }
  12. }
  13. [ObjectSystem]
  14. public class MailBoxComponentAwake1System : AwakeSystem<MailBoxComponent, string>
  15. {
  16. public override void Awake(MailBoxComponent self, string mailboxType)
  17. {
  18. self.MailboxType = mailboxType;
  19. }
  20. }
  21. /// <summary>
  22. /// 挂上这个组件表示该Entity是一个Actor, 接收的消息将会队列处理
  23. /// </summary>
  24. public static class MailBoxComponentHelper
  25. {
  26. public static async ETTask AddLocation(this MailBoxComponent self)
  27. {
  28. await Game.Scene.GetComponent<LocationProxyComponent>().Add(self.Entity.Id, self.Entity.InstanceId);
  29. }
  30. public static async ETTask RemoveLocation(this MailBoxComponent self)
  31. {
  32. await Game.Scene.GetComponent<LocationProxyComponent>().Remove(self.Entity.Id);
  33. }
  34. public static async ETTask Add(this MailBoxComponent self, Session session, object message)
  35. {
  36. MailboxDispatcherComponent mailboxDispatcherComponent = Game.Scene.GetComponent<MailboxDispatcherComponent>();
  37. await mailboxDispatcherComponent.Handle(self, session, message);
  38. }
  39. }
  40. }