Пример #1
0
        public async Task <bool> GetCoroutine()
        {
            if (_allowSafeZerg && PluginSettings.Current.BountyZerg && BountyData != null &&
                BountyData.QuestType != BountyQuestType.KillMonster)
            {
                Logger.Verbose("Enabling SafeZerg for Kill Monster bounty");
                SafeZerg.Instance.EnableZerg();
            }

            switch (State)
            {
            case States.NotStarted:
                return(await NotStarted());

            case States.Searching:
                return(await Searching());

            case States.Moving:
                return(await Moving());

            case States.Completed:
                return(await Completed());

            case States.Failed:
                return(await Failed());
            }
            return(false);
        }
Пример #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();
     }
 }
Пример #3
0
        public void Update(List <INode> nodes)
        {
            Logger.Verbose("[{0}] Updating grid with {1} new nodes", GetType().Name, nodes.Count);

            nodes = nodes.OrderBy(n => n.Center.X).ThenBy(n => n.Center.Y).ToList();
            foreach (var node in nodes)
            {
                if (node.DynamicWorldId != AdvDia.CurrentWorldDynamicId)
                {
                    Logger.Debug("[{0}] A node has different worldId than current world, skipping", GetType().Name);
                    return;
                }
                var nodeX = ToGridDistance(node.Center.X);  //(int)Math.Round((node.Center.X - MinX - boxSize / 2) / boxSize);
                var nodeY = ToGridDistance(node.Center.Y);  //(int)Math.Round((node.Center.Y - MinY - boxSize / 2) / boxSize);
                InnerGrid[nodeX, nodeY] = node;
                if (MinX > nodeX)
                {
                    MinX = nodeX;
                }
                if (MaxX < nodeX)
                {
                    MaxX = nodeX;
                }
                if (MinY > nodeY)
                {
                    MinY = nodeY;
                }
                if (MaxY < nodeY)
                {
                    MaxY = nodeY;
                }
                node.GridPoint = new GridPoint(nodeX, nodeY);
            }

            GridMaxX = InnerGrid.GetLength(0);
            GridMaxY = InnerGrid.GetLength(1);
            BaseSize = (int)Math.Round(BoxSize / 4, MidpointRounding.AwayFromZero);

            if (this is ExplorationGrid)
            {
                foreach (var node in nodes)
                {
                    var expNode = node as ExplorationNode;
                    if (expNode != null)
                    {
                        expNode.AStarValue = (byte)(expNode.HasEnoughNavigableCells ? 1 : 2);
                    }
                }
            }

            if (this is NavigationGrid)
            {
                foreach (var node in nodes.Where(n => n.NodeFlags.HasFlag(NodeFlags.AllowWalk)))
                {
                    var navNode = node as NavigationNode;
                    if (navNode != null)
                    {
                        navNode.AStarValue = 1;
                        if (MarkNodesNearWall)
                        {
                            if (GetNeighbors(node).Any(n => (n.NodeFlags & NodeFlags.AllowWalk) == 0))
                            {
                                node.NodeFlags |= NodeFlags.NearWall;

                                navNode.AStarValue = 2;
                                if (navNode == navNode.ExplorationNode.NavigableCenterNode)
                                {
                                    var newCenterNode = GetNeighbors(node).FirstOrDefault(n =>
                                                                                          n.NodeFlags.HasFlag(NodeFlags.AllowWalk) &&
                                                                                          !n.NodeFlags.HasFlag(NodeFlags.NearWall));
                                    if (newCenterNode != null && newCenterNode is NavigationNode)
                                    {
                                        navNode.ExplorationNode.NavigableCenterNode = newCenterNode as NavigationNode;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            OnUpdated(nodes);
        }