public static void Update() { if (!bInit) { return; } InvalidList.Clear(); U3D_Render.EntityView view; foreach (TopName var in m_TopNameMap.Values) { TopName tn = var; view = EntityFactory.getEntityViewByID(tn.ID); if (view == null) { InvalidList.Enqueue(tn); continue; } if (!tn.Entry)//实体被删除 { InvalidList.Enqueue(tn); continue; } if (!tn.Entry.activeSelf || !view.StateMachine.GetVisible())//实体没有被激活或者不可见 { if (tn.GetEnable()) { tn.SetEnable(false); } } else//正常的实体 { if (!tn.GetEnable()) { tn.SetEnable(true); } tn.OnUpdate(); } } while (InvalidList.Count > 0) { //移除无效的TopName节点 TopName b = InvalidList.Dequeue(); if (OptimitzedControlPlane.Instance.EnityCreateOptimize) { CacheTopName(b); } else { TopNameManager.Destroy(b); } } InvalidList.Clear(); }
/// <summary> /// 一般更新 /// </summary> private static void NormalUpdate() { InvalidList.Clear(); if (null != m_BloodMap) { foreach (GfxBlood var in m_BloodMap.Values) { GfxBlood gba = var; U3D_Render.EntityView view = EntityFactory.getEntityViewByID(gba.ID); if (view == null) { InvalidList.Enqueue(gba); continue; } if (!gba.Entry) { InvalidList.Enqueue(gba); continue; } if (!gba.Entry.activeSelf || !view.StateMachine.GetVisible())//实体没有被激活或者不可见 { if (gba.GetEnable()) { gba.SetEnable(false); } } else//正常的实体 { if (!gba.GetEnable()) { gba.SetEnable(true); } gba.OnUpdate(); } } } while (InvalidList.Count > 0) { //移除无效的Blood节点 GfxBlood b = InvalidList.Dequeue(); if (OptimitzedControlPlane.Instance.EnityCreateOptimize) { CacheBlood(b); } else { GfxBloodManager.Destroy(b); } } InvalidList.Clear(); }
private Faculty() { Messenger.Default.AddListener <Student>(Messages.ModelSelected, s => { if (s.Level != Departments.Faculty) { return; } var students = Student.Cache.Where(Filter).ToList(); bool?sel = null; foreach (var student in students) { if (sel == null) { sel = student.IsSelected; } else { if (sel != student.IsSelected) { sel = null; break; } } } _SelectionState = sel; OnPropertyChanged(nameof(SelectionState)); OnPropertyChanged(nameof(HasSelected)); }); Messenger.Default.AddListener <int>(Messages.ScreenChanged, screen => { if (screen == MainViewModel.FACULTY) { RfidScanner.ExclusiveCallback = ScanCallback; } else { IsDialogOpen = false; InvalidList.ForEach(x => x.Reset()); InvalidList.Clear(); } }); Messenger.Default.AddListener <Student>(Messages.BeginAddStudent, student => { if (MainViewModel.Instance.Screen == MainViewModel.FACULTY) { student.Level = Departments.Faculty; } }); Messenger.Default.AddListener <Student>(Messages.CommitError, student => { if (MainViewModel.Instance.Screen != MainViewModel.FACULTY) { return; } if (student.Id == 0 && string.IsNullOrEmpty(student.Firstname) && string.IsNullOrEmpty(student.Lastname) && string.IsNullOrEmpty(student.ContactNumber)) { Student.Cache.Remove(student); } else { InvalidList.Add(student); //MessageDialog.Show("INVALID DATA", student.GetLastError(), PackIconKind.Alert, "OKAY"); MainViewModel.ShowMessage($"INVALID DATA: {student.GetLastError()}", null, null); } }); }