private void ScanForObjective() { if (_previouslyFoundLocation != Vector3.Zero && PluginTime.ReadyToUse(_returnTimeForPreviousLocation, 60000)) { _objectiveLocation = _previouslyFoundLocation; _previouslyFoundLocation = Vector3.Zero; Logger.Debug("[MoveToScenePosition] Returning previous objective location."); return; } if (PluginTime.ReadyToUse(_lastScanTime, 1000)) { _lastScanTime = PluginTime.CurrentMillisecond; if (!string.IsNullOrEmpty(_sceneName)) { var scene = ScenesStorage.CurrentWorldScenes.OrderBy(s => s.Center.DistanceSqr(AdvDia.MyPosition.ToVector2())).FirstOrDefault(s => s.Name.Contains(_sceneName)); if (scene != null) { _worldScene = scene; _objectiveLocation = _worldScene.GetWorldPosition(_position); } } else if (!string.IsNullOrEmpty(_tempSceneName)) { var scene = ScenesStorage.CurrentWorldScenes.OrderBy(s => s.Center.DistanceSqr(AdvDia.MyPosition.ToVector2())).FirstOrDefault(s => s.Name == _tempSceneName); if (scene != null) { _worldScene = scene; _objectiveLocation = _worldScene.GetWorldPosition(_position); } } //if (_objectiveLocation == Vector3.Zero && _actorId != 0) //{ // _objectiveLocation = BountyHelpers.ScanForActorLocation(_actorId, _objectiveScanRange); //} if (_objectiveLocation != Vector3.Zero) { using (new PerformanceLogger("[MoveToScenePosition] Path to Objective Check", true)) { //if ((Navigator.GetNavigationProviderAs<DefaultNavigationProvider>().CanFullyClientPathTo(_objectiveLocation))) //{ Logger.Info("[MoveToScenePosition] Found the objective at distance {0}", AdvDia.MyPosition.Distance2D(_objectiveLocation)); //} //else //{ // Logger.Debug("[MoveToMapMarker] Found the objective at distance {0}, but cannot get a path to it.", // AdvDia.MyPosition.Distance2D(_objectiveLocation)); // _objectiveLocation = Vector3.Zero; //} } } } }
private void ScanForObjective() { //if (_previouslyFoundLocation != Vector3.Zero && PluginTime.ReadyToUse(_returnTimeForPreviousLocation, 60000)) //{ // _objectiveLocation = _previouslyFoundLocation; // _previouslyFoundLocation = Vector3.Zero; // Core.Logger.Debug("[MoveToScenePosition] Returning previous objective location."); // return; //} if (PluginTime.ReadyToUse(_lastScanTime, 1000)) { _lastScanTime = PluginTime.CurrentMillisecond; if (_sceneSnoId > 0) { var scene = Core.Scenes.CurrentWorldScenes.OrderBy(s => s.Center.DistanceSqr(AdvDia.MyPosition.ToVector2())).FirstOrDefault(s => s.SnoId == _sceneSnoId || s.HasChild && s.SubScene.SnoId == _sceneSnoId); if (scene != null) { _worldScene = scene; _objectiveLocation = _worldScene.GetWorldPosition(_position); ExplorationHelpers.SetExplorationPriority(_objectiveLocation); Core.Logger.Debug($"Scan found target scene by SnoId {_worldScene.Name} ({_worldScene.SnoId}). Pos={_objectiveLocation} Dist={_objectiveLocation.Distance(AdvDia.MyPosition)} Relative={_position}"); } } else if (!string.IsNullOrEmpty(_sceneName)) { var scene = Core.Scenes.CurrentWorldScenes.OrderBy( s => s.Center.DistanceSqr(AdvDia.MyPosition.ToVector2())) .FirstOrDefault( s => s.Name.ToLowerInvariant().Contains(_sceneName.ToLowerInvariant()) || s.SubScene != null && s.SubScene.Name.ToLowerInvariant().Contains(_sceneName.ToLowerInvariant()) ); if (scene != null) { _worldScene = scene; _objectiveLocation = _worldScene.GetWorldPosition(_position); ExplorationHelpers.SetExplorationPriority(_objectiveLocation); Core.Logger.Debug($"Scan found target scene {_worldScene.Name} ({_worldScene.SnoId}). Pos={_objectiveLocation} Dist={_objectiveLocation.Distance(AdvDia.MyPosition)} Relative={_position}"); } } if (!Core.Scenes.CurrentScene.IsConnected(_objectiveLocation)) { Core.Logger.Debug($"Unable to reach the scene, we need to uncover more intermediary scenes first"); _objectiveLocation = Vector3.Zero; } //else if (!string.IsNullOrEmpty(_tempSceneName)) //{ // var scene = Core.Scenes.CurrentWorldScenes.OrderBy(s => s.Center.DistanceSqr(AdvDia.MyPosition.ToVector2())).FirstOrDefault(s => s.Name == _tempSceneName); // if (scene != null) // { // _worldScene = scene; // _objectiveLocation = _worldScene.GetWorldPosition(_position); // } //} //if (_objectiveLocation == Vector3.Zero && _actorId != 0) //{ // _objectiveLocation = BountyHelpers.ScanForActorLocation(_actorId, _objectiveScanRange); //} //if (_objectiveLocation != Vector3.Zero) //{ // using (new PerformanceLogger("[MoveToScenePosition] Path to Objective Check", true)) // { // //if ((Navigator.GetNavigationProviderAs<Navigator>().CanFullyClientPathTo(_objectiveLocation))) // //{ // Core.Logger.Log("[MoveToScenePosition] Found the objective at distance {0}", // AdvDia.MyPosition.Distance(_objectiveLocation)); // //} // //else // //{ // // Core.Logger.Debug("[MoveToMapMarker] Found the objective at distance {0}, but cannot get a path to it.", // // AdvDia.MyPosition.Distance(_objectiveLocation)); // // _objectiveLocation = Vector3.Zero; // //} // } //} } }