Esempio n. 1
0
        private void ScanForObjective()
        {
            if (_previouslyFoundLocation != Vector3.Zero && PluginTime.ReadyToUse(_returnTimeForPreviousLocation, 60000))
            {
                _objectiveLocation       = _previouslyFoundLocation;
                _previouslyFoundLocation = Vector3.Zero;
                Core.Logger.Debug("[MoveToScene] Returning previous objective location.");
                return;
            }
            if (PluginTime.ReadyToUse(_lastScanTime, 1000))
            {
                _lastScanTime = PluginTime.CurrentMillisecond;
                if (!string.IsNullOrEmpty(SceneName))
                {
                    _scene = Core.Scenes.CurrentWorldScenes.OrderBy(s => s.Center.DistanceSqr(AdvDia.MyPosition.ToVector2())).FirstOrDefault(s => s.Name.ToLowerInvariant().Contains(SceneName.ToLowerInvariant()) || s.HasChild && s.SubScene.Name.ToLowerInvariant().Contains(SceneName.ToLowerInvariant()));
                    var centerNode =
                        _scene?.Nodes.Where(n => n.HasEnoughNavigableCells)
                        .OrderBy(n => n.Center.DistanceSqr(_scene.Center))
                        .FirstOrDefault();
                    if (centerNode != null)
                    {
                        _objectiveLocation = centerNode.NavigableCenter;
                    }
                }
                if (_objectiveLocation != Vector3.Zero && PluginTime.ReadyToUse(_lastObjectiveFoundTime, 20000))
                {
                    _lastObjectiveFoundTime = PluginTime.CurrentMillisecond;

                    using (new PerformanceLogger("[MoveToScene] Path to Objective Check", true))
                    {
                        Core.Logger.Log("[MoveToScene] Found the objective at distance {0}",
                                        AdvDia.MyPosition.Distance(_objectiveLocation));

                        ExplorationHelpers.SetExplorationPriority(_objectiveLocation);
                    }
                }
                else
                {
                    _objectiveLocation = Vector3.Zero;
                }
            }
        }