Exemplo n.º 1
0
        public void Teleport(ushort mapId, float x, float y, float z, bool teleportedByAdmin = false, bool summonedByAdmin = false)
        {
            IsTeleporting = true;

            if (_gameWorld.CanTeleport(_gameWorld.Players[_ownerId], mapId, out var reason))
            {
                _mapProvider.NextMapId = mapId;
            }
            else
            if (reason == PortalTeleportNotAllowedReason.Unknown)
            {
                _mapProvider.NextMapId = 0;
            }

            _movementManager.PosX = x;
            _movementManager.PosY = y;
            _movementManager.PosZ = z;

            OnTeleporting?.Invoke(_ownerId, _mapProvider.NextMapId, _movementManager.PosX, _movementManager.PosY, _movementManager.PosZ, teleportedByAdmin, summonedByAdmin);

            var prevMapId = _mapProvider.Map.Id;

            if (prevMapId == mapId)
            {
                IsTeleporting = false;
            }
            else
            {
                _mapProvider.Map.UnloadPlayer(_ownerId);
            }
        }
Exemplo n.º 2
0
            public static bool TeleportToLocationUnsafe(Player __instance, ref Vector3 position, ref float yaw)
            {
                var cancel = false;

                OnTeleporting?.Invoke(__instance, ref position, ref yaw, ref cancel);

                return(!cancel);
            }