/// <summary>Sends the given Character on the given Path.</summary> /// <param name="chr">The Character to fly around.</param> /// <param name="destinations">An array of destination TaxiNodes.</param> /// <returns>Whether the client was sent on its way.</returns> internal static bool TryFly(Character chr, NPC vendor, PathNode[] destinations) { IRealmClient client = chr.Client; if (vendor == null && chr.Role.IsStaff) { PathNode pathNode = ((IEnumerable <PathNode>)destinations).LastOrDefault <PathNode>(); if (pathNode == null) { return(false); } chr.TeleportTo((IWorldLocation)pathNode); return(true); } if (vendor == null || !vendor.CheckVendorInteraction(chr)) { TaxiHandler.SendActivateTaxiReply((IPacketReceiver)client, TaxiActivateResponse.NotAvailable); } else if (TaxiMgr.PreFlightCheatChecks(client, destinations) && TaxiMgr.PreFlightValidPathCheck(client, destinations) && (client.ActiveCharacter.GodMode || TaxiMgr.PreFlightMoneyCheck(client))) { TaxiHandler.SendActivateTaxiReply((IPacketReceiver)client, TaxiActivateResponse.Ok); chr.UpdatePvPState(false, true); TaxiMgr.FlyUnit((Unit)chr, true); return(true); } return(false); }
/// <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, (float)TaxiMgr.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) { TaxiMgr.FlyUnit(unit, false); } else { if (TaxiMgr.IsNormalSpeed) { unit.Map.MoveObject((WorldObject)unit, pathVertex.Pos); } else { unit.TeleportTo(pathVertex.Pos); } unit.CancelTaxiFlight(); } }
/// <summary> /// Interpolates the position of the given Unit along the Path given the elapsed flight time. /// </summary> /// <param name="elapsedTime">Time that elapsed since the given unit passed by the last PathVertex</param> internal static void InterpolatePosition(Unit unit, int elapsedTime) { LinkedListNode <PathVertex> linkedListNode = unit.LatestTaxiPathNode; unit.taxiTime += elapsedTime; if (linkedListNode.Next == null) { unit.CancelTaxiFlight(); } else { while (linkedListNode.Next.Value.TimeFromStart <= unit.taxiTime) { linkedListNode = linkedListNode.Next; unit.LatestTaxiPathNode = linkedListNode; if (linkedListNode.Next == null) { if (TaxiMgr.IsNormalSpeed) { unit.m_TaxiMovementTimer.Stop(); return; } TaxiMgr.ContinueFlight(unit); return; } } PathVertex pathVertex1 = linkedListNode.Value; PathVertex pathVertex2 = linkedListNode.Next.Value; int num = unit.taxiTime - linkedListNode.Value.TimeFromStart; Vector3 newPos = pathVertex1.Pos + (pathVertex2.Pos - pathVertex1.Pos) * (float)num / (float)pathVertex2.TimeFromPrevious; unit.Map.MoveObject((WorldObject)unit, ref newPos); } }
public static void FlyUnit(Unit chr, bool startFlight) { TaxiMgr.FlyUnit(chr, startFlight, (LinkedListNode <PathVertex>)null); }