Esempio n. 1
0
        public ExplorationNode(Vector2 center, float boxSize, float boxTolerance, WorldScene scene)
        {
            _boxSize      = boxSize;
            _boxTolerance = boxTolerance;
            _scene        = scene;

            var halfSize = (float)boxSize / 2;

            //_maxCellsCount = _boxSize / 2.5 / 2;

            Center      = center;
            TopLeft     = Center + new Vector2(-(halfSize), -(halfSize));
            BottomLeft  = Center + new Vector2(-(halfSize), halfSize);
            TopRight    = Center + new Vector2(halfSize, -(halfSize));
            BottomRight = Center + new Vector2(halfSize, halfSize);

            NavigableCenterNode = null;

            Calculate(this);
        }
Esempio n. 2
0
 public WorldScene(Scene scene, float boxSize, float boxTolerance)
 {
     using (new PerformanceLogger("[WorldScene] ctor", false))
     {
         //                Logger.Debug("[WorldScene] Scene GridSquare Size: {0} X:{1} Y:{2}", scene.Mesh.Zone.NavZoneDef.GridSquareSize,scene.Mesh.Zone.NavZoneDef.NavGridSquareCountX, scene.Mesh.Zone.NavZoneDef.NavGridSquareCountY);
         _boxSize      = boxSize;
         _boxTolerance = boxTolerance;
         Scene         = scene;
         Name          = scene.Name;
         HashName      = scene.GetSceneNameString();
         LevelAreaId   = Scene.Mesh.LevelAreaSNO;
         Min           = Scene.Mesh.Zone.ZoneMin;
         Max           = Scene.Mesh.Zone.ZoneMax;
         Center        = (Max + Min) / 2;
         //Rect = new Rect(new Point(Center.X, Center.Y), new Size(_boxSize, _boxSize));
         HasChild       = Scene.Mesh.SubSceneId > 0;
         HasParent      = Scene.Mesh.ParentSceneId > 0;
         IsIgnored      = ExplorationData.IgnoreScenes.Contains(Scene.Name);
         DynamicWorldId = Scene.Mesh.DynamicWorldId;
         SceneId        = scene.Mesh.SceneId;
         if (HasChild)
         {
             SubScene = new WorldScene(Scene.Mesh.SubScene, boxSize, boxTolerance);
             if (SubScene.HasChild)
             {
                 Logger.Error("[ScenesStorage] Found sub sub scene!!!");
                 SubScene.SubScene = new WorldScene(SubScene.Scene.Mesh.SubScene, boxSize, boxTolerance);
             }
         }
         Logger.Verbose("[WorldScene] Created a new world scene. Name: {0} LevelArea: {1} ({2})", Name, (SNOLevelArea)LevelAreaId, LevelAreaId);
         if (LevelAreaId != AdvDia.CurrentLevelAreaId && !ExplorationData.OpenWorldIds.Contains(AdvDia.CurrentWorldId))
         {
             Logger.Verbose("[WorldScene] The scene LevelAreaID is different than the CurrentLevelAreaID");
             Logger.Verbose("[WorldScene] Scene Name: {0}", Name);
             Logger.Verbose("[WorldScene] Scene: {0} ({1})", (SNOLevelArea)LevelAreaId, LevelAreaId);
             Logger.Verbose("[WorldScene] Current: {0} ({1})", (SNOLevelArea)AdvDia.CurrentLevelAreaId, AdvDia.CurrentLevelAreaId);
         }
         CreateGrid();
     }
 }
Esempio n. 3
0
 public WorldScene(Scene scene, float boxSize, float boxTolerance)
 {
     using (new PerformanceLogger("[WorldScene] ctor", false))
     {
         //                Logger.Debug("[WorldScene] Scene GridSquare Size: {0} X:{1} Y:{2}", scene.Mesh.Zone.NavZoneDef.GridSquareSize,scene.Mesh.Zone.NavZoneDef.NavGridSquareCountX, scene.Mesh.Zone.NavZoneDef.NavGridSquareCountY);
         _boxSize = boxSize;
         _boxTolerance = boxTolerance;
         Scene = scene;
         Name = scene.Name;
         HashName = scene.GetSceneNameString();
         LevelAreaId = Scene.Mesh.LevelAreaSNO;
         Min = Scene.Mesh.Zone.ZoneMin;
         Max = Scene.Mesh.Zone.ZoneMax;
         Center = (Max + Min) / 2;
         //Rect = new Rect(new Point(Center.X, Center.Y), new Size(_boxSize, _boxSize));
         HasChild = Scene.Mesh.SubSceneId > 0;
         HasParent = Scene.Mesh.ParentSceneId > 0;
         IsIgnored = ExplorationData.IgnoreScenes.Contains(Scene.Name);
         DynamicWorldId = Scene.Mesh.DynamicWorldId;
         SceneId = scene.Mesh.SceneId;
         if (HasChild)
         {
             SubScene = new WorldScene(Scene.Mesh.SubScene, boxSize, boxTolerance);
             if (SubScene.HasChild)
             {
                 Logger.Error("[ScenesStorage] Found sub sub scene!!!");
                 SubScene.SubScene = new WorldScene(SubScene.Scene.Mesh.SubScene, boxSize, boxTolerance);
             }
         }
         Logger.Verbose("[WorldScene] Created a new world scene. Name: {0} LevelArea: {1} ({2})", Name, (SNOLevelArea)LevelAreaId, LevelAreaId);
         if (LevelAreaId != AdvDia.CurrentLevelAreaId && !ExplorationData.OpenWorldIds.Contains(AdvDia.CurrentWorldId))
         {
             Logger.Verbose("[WorldScene] The scene LevelAreaID is different than the CurrentLevelAreaID");
             Logger.Verbose("[WorldScene] Scene Name: {0}", Name);
             Logger.Verbose("[WorldScene] Scene: {0} ({1})", (SNOLevelArea)LevelAreaId, LevelAreaId);
             Logger.Verbose("[WorldScene] Current: {0} ({1})", (SNOLevelArea)AdvDia.CurrentLevelAreaId, AdvDia.CurrentLevelAreaId);
         }
         CreateGrid();
     }
 }
Esempio n. 4
0
        public NavigationNode(Vector3 center, float boxSize, ExplorationNode node, WorldSceneCell cell)
        {
            if (node != null)
            {
                _explorationNode = node;
                _scene           = node.Scene;
            }

            if (cell != null)
            {
                NodeFlags = (NodeFlags)cell.NavCellFlags;
            }

            var halfSize = (float)boxSize / 2;

            Center            = center.ToVector2();
            TopLeft           = Center + new Vector2(-(halfSize), -(halfSize));
            BottomLeft        = Center + new Vector2(-(halfSize), halfSize);
            TopRight          = Center + new Vector2(halfSize, -(halfSize));
            BottomRight       = Center + new Vector2(halfSize, halfSize);
            NavigableCenter   = center;
            NavigableCenter2D = Center;
        }
        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;
                        //}
                    }

                }
            }
        }
Esempio n. 6
0
 public static void Update()
 {
     using (new PerformanceLogger("[ScenesStorage] Update Scenes", true))
     {
         var          addedScenes = new List <WorldScene>();
         List <Scene> newScenes;
         try
         {
             newScenes = ZetaDia.Scenes.Where(s => s.IsAlmostValid() && !CurrentWorldSceneIds.Contains(s.GetSceneNameString())).ToList();
         }
         catch (NullReferenceException)
         {
             return;
         }
         catch (Exception ex)
         {
             if (ex.Message.Contains("ReadProcessMemory"))
             {
                 return;
             }
             throw;
         }
         foreach (var scene in newScenes)
         {
             try
             {
                 if (!scene.IsAlmostValid())
                 {
                     continue;
                 }
                 var sceneHashName = scene.GetSceneNameString();
                 if (scene.IsAlmostValid() && scene.Mesh.ParentSceneId <= 0 &&
                     scene.Mesh.WorldId == AdvDia.CurrentWorldDynamicId &&
                     !scene.Name.ToLowerInvariant().Contains("fill"))
                 {
                     var adventurerScene = new WorldScene(scene, ExplorationData.ExplorationNodeBoxSize,
                                                          ExplorationData.ExplorationNodeBoxTolerance);
                     if (adventurerScene.Cells.Count > 0)
                     {
                         CurrentWorldScenes.Add(adventurerScene);
                         addedScenes.Add(adventurerScene);
                     }
                 }
                 CurrentWorldSceneIds.Add(sceneHashName);
             }
             catch (NullReferenceException)
             {
             }
         }
         if (addedScenes.Count > 0)
         {
             Logger.Debug("[ScenesStorage] Found {0} new scenes", addedScenes.Count);
             var nodes = addedScenes.SelectMany(s => s.Nodes).ToList();
             //foreach (var explorationNode in nodes)
             //{
             //    if (ZetaDia.Minimap.IsExplored(explorationNode.NavigableCenter, explorationNode.WorldId))
             //    {
             //        explorationNode.IsVisited = true;
             //    }
             //}
             ExplorationGrid.Instance.Update(nodes.Cast <INode>().ToList());
             NavigationGrid.Instance.Update(nodes.SelectMany(n => n.Nodes).Cast <INode>().ToList());
         }
     }
 }
Esempio n. 7
0
        public static void Update()
        {

            using (new PerformanceLogger("[ScenesStorage] Update Scenes", true))
            {
                var addedScenes = new List<WorldScene>();
                List<Scene> newScenes;
                try
                {
                    newScenes = ZetaDia.Scenes.Where(s => s.IsAlmostValid() && !CurrentWorldSceneIds.Contains(s.GetSceneNameString())).ToList();
                }
                catch (NullReferenceException)
                {
                    return;
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("ReadProcessMemory"))
                    {
                        return;
                    }
                    throw;
                }
                foreach (var scene in newScenes)
                {
                    try
                    {
                        if (!scene.IsAlmostValid()) continue;
                        var sceneHashName = scene.GetSceneNameString();
                        if (scene.IsAlmostValid() && scene.Mesh.ParentSceneId <= 0 &&
                            scene.Mesh.WorldId == AdvDia.CurrentWorldDynamicId &&
                            !scene.Name.ToLowerInvariant().Contains("fill"))
                        {
                            var adventurerScene = new WorldScene(scene, ExplorationData.ExplorationNodeBoxSize,
                                ExplorationData.ExplorationNodeBoxTolerance);
                            if (adventurerScene.Cells.Count > 0)
                            {
                                CurrentWorldScenes.Add(adventurerScene);
                                addedScenes.Add(adventurerScene);
                            }
                        }
                        CurrentWorldSceneIds.Add(sceneHashName);
                    }
                    catch (NullReferenceException)
                    {

                    }
                }
                if (addedScenes.Count > 0)
                {
                    Logger.Debug("[ScenesStorage] Found {0} new scenes", addedScenes.Count);
                    var nodes = addedScenes.SelectMany(s => s.Nodes).ToList();
                    //foreach (var explorationNode in nodes)
                    //{
                    //    if (ZetaDia.Minimap.IsExplored(explorationNode.NavigableCenter, explorationNode.WorldId))
                    //    {
                    //        explorationNode.IsVisited = true;
                    //    }
                    //}
                    ExplorationGrid.Instance.Update(nodes.Cast<INode>().ToList());
                    NavigationGrid.Instance.Update(nodes.SelectMany(n => n.Nodes).Cast<INode>().ToList());
                }
            }
        }