Example #1
0
        private void HandleConnections(MeshTile tile)
        {
            if (tile.Header.OffMeshConCount <= 0)
            {
                return;
            }

            var count = tile.Header.OffMeshConCount;

            for (int i = 0; i < count; i++)
            {
                var con = tile.GetOffMeshConnection(i);
                if (con == null)
                {
                    continue;
                }
                var path = TaxiHelper.GetRecordById((int)con.UserID);
                if (!path.IsValid())
                {
                    DisableConnection(tile, i);
                    continue;
                }
                var from = TaxiHelper.GetNode(path.From);
                var to   = TaxiHelper.GetNode(path.To);
                if (!from.IsValid() || !to.IsValid())
                {
                    DisableConnection(tile, i);
                    continue;
                }

                var data = new ConnectionData
                {
                    Alliance = from.IsAlliance() || to.IsAlliance(),
                    Horde    = from.IsHorde() || to.IsHorde(),
                    Cost     = path.Cost,
                    From     = from.Name(),
                    To       = to.Name(),
                    Id       = (int)con.UserID
                };

                if (!ConnectionHandler(data))
                {
                    DisableConnection(tile, i);
                }
            }
        }
Example #2
0
        private static Hop BuildFlightmasterHop(int pathId)
        {
            var path = TaxiHelper.GetRecordById(pathId);

            if (!path.IsValid())
            {
                throw new NavMeshException(DetourStatus.Failure, "FindStraightPath returned a hop with an invalid path id");
            }

            var from = TaxiHelper.GetNode(path.From);
            var to   = TaxiHelper.GetNode(path.To);

            if (!from.IsValid() || !to.IsValid())
            {
                throw new NavMeshException(DetourStatus.Failure, "FindStraightPath returned a hop with unresolvable flight path");
            }

            return(new Hop
            {
                Location = from.Location,
                FlightTarget = to.Name(),
                Type = HopType.Flightmaster
            });
        }