Exemplo n.º 1
0
        private void SetRideOffPosition(PlayerEntity playerEntity, VehicleEntity vehicle)
        {
            //set the player ride-off position
            var seat = VehicleEntityUtility.GetVehicleSeat(playerEntity);

            if (vehicle.IsRideOffFromLeft(seat))
            {
                if (RideOffFromLeft(playerEntity, vehicle))
                {
                    return;
                }

                if (RideOffFromRight(playerEntity, vehicle))
                {
                    return;
                }
            }
            else
            {
                if (RideOffFromRight(playerEntity, vehicle))
                {
                    return;
                }

                if (RideOffFromLeft(playerEntity, vehicle))
                {
                    return;
                }
            }

            //if the player can not ride off from left or right, try to ride off from back or front
            if (RideOffFromBack(playerEntity, vehicle))
            {
                return;
            }

            if (RideOffFromFront(playerEntity, vehicle))
            {
                return;
            }

            //almost never happen, the vehicle is stuck, and the player has to ride off from the top of the vehicle.
            RideOffFromTop(playerEntity, vehicle);
        }
Exemplo n.º 2
0
        private void ChangeSeatOnVehicle(PlayerEntity playerEntity, int seatIndex)
        {
            if (!playerEntity.IsOnVehicle())
            {
                return;
            }

            var vehicleComp = playerEntity.controlledVehicle;
            var vehicle     = _vehicleContext.GetEntityWithEntityKey(vehicleComp.EntityKey);

            if (vehicle == null)
            {
                return;
            }

            var seat = GetSeatIdFromCmdSeatIndex(vehicle, seatIndex);

            if (seat < 0)
            {
                return;
            }

            if (vehicle.IsOnVehicleSeat(playerEntity, seat))
            {
                return;
            }


            if (!vehicle.ChangeSeatOnVehicle(playerEntity, seat))
            {
                return;
            }

            var originSeat = VehicleEntityUtility.GetVehicleSeat(playerEntity);

            CheckAndRemoveOwnerId(vehicle, originSeat);
            CheckAndAddOwnerId(vehicle, playerEntity);

            playerEntity.DriveStart(_contexts, seat, vehicle.vehicleAssetInfo.PostureId);
        }
Exemplo n.º 3
0
        private void RideOffVehicle(PlayerEntity playerEntity)
        {
            if (playerEntity.IsOnVehicle())
            {
                var vehicle = _vehicleContext.GetEntityWithEntityKey(playerEntity.controlledVehicle.EntityKey);
                if (vehicle == null)
                {
                    return;
                }

                var seat = VehicleEntityUtility.GetVehicleSeat(playerEntity);
                CheckAndRemoveOwnerId(vehicle, seat);
                vehicle.RemovePassager(playerEntity);
                SetRideOffPosition(playerEntity, vehicle);
                //Logger.ErrorFormat("PosAfterRideOff_{0} : {1},{2},{3}", playerEntity.userCmd.Latest.Seq,
                //    playerEntity.position.Value.x, playerEntity.position.Value.y, playerEntity.position.Value.z);
                AddRideOffVelocity(playerEntity, vehicle);
                SetPositionInterpolateMode(playerEntity);
            }

            playerEntity.controlledVehicle.RideOff(_currentTime.CurrentTime);
            playerEntity.SetCharacterStateWithVehicle(_contexts, _vehicleContext);
        }