/// <summary> /// 在初始化后会 Start里面会自动调用 /// </summary> /// <param name="self"></param> public static async void HandleAsync(this MailBoxComponent self) { ActorMessageDispatherComponent actorMessageDispatherComponent = Game.Scene.GetComponent <ActorMessageDispatherComponent>(); long instanceId = self.InstanceId; while (true) { if (self.InstanceId != instanceId) { return; } try { ActorMessageInfo info = await self.GetAsync(); // 返回null表示actor已经删除,协程要终止 if (info.Message == null) { return; } // 根据这个actor的类型分发给相应的ActorHandler处理 await actorMessageDispatherComponent.Handle(self, info); } catch (Exception e) { Log.Error(e); } } }
public static async void HandleAsync(this MailBoxComponent self) { ActorMessageDispatherComponent actorMessageDispatherComponent = Game.Scene.GetComponent <ActorMessageDispatherComponent>(); while (true) { if (self.IsDisposed) { return; } try { ActorMessageInfo info = await self.GetAsync(); // 返回null表示actor已经删除,协程要终止 if (info.Message == null) { return; } // 根据这个actor的类型分发给相应的ActorHandler处理 await actorMessageDispatherComponent.ActorTypeHandle(self.ActorType, (Entity)self.Parent, info); } catch (Exception e) { Log.Error(e); } } }