public void HardCancelTransition() { if (IsTransitioning || IsConnecting) { dispatcher.RemoveListener <WorldServiceEvents.SelfRoomJoinedEvent>(onSelfJoinedRoom); dispatcher.RemoveListener <SceneTransitionEvents.TransitionComplete>(onSceneLoadComplete); Service.Get <SceneTransitionService>().HardCancelTransition(); TransitionState = ZoneTransitionEvents.ZoneTransition.States.Cancel; IsConnecting = false; isCancelled = true; } }
private void Awake() { dispatcher = Service.Get <EventDispatcher>(); dataEntityCollection = Service.Get <CPDataEntityCollection>(); PreviousZone = ScriptableObject.CreateInstance <ZoneDefinition>(); CurrentZone = ScriptableObject.CreateInstance <ZoneDefinition>(); CurrentInstanceId = ""; IsTransitioning = false; IsConnecting = false; isCancelled = false; TransitionState = ZoneTransitionEvents.ZoneTransition.States.Done; dispatcher.AddListener <SceneTransitionEvents.SetIsTransitioningFlag>(onSetIsTransitioningFlag); }
public void CancelTransition(string sceneName = null) { if (IsTransitioning || IsConnecting) { dispatcher.RemoveListener <WorldServiceEvents.SelfRoomJoinedEvent>(onSelfJoinedRoom); dispatcher.RemoveListener <SceneTransitionEvents.TransitionComplete>(onSceneLoadComplete); Service.Get <SceneTransitionService>().CancelTransition(sceneName); TransitionState = ZoneTransitionEvents.ZoneTransition.States.Cancel; dispatcher.DispatchEvent(new ZoneTransitionEvents.ZoneTransition(CurrentZone.SceneName, sceneName, ZoneTransitionEvents.ZoneTransition.States.Cancel)); IsConnecting = false; isCancelled = true; checkIfZoneTransitionComplete(); } }
public void LoadZoneOffline(string sceneName, string transitionScene = null, string worldName = null, Dictionary <string, object> sceneArgs = null) { if (isSceneTransitionValid(sceneName)) { sceneTransition(sceneName, transitionScene, sceneArgs, allowSceneActivation: true); TransitionState = ZoneTransitionEvents.ZoneTransition.States.Request; dispatcher.DispatchEvent(new ZoneTransitionEvents.ZoneTransition(CurrentZone.SceneName, sceneName, ZoneTransitionEvents.ZoneTransition.States.Request)); PreviousZone = CurrentZone; CurrentZone = GetZoneBySceneName(sceneName); CurrentInstanceId = ""; IsConnecting = false; IsInIgloo = false; } }
private void checkIfZoneTransitionComplete() { if (!IsTransitioning && !IsConnecting) { TransitionState = ZoneTransitionEvents.ZoneTransition.States.Done; Crittercism.SetValue("previousZone", PreviousZone.SceneName); Crittercism.SetValue("currentZone", CurrentZone.SceneName); Crittercism.LeaveBreadcrumb($"Transitioned zone from '{PreviousZone.SceneName}' to '{CurrentZone.SceneName}'"); if (CurrentZone.Type == ZoneDefinition.ZoneType.Igloo) { checkIglooSceneStateDataExists(); } dispatcher.DispatchEvent(new ZoneTransitionEvents.ZoneTransition(PreviousZone.SceneName, CurrentZone.SceneName, ZoneTransitionEvents.ZoneTransition.States.Done)); Service.Get <LoadingController>().RemoveLoadingSystem(this); isCancelled = false; } }
private void sceneTransition(string sceneName, string transitionScene, Dictionary <string, object> sceneArgs = null, bool allowSceneActivation = false) { Time.timeScale = 1f; LoadingController loadingController = Service.Get <LoadingController>(); if (!loadingController.HasLoadingSystem(this)) { loadingController.AddLoadingSystem(this); } if (string.IsNullOrEmpty(transitionScene)) { transitionScene = "Loading"; } TransitionState = ZoneTransitionEvents.ZoneTransition.States.Begin; dispatcher.DispatchEvent(new ZoneTransitionEvents.ZoneTransition(CurrentZone.SceneName, sceneName, ZoneTransitionEvents.ZoneTransition.States.Begin)); dispatcher.AddListener <SceneTransitionEvents.TransitionComplete>(onSceneLoadComplete); Service.Get <SceneTransitionService>().LoadScene(sceneName, transitionScene, sceneArgs, allowSceneActivation); }
private bool startZoneTransition(string sceneName, string onJoinNotificationTag) { if (IsConnecting) { Log.LogError(this, "Zone connection called while one is already taking place."); return(false); } this.onJoinNotificationTag = onJoinNotificationTag; if (!IsTransitioning) { TransitionState = ZoneTransitionEvents.ZoneTransition.States.Begin; dispatcher.DispatchEvent(new ZoneTransitionEvents.ZoneTransition(CurrentZone.SceneName, sceneName, ZoneTransitionEvents.ZoneTransition.States.Begin)); } DateTime contentDate = Service.Get <ContentSchedulerService>().RefreshContentDate(); Service.Get <INetworkServicesManager>().WorldService.SetContentDate(contentDate); dispatcher.AddListener <WorldServiceEvents.SelfRoomJoinedEvent>(onSelfJoinedRoom, EventDispatcher.Priority.FIRST); TransitionState = ZoneTransitionEvents.ZoneTransition.States.Request; dispatcher.DispatchEvent(new ZoneTransitionEvents.ZoneTransition(CurrentZone.SceneName, sceneName, ZoneTransitionEvents.ZoneTransition.States.Request)); IsConnecting = true; return(true); }