Ejemplo n.º 1
0
        /// <summary>Send character down the next leg of a multi-hop trip.</summary>
        internal static void ContinueFlight(Unit unit)
        {
            if (unit.LatestTaxiPathNode == null)
            {
                return;
            }
            PathVertex pathVertex = unit.LatestTaxiPathNode.Value;
            PathNode   to         = pathVertex.Path.To;

            if (unit.m_TaxiMovementTimer.IsRunning && !unit.IsInRadius(to.Position, AirSpeed))
            {
                return;
            }
            bool flag = false;

            if (unit.TaxiPaths.Count < 2)
            {
                flag = true;
            }
            else
            {
                if (unit.TaxiPaths.Dequeue().To != to)
                {
                    unit.CancelTaxiFlight();
                    return;
                }

                TaxiPath taxiPath = unit.TaxiPaths.Peek();
                if (to != taxiPath.From)
                {
                    unit.CancelTaxiFlight();
                    return;
                }
            }

            if (!flag)
            {
                FlyUnit(unit, false);
            }
            else
            {
                if (IsNormalSpeed)
                {
                    unit.Map.MoveObject(unit, pathVertex.Pos);
                }
                else
                {
                    unit.TeleportTo(pathVertex.Pos);
                }
                unit.CancelTaxiFlight();
            }
        }
Ejemplo n.º 2
0
        public static void FlyUnit(Unit unit, bool startFlight, LinkedListNode <PathVertex> startNode)
        {
            if (unit.TaxiPaths.Count < 1)
            {
                throw new InvalidOperationException("Tried to fly Unit without Path given.");
            }
            TaxiPath taxiPath = unit.TaxiPaths.Peek();

            unit.IsInCombat = false;
            unit.Stealthed  = 0;
            if (startFlight)
            {
                NPCEntry entry = NPCMgr.GetEntry(unit.Faction.IsAlliance
          ? taxiPath.From.AllianceMountId
          : taxiPath.From.HordeMountId);
                if (entry != null)
                {
                    uint displayId = entry.GetRandomModel().DisplayId;
                    unit.Mount(displayId);
                    if (unit is Character)
                    {
                        unit.PushFieldUpdateToPlayer((Character)unit, UnitFields.MOUNTDISPLAYID,
                                                     displayId);
                    }
                }

                unit.OnTaxiStart();
            }

            unit.LatestTaxiPathNode = startNode ?? taxiPath.Nodes.First;
            if (unit.LatestTaxiPathNode == taxiPath.Nodes.First)
            {
                unit.taxiTime = 0;
                MovementHandler.SendMoveToPacket(unit, taxiPath.PathTime,
                                                 MonsterMoveFlags.Flag_0x2000_FullPoints_1, taxiPath.Nodes);
            }
            else
            {
                unit.taxiTime = startNode.Previous.Value.TimeFromStart +
                                (int)(1000.0 * startNode.Value.Pos.GetDistance(unit.Position) /
                                      AirSpeed);
                MovementHandler.SendMoveToPacket(unit, AirSpeed,
                                                 MonsterMoveFlags.Flag_0x2000_FullPoints_1, startNode);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Check that a valid path exists between the destinations.
        /// Also sets the characters TaxiPaths queue with the sequence of valid
        /// paths to the final destination.
        /// </summary>
        /// <param name="client">The IRealmClient requesting the flight.</param>
        /// <param name="destinations">An array of destination TaxiNodes.</param>
        /// <returns>True if a valid path exists.</returns>
        private static bool PreFlightValidPathCheck(IRealmClient client, PathNode[] destinations)
        {
            var curChar = client.ActiveCharacter;

            curChar.TaxiPaths.Clear();

            for (uint i = 0; i < (destinations.Length - 1); ++i)
            {
                TaxiPath path = destinations[i].GetPathTo(destinations[i + 1]);
                if (path == null)
                {
                    curChar.TaxiPaths.Clear();
                    TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.InvalidChoice);
                    return(false);
                }
                curChar.TaxiPaths.Enqueue(path);
            }
            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Check that a valid path exists between the destinations.
        /// Also sets the characters TaxiPaths queue with the sequence of valid
        /// paths to the final destination.
        /// </summary>
        /// <param name="client">The IRealmClient requesting the flight.</param>
        /// <param name="destinations">An array of destination TaxiNodes.</param>
        /// <returns>True if a valid path exists.</returns>
        private static bool PreFlightValidPathCheck(IRealmClient client, PathNode[] destinations)
        {
            Character activeCharacter = client.ActiveCharacter;

            activeCharacter.TaxiPaths.Clear();
            for (uint index = 0; (long)index < (long)(destinations.Length - 1); ++index)
            {
                TaxiPath pathTo = destinations[index].GetPathTo(destinations[index + 1U]);
                if (pathTo == null)
                {
                    activeCharacter.TaxiPaths.Clear();
                    TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.InvalidChoice);
                    return(false);
                }

                activeCharacter.TaxiPaths.Enqueue(pathTo);
            }

            return(true);
        }
Ejemplo n.º 5
0
 public void AddPath(TaxiPath path)
 {
     Paths.Add(path);
 }