void Update() { if (uiCloseWhenTop && DaggerfallUI.UIManager.TopWindow == travelControlUI) { uiCloseWhenTop = false; travelControlUI.CloseWindow(); } if (playerAutopilot != null) { // Ensure only the travel UI is showing, stop travel if not, but allow registered window and travel map to not halt travel. if (GameManager.Instance.IsPlayerOnHUD || (DaggerfallUI.UIManager.TopWindow != travelControlUI && DaggerfallUI.UIManager.TopWindow != noStopForUIWindow && DaggerfallUI.UIManager.TopWindow != DaggerfallUI.Instance.DfTravelMapWindow)) { Debug.Log("Other UI activity detected, stopping travel."); InterruptTravel(); uiCloseWhenTop = travelControlUI.isShowing; return; } // Run updates for playerAutopilot and HUD playerAutopilot.Update(); DaggerfallUI.Instance.DaggerfallHUD.HUDVitals.Update(); if (DestinationName == null && followKeyCode != KeyCode.None && !InputManager.Instance.IsPaused && InputManager.Instance.GetKeyDown(followKeyCode)) { if (travelControlUI.isShowing) { travelControlUI.CloseWindow(); } } // If circumnavigating a location, check for path crossings PlayerGPS playerGPS = GameManager.Instance.PlayerGPS; if (circumnavigatePathsDataPt != 0) { byte crossed = IsPlayerOnPath(playerGPS, circumnavigatePathsDataPt); if (crossed != 0 && crossed != lastCrossed) { lastCrossed = crossed; if (travelControlUI.isShowing) { travelControlUI.CloseWindow(); } return; } lastCrossed = crossed; } // If travelling cautiously, check health and fatigue levels if (DestinationCautious) { if (GameManager.Instance.PlayerEntity.CurrentHealthPercent * 100 < CautiousHealthMinPc) { StopTravelWithMessage(MsgLowHealth); return; } if (GameManager.Instance.PlayerEntity.CurrentFatigue < DaggerfallEntity.FatigueMultiplier * CautiousFatigueMin) { StopTravelWithMessage(MsgLowFatigue); return; } } // If location pause set to nearby and travelling to destination, check for a nearby location and stop if found if (locationPause == LocPauseNear && DestinationName != null && playerGPS.HasCurrentLocation && !playerGPS.CurrentLocation.Equals(lastLocation) && playerGPS.CurrentLocation.Name != DestinationName) { // Store location so it doesn't trigger again and ensure discovered lastLocation = playerGPS.CurrentLocation; playerGPS.DiscoverLocation(playerGPS.CurrentLocation.RegionName, playerGPS.CurrentLocation.Name); StopTravelWithMessage(string.Format(MsgNearLocation, LocationTypeString(), playerGPS.CurrentLocation.Name)); return; } // Check for ocean climate. if (playerGPS.CurrentClimateIndex == (int)MapsFile.Climates.Ocean) { StopTravelWithMessage(MsgOcean); return; } // Handle encounters. if (ignoreEncounters && Time.unscaledTime >= ignoreEncountersTime) { ignoreEncounters = false; } if (!ignoreEncounters && GameManager.Instance.AreEnemiesNearby()) { // This happens when DFU spawns enemies nearby, however quest trigger encounters fire the OnEncounter event first so this code is never reached. Debug.Log("Enountered enemies during travel."); travelControlUI.CloseWindow(); if (DestinationCautious) { AttemptAvoidEncounter(); } else { DaggerfallUI.MessageBox(MsgEnemies); } return; } // Check for diseases. var currentDiseaseCount = GameManager.Instance.PlayerEffectManager.DiseaseCount; if (currentDiseaseCount != diseaseCount) { if (currentDiseaseCount > diseaseCount) { Debug.Log("New disease detected, interrupting travel!"); InterruptTravel(); DaggerfallUI.Instance.CreateHealthStatusBox(DaggerfallUI.Instance.UserInterfaceManager.TopWindow).Show(); } diseaseCount = currentDiseaseCount; } } else if (followKeyCode != KeyCode.None && !InputManager.Instance.IsPaused && InputManager.Instance.GetKeyDown(followKeyCode) && GameManager.Instance.IsPlayerOnHUD) { if (GameManager.Instance.PlayerEnterExit.IsPlayerInside) { return; } if (GameManager.Instance.AreEnemiesNearby()) { DaggerfallUI.MessageBox(TextManager.Instance.GetLocalizedText("cannotTravelWithEnemiesNearby")); } else { FollowPath(); } } }
void Update() { if (playerAutopilot != null) { // Ensure UI is showing if (!travelControlUI.isShowing) { DaggerfallUI.UIManager.PushWindow(travelControlUI); } // Run updates for playerAutopilot and HUD playerAutopilot.Update(); DaggerfallUI.Instance.DaggerfallHUD.HUDVitals.Update(); // If travelling cautiously, check health and fatigue levels if (DestinationCautious) { if (GameManager.Instance.PlayerEntity.CurrentHealthPercent * 100 < CautiousHealthMinPc) { StopTravelWithMessage(MsgLowHealth); return; } if (GameManager.Instance.PlayerEntity.CurrentFatigue < DaggerfallEntity.FatigueMultiplier * CautiousFatigueMin) { StopTravelWithMessage(MsgLowFatigue); return; } } // If location pause set to nearby, check for a near location PlayerGPS playerGPS = GameManager.Instance.PlayerGPS; if (locationPause == LocPauseNear && playerGPS.HasCurrentLocation && !playerGPS.CurrentLocation.Equals(lastLocation)) { lastLocation = playerGPS.CurrentLocation; StopTravelWithMessage(string.Format(MsgNearLocation, MacroHelper.LocationTypeName(), playerGPS.CurrentLocation.Name)); return; } // Check for ocean climate. if (playerGPS.CurrentClimateIndex == (int)MapsFile.Climates.Ocean) { StopTravelWithMessage(MsgOcean); return; } // Handle encounters. if (ignoreEncounters && Time.unscaledTime >= ignoreEncountersTime) { ignoreEncounters = false; } if (!ignoreEncounters && GameManager.Instance.AreEnemiesNearby()) { // This happens when DFU spawns enemies nearby, however quest trigger encounters fire the OnEncounter event first so this code is never reached. Debug.Log("Enountered enemies during travel."); travelControlUI.CloseWindow(); if (DestinationCautious) { AttemptAvoidEncounter(); } else { DaggerfallUI.MessageBox(MsgEnemies); } return; } // Check for diseases. var currentDiseaseCount = GameManager.Instance.PlayerEffectManager.DiseaseCount; if (currentDiseaseCount != diseaseCount) { if (currentDiseaseCount > diseaseCount) { Debug.Log("New disease detected, interrupting travel!"); InterruptTravel(); DaggerfallUI.Instance.CreateHealthStatusBox(DaggerfallUI.Instance.UserInterfaceManager.TopWindow).Show(); } diseaseCount = currentDiseaseCount; } } }