Example #1
0
    public void SwapSeats(BasePlayer player, int targetSeat = 0)
    {
        if (!this.HasMountPoints())
        {
            return;
        }
        int playerSeat = this.GetPlayerSeat(player);

        if (playerSeat == -1)
        {
            return;
        }
        BaseMountable baseMountable  = this.mountPoints[playerSeat].mountable;
        int           num            = playerSeat;
        BaseMountable baseMountable1 = null;

        if (baseMountable1 == null)
        {
            int num1 = 0;
            while (num1 < (int)this.mountPoints.Length)
            {
                num++;
                if (num >= (int)this.mountPoints.Length)
                {
                    num = 0;
                }
                BaseVehicle.MountPointInfo mountPointInfo = this.mountPoints[num];
                if (!(mountPointInfo.mountable != null) || mountPointInfo.mountable.IsMounted() || this.IsSeatClipping(mountPointInfo.mountable, 1218511105) || !this.IsSeatVisible(mountPointInfo.mountable, player.eyes.position, 1218511105))
                {
                    num1++;
                }
                else
                {
                    baseMountable1 = mountPointInfo.mountable;
                    break;
                }
            }
        }
        if (baseMountable1 != null && baseMountable1 != baseMountable)
        {
            baseMountable.DismountPlayer(player, true);
            baseMountable1.MountPlayer(player);
            player.MarkSwapSeat();
        }
    }
Example #2
0
    public void SwapSeats(BasePlayer player, int targetSeat = 0)
    {
        if (!this.HasMountPoints())
        {
            return;
        }
        int playerSeat = this.GetPlayerSeat(player);

        if (playerSeat == -1)
        {
            return;
        }
        BaseMountable mountable     = this.mountPoints[playerSeat].mountable;
        int           index1        = playerSeat;
        BaseMountable baseMountable = (BaseMountable)null;

        if (Object.op_Equality((Object)baseMountable, (Object)null))
        {
            for (int index2 = 0; index2 < this.mountPoints.Length; ++index2)
            {
                ++index1;
                if (index1 >= this.mountPoints.Length)
                {
                    index1 = 0;
                }
                BaseVehicle.MountPointInfo mountPoint = this.mountPoints[index1];
                if (Object.op_Inequality((Object)mountPoint.mountable, (Object)null) && !mountPoint.mountable.IsMounted() && (!this.IsSeatClipping(mountPoint.mountable, 1218511105) && this.IsSeatVisible(mountPoint.mountable, player.eyes.position, 1218511105)))
                {
                    baseMountable = mountPoint.mountable;
                    break;
                }
            }
        }
        if (!Object.op_Inequality((Object)baseMountable, (Object)null) || !Object.op_Inequality((Object)baseMountable, (Object)mountable))
        {
            return;
        }
        mountable.DismountPlayer(player, true);
        baseMountable.MountPlayer(player);
        player.MarkSwapSeat();
    }
Example #3
0
    public void SwapSeats(BasePlayer player, int targetSeat = 0)
    {
        if (!HasMountPoints() || !CanSwapSeats)
        {
            return;
        }
        int playerSeat = GetPlayerSeat(player);

        if (playerSeat == -1)
        {
            return;
        }
        BaseMountable mountable     = mountPoints[playerSeat].mountable;
        int           num           = playerSeat;
        BaseMountable baseMountable = null;

        if (baseMountable == null)
        {
            for (int i = 0; i < mountPoints.Count; i++)
            {
                num++;
                if (num >= mountPoints.Count)
                {
                    num = 0;
                }
                MountPointInfo mountPointInfo = mountPoints[num];
                if (mountPointInfo.mountable != null && !mountPointInfo.mountable.IsMounted() && mountPointInfo.mountable.CanSwapToThis(player) && !IsSeatClipping(mountPointInfo.mountable) && IsSeatVisible(mountPointInfo.mountable, player.eyes.position))
                {
                    baseMountable = mountPointInfo.mountable;
                    break;
                }
            }
        }
        if (baseMountable != null && baseMountable != mountable)
        {
            mountable.DismountPlayer(player, true);
            baseMountable.MountPlayer(player);
            player.MarkSwapSeat();
        }
    }