Ejemplo n.º 1
0
        public Pather(string continent, ConnectionHandlerDelegate connectionHandler)
        {
            ConnectionHandler = connectionHandler;

            Continent = continent.Substring(continent.LastIndexOf('\\') + 1);

            if (Directory.Exists(continent))
            {
                _meshPath = continent;
            }
            else
            {
                var assembly = Assembly.GetCallingAssembly().Location;
                var dir      = Path.GetDirectoryName(assembly);
                if (Directory.Exists(dir + "\\Meshes"))
                {
                    _meshPath = dir + "\\Meshes\\" + continent;
                }
                else
                {
                    _meshPath = dir + "\\" + continent;
                }
            }

            if (!Directory.Exists(_meshPath))
            {
                throw new NavMeshException(DetourStatus.Failure, "No mesh for " + continent + " (Path: " + _meshPath + ")");
            }

            _mesh = new NavMesh();
            DetourStatus status;

            // check if this is a dungeon and initialize our mesh accordingly
            string dungeonPath = GetDungeonPath();

            if (File.Exists(dungeonPath))
            {
                var data = File.ReadAllBytes(dungeonPath);
                status = _mesh.Initialize(data);
                AddMemoryPressure(data.Length);
                IsDungeon = true;
            }
            else
            {
                status = _mesh.Initialize(32768, 4096, Utility.Origin, Utility.TileSize, Utility.TileSize);
            }

            if (status.HasFailed())
            {
                throw new NavMeshException(status, "Failed to initialize the mesh");
            }

            _query = new NavMeshQuery(new PatherCallback(this));
            _query.Initialize(_mesh, 65536);
            Filter = new QueryFilter {
                IncludeFlags = 0xFFFF, ExcludeFlags = 0x0
            };
        }
Ejemplo n.º 2
0
        public Pather(string continent, ConnectionHandlerDelegate connectionHandler)
        {
            lock (_threadLocker)
            {
                try
                {
                    ConnectionHandler = connectionHandler;

                    Continent = continent.Substring(continent.LastIndexOf('\\') + 1);

                    string dir = Application.StartupPath;
                    _meshPath = dir + "\\Meshes"; // + continent;


                    if (!Directory.Exists(_meshPath))
                    {
                        Logging.WriteNavigator(DetourStatus.Failure + " No mesh for " + continent + " (Path: " + _meshPath +
                                               ")");
                    }

                    _mesh        = new NavMesh();
                    _loadedTiles = new Dictionary <Tuple <int, int>, int>();
                    _failedTiles = new Dictionary <Tuple <int, int>, int>();
                    if (_loadTileCheck == null)
                    {
                        _loadTileCheck = new Helpful.Timer(60 * 1000); // 1 min
                    }
                    DetourStatus status;

                    // check if this is a dungeon and initialize our mesh accordingly
                    WoWMap map = WoWMap.FromMPQName(continent);
                    if (map.Record.MapType == WoWMap.MapType.WDTOnlyType || continent == "AllianceGunship")
                    {
                        string dungeonPath = GetDungeonPath();
                        if (!File.Exists(_meshPath + "\\" + dungeonPath))
                        {
                            downloadTile(dungeonPath);
                        }
                        byte[] data = File.ReadAllBytes(_meshPath + "\\" + dungeonPath);
                        status = _mesh.Initialize(data);
                        AddMemoryPressure(data.LongLength);
                        IsDungeon = true;
                    }
                    else //                       20bits 28bits
                    {
                        status = _mesh.Initialize(1048576, 2048 * Division * Division, Utility.Origin, Utility.TileSize / Division, Utility.TileSize / Division);
                    }
                    // maxPolys = 1 << polyBits (20) = 1048576
                    // maxTiles = is 8192 (was 4096), Travel loads tons of tile in quester.
                    // I have logs with over 6000 .tile files loaded.

                    if (status.HasFailed())
                    {
                        Logging.WriteNavigator(status + " Failed to initialize the mesh");
                    }

                    _query = new NavMeshQuery(new PatherCallback(this));
                    DetourStatus t = _query.Initialize(_mesh, 524287); // 20bits - 1
                    //Logging.WriteDebug("NavMeshQuery initialized with status: " + t);
                    Filter = new QueryFilter {
                        IncludeFlags = 0xFFFF, ExcludeFlags = 0x0
                    };
                    // Add the costs
                    Filter.SetAreaCost((int)PolyArea.Water, 4);
                    Filter.SetAreaCost((int)PolyArea.Terrain, 1);
                    Filter.SetAreaCost((int)PolyArea.Road, 1);  // This is the Taxi system, not in tiles yet
                    Filter.SetAreaCost((int)PolyArea.Danger, 25);
                    if (nManagerSetting.DangerousZones.Count > 0)
                    {
                        int addedDangers = ReportDanger(nManagerSetting.DangerousZones, true);
                        if (addedDangers > 0)
                        {
                            Logging.WriteNavigator(addedDangers + " dangers added.");
                        }
                    }
                }
                catch (Exception exception)
                {
                    Logging.WriteError("Pather(string continent, ConnectionHandlerDelegate connectionHandler): " + exception);
                }
            }
        }
Ejemplo n.º 3
0
        public Pather(string continent, ConnectionHandlerDelegate connectionHandler)
        {
            ConnectionHandler = connectionHandler;

            Continent = continent.Substring(continent.LastIndexOf('\\') + 1);

            if (Directory.Exists(continent))
                _meshPath = continent;
            else
            {
                var assembly = Assembly.GetCallingAssembly().Location;
                var dir = Path.GetDirectoryName(assembly);
                if (Directory.Exists(dir + "\\Meshes"))
                    _meshPath = dir + "\\Meshes\\" + continent;
                else
                    _meshPath = dir + "\\" + continent;
            }

            if (!Directory.Exists(_meshPath))
                throw new NavMeshException(DetourStatus.Failure, "No mesh for " + continent + " (Path: " + _meshPath + ")");

            _mesh = new NavMesh();
            DetourStatus status;

            // check if this is a dungeon and initialize our mesh accordingly
            string dungeonPath = GetDungeonPath();
            if (File.Exists(dungeonPath))
            {
                var data = File.ReadAllBytes(dungeonPath);
                status = _mesh.Initialize(data);
                AddMemoryPressure(data.Length);
                IsDungeon = true;
            }
            else
                status = _mesh.Initialize(32768, 4096, Utility.Origin, Utility.TileSize, Utility.TileSize);

            if (status.HasFailed())
                throw new NavMeshException(status, "Failed to initialize the mesh");

            _query = new NavMeshQuery(new PatherCallback(this));
            _query.Initialize(_mesh, 65536);
            Filter = new QueryFilter {IncludeFlags = 0xFFFF, ExcludeFlags = 0x0};
        }
Ejemplo n.º 4
0
        public Pather(string continent, ConnectionHandlerDelegate connectionHandler)
        {
            ConnectionHandler = connectionHandler;

            Continent    = continent.Substring(continent.LastIndexOf('\\') + 1);
            _missingTile = new List <string>();

            if (Directory.Exists(continent))
            {
                _meshPath = continent;
            }
            else
            {
                var assembly = Assembly.GetCallingAssembly().Location;
                var dir      = Path.GetDirectoryName(assembly);
                if (Directory.Exists(dir + "\\Meshes"))
                {
                    _meshPath = dir + "\\Meshes\\" + continent;
                }
                else
                {
                    _meshPath = dir + "\\" + continent;
                }
            }

            if (!Directory.Exists(_meshPath))
            {
                throw new NavMeshException(DetourStatus.Failure, "No mesh for " + continent + " (Path: " + _meshPath + ")");
            }

            _mesh = new NavMesh();
            DetourStatus status;

            // check if this is a dungeon and initialize our mesh accordingly
            string dungeonPath = GetDungeonPath();

            if (File.Exists(dungeonPath))
            {
                var data = File.ReadAllBytes(dungeonPath);
                status = _mesh.Initialize(data);
                AddMemoryPressure(data.Length);
                IsDungeon = true;
            }    //                       20 = 1048575, 28 = toomuch
            else //                       15bits = 32767  9bits
            {
                status = _mesh.Initialize(150000, 512 * Division * Division, Utility.Origin, Utility.TileSize / Division, Utility.TileSize / Division);
            }

            if (status.HasFailed())
            {
                throw new NavMeshException(status, "Failed to initialize the mesh");
            }

            _query = new NavMeshQuery(new PatherCallback(this));
            _query.Initialize(_mesh, 65536);
            Filter = new QueryFilter {
                IncludeFlags = 0xFFFF, ExcludeFlags = 0x0
            };
            Filter.SetAreaCost((int)PolyArea.Water, 4);
            Filter.SetAreaCost((int)PolyArea.Terrain, 1);
            Filter.SetAreaCost((int)PolyArea.Road, 1);
            Filter.SetAreaCost((int)PolyArea.Danger, 20);
        }