Beispiel #1
0
        void DelayedTeleportTransport()
        {
            if (!_delayedTeleport)
            {
                return;
            }

            var nextFrame = GetKeyFrames()[_nextFrame];

            _delayedTeleport = false;
            Map newMap = Global.MapMgr.CreateBaseMap(nextFrame.Node.ContinentID);

            GetMap().RemoveFromMap(this, false);
            SetMap(newMap);

            float x = nextFrame.Node.Loc.X,
                  y = nextFrame.Node.Loc.Y,
                  z = nextFrame.Node.Loc.Z,
                  o = nextFrame.InitialOrientation;

            foreach (WorldObject obj in _passengers.ToList())
            {
                float destX, destY, destZ, destO;
                obj.m_movementInfo.transport.pos.GetPosition(out destX, out destY, out destZ, out destO);
                TransportPosHelper.CalculatePassengerPosition(ref destX, ref destY, ref destZ, ref destO, x, y, z, o);

                switch (obj.GetTypeId())
                {
                case TypeId.Player:
                    if (!obj.ToPlayer().TeleportTo(nextFrame.Node.ContinentID, destX, destY, destZ, destO, TeleportToOptions.NotLeaveTransport))
                    {
                        RemovePassenger(obj);
                    }
                    break;

                case TypeId.DynamicObject:
                case TypeId.AreaTrigger:
                    obj.AddObjectToRemoveList();
                    break;

                default:
                    RemovePassenger(obj);
                    break;
                }
            }

            Relocate(x, y, z, o);
            GetMap().AddToMap(this);
        }
Beispiel #2
0
        bool TeleportTransport(uint newMapid, float x, float y, float z, float o)
        {
            Map oldMap = GetMap();

            if (oldMap.GetId() != newMapid)
            {
                _delayedTeleport = true;
                UnloadStaticPassengers();
                return(true);
            }
            else
            {
                UpdatePosition(x, y, z, o);

                // Teleport players, they need to know it
                foreach (var obj in _passengers)
                {
                    if (obj.IsTypeId(TypeId.Player))
                    {
                        // will be relocated in UpdatePosition of the vehicle
                        Unit veh = obj.ToUnit().GetVehicleBase();
                        if (veh)
                        {
                            if (veh.GetTransport() == this)
                            {
                                continue;
                            }
                        }

                        float destX, destY, destZ, destO;
                        obj.m_movementInfo.transport.pos.GetPosition(out destX, out destY, out destZ, out destO);
                        TransportPosHelper.CalculatePassengerPosition(ref destX, ref destY, ref destZ, ref destO, x, y, z, o);

                        obj.ToUnit().NearTeleportTo(destX, destY, destZ, destO);
                    }
                }

                return(false);
            }
        }
Beispiel #3
0
 public void CalculatePassengerOffset(ref float x, ref float y, ref float z, ref float o)
 {
     TransportPosHelper.CalculatePassengerOffset(ref x, ref y, ref z, ref o, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
 }