public void GoBack(GoBackRequestEvent e, Node any, [JoinAll] NavigationNode navigationNode, [JoinAll] ScreenNode screen) { if (navigationNode.history.screens.Count > 0) { ShowScreenData showScreenData = navigationNode.history.screens.Peek(); ScreensRegistryComponent screensRegistry = navigationNode.screensRegistry; GameObject nonActiveScreen = this.GetNonActiveScreen(showScreenData.ScreenType, screensRegistry); if (nonActiveScreen != null) { OverrideGoBack component = nonActiveScreen.GetComponent <OverrideGoBack>(); if (component != null) { showScreenData = component.ScreenData; nonActiveScreen = this.GetNonActiveScreen(showScreenData.ScreenType, screensRegistry); } base.ScheduleEvent <GoBackEvent>(any.Entity); navigationNode.history.screens.Pop(); CurrentScreenComponent currentScreen = navigationNode.currentScreen; if (currentScreen.showScreenData.Context != null) { currentScreen.showScreenData.Context.RemoveComponent <ScreenGroupComponent>(); } currentScreen.screen.RemoveComponent <ActiveScreenComponent>(); currentScreen.screen.AddComponent <ScreenHidingComponent>(); currentScreen.showScreenData.FreeContext(); this.ActivateShowingScreen(nonActiveScreen, this.GetActiveScreen(currentScreen.showScreenData.ScreenType, navigationNode.screensRegistry), showScreenData, currentScreen); base.NewEvent <PostGoBackEvent>().Attach(navigationNode).ScheduleDelayed(0f); } } }
private GameObject GetScreen(Type screenType, ScreensRegistryComponent screens, bool active) { GameObject obj3; using (List <GameObject> .Enumerator enumerator = screens.screens.GetEnumerator()) { while (true) { if (enumerator.MoveNext()) { GameObject current = enumerator.Current; if ((current.GetComponent(screenType) == null) || (current.activeSelf != active)) { continue; } obj3 = current; } else { return(null); } break; } } return(obj3); }
private void TryShowScreen(NavigationRequestNode navigationNode) { ShowScreenData showScreenData = navigationNode.requestShowScreen.Event.ShowScreenData; ScreensRegistryComponent screensRegistry = navigationNode.screensRegistry; GameObject nonActiveScreen = this.GetNonActiveScreen(showScreenData.ScreenType, screensRegistry); if (nonActiveScreen == null) { if (this.GetActiveScreen(showScreenData.ScreenType, screensRegistry) != null) { navigationNode.Entity.RemoveComponent <RequestShowScreenComponent>(); } else { base.Log.WarnFormat("Skip remove RequestShowScreenComponent {0}", navigationNode.requestShowScreen.Event.ShowScreenData.ScreenType.Name); } } else { navigationNode.Entity.RemoveComponent <RequestShowScreenComponent>(); CurrentScreenComponent currentScreen = navigationNode.currentScreen; HistoryComponent history = navigationNode.history; GameObject hidingScreen = null; if (currentScreen.screen != null) { hidingScreen = this.GetActiveScreen(currentScreen.showScreenData.ScreenType, navigationNode.screensRegistry); currentScreen.screen.RemoveComponent <ActiveScreenComponent>(); currentScreen.screen.AddComponent <ScreenHidingComponent>(); if (hidingScreen.GetComponent <ScreenComponent>().LogInHistory) { ShowScreenData t = currentScreen.showScreenData.InvertAnimationDirection(showScreenData.AnimationDirection); Stack <ShowScreenData> screens = history.screens; if ((screens.Count > 0) && ReferenceEquals(screens.Peek().ScreenType, t.ScreenType)) { screens.Pop(); } screens.Push(t); if (t.Context != null) { t.Context.RemoveComponent <ScreenGroupComponent>(); } } } this.ActivateShowingScreen(nonActiveScreen, hidingScreen, showScreenData, currentScreen); } }
private GameObject GetNonActiveScreen(Type screenType, ScreensRegistryComponent screens) => this.GetScreen(screenType, screens, false);