public async ETTask Handle(Entity entity, object actorMessage, Action <IActorResponse> reply) { Message msg = actorMessage as Message; if (msg == null) { Log.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Message).Name}"); return; } E e = entity as E; if (e == null) { Log.Error($"Actor类型转换错误: {entity.GetType().Name} to {typeof (E).Name} --{typeof (Message).Name}"); return; } await this.Run(e, msg); }
public static void BeforeOnDestroy(this Entity self) { var keys1 = self.GetCompoennts().Keys.ToList(); for (int i = keys1.Count - 1; i >= 0; i--) { if (self.GetCompoennts()[keys1[i]] != null) { var keys2 = self.GetCompoennts()[keys1[i]].Keys.ToList(); for (int j = keys2.Count - 1; j >= 0; j--) { var component = self.GetCompoennts()[keys1[i]][keys2[j]]; component.BeforeOnDestroy(); UIEventSystem.Instance.OnDestroy(component); } } } self.SetLength(self.GetLength() - 1); if (self.GetLength() <= 0) { if (UIManagerComponent.Instance.pathMap.TryGetValue(self.Id, out var path)) { self.Parent.InnerRemoveUIComponent(self, path); } else { Log.Info("Close window here, type name: " + self.GetType().Name); } } else { Log.Error("OnDestroy fail, length != 0"); } UIManagerComponent.Instance.componentsMap.Remove(self.Id); UIManagerComponent.Instance.lengthMap.Remove(self.Id); UIManagerComponent.Instance.pathMap.Remove(self.Id); self.Dispose(); }
public void RegisterSystem(Entity component, bool isRegister = true) { if (!isRegister) { this.Remove(component.InstanceId); return; } this.allEntities.Add(component.InstanceId, component); Type type = component.GetType(); OneTypeSystems oneTypeSystems = this.typeSystems.GetOneTypeSystems(type);; if (component is ILoad) { if (oneTypeSystems.ContainsKey(typeof(ILoadSystem))) { this.loaders.Enqueue(component.InstanceId); } } if (component is IUpdate) { if (oneTypeSystems.ContainsKey(typeof(IUpdateSystem))) { this.updates.Enqueue(component.InstanceId); } } if (component is ILateUpdate) { if (oneTypeSystems.ContainsKey(typeof(ILateUpdateSystem))) { this.lateUpdates.Enqueue(component.InstanceId); } } }
public static async ETTask CloseWindow(this UIManagerComponent self, Entity window) { string ui_name = window.GetType().Name; await self.CloseWindow(ui_name); }