private static void GetStateFromDynamicData(VehicleEntity vehicle, VehicleAbstractInternState state)
        {
            var data = (CarRewindDataComponent)vehicle.GetDynamicData();

            state.SetFrom(vehicle);
            data.Clear();
        }
        private void SetWheelAngleFromState(VehicleAbstractController controller, VehicleAbstractInternState internalState)
        {
            var wheelCount = controller.WheelCount;

            for (int i = 0; i < wheelCount; ++i)
            {
                var wheel = controller.GetWheel(i);
                wheel.wheelCollider.steerAngle = internalState.Wheels[i].WheelSteerAngle;
            }
        }
 public void SyncFromComponentToController(VehicleEntity vehicle, VehicleAbstractInternState state)
 {
     if (SharedConfig.DynamicPrediction)
     {
         DynamicSyncFromComponentToController(vehicle, state);
     }
     else
     {
         DirectSyncFromComponentToController(vehicle, state);
     }
 }
        private void SyncStateFromComponentToController(VehicleEntity vehicle, VehicleAbstractInternState state)
        {
            if (!state.IsSet() || SharedConfig.IsOffline)
            {
                return;
            }

            var currentState = GetCurrentState(vehicle);

            state.SetTo(currentState);
            ApplyState(vehicle);
        }
        private void DynamicSyncFromComponentToController(VehicleEntity vehicle, VehicleAbstractInternState internalState)
        {
            var controller = GetController(vehicle);
            var state      = VehicleDynamicPredictionUtility.MoveToState(controller, internalState);

            SetWheelAngleFromState(controller, internalState);
            SetWheelEntityInput(controller, internalState);
            SetControllerState(controller,
                               state.Position, state.Rotation,
                               state.LinearVelocity, state.AngularVelocity,
                               state.Crashed, state.IsSleeping, state.SleepingOutSync);
        }
        private void SetWheelEntityInput(VehicleAbstractController controller, VehicleAbstractInternState internalState)
        {
            controller.steerInput     = internalState.SteerInput;
            controller.throttleInput  = internalState.ThrottleInput;
            controller.handbrakeInput = internalState.HandbrakeInput;
            controller.isHornOn       = internalState.IsHornOn;
            controller.isAccelerated  = internalState.IsAccelerated;

            if (controller.ControllerType == VehicleControllerType.Car)
            {
                var carInternState = (CarInternState)internalState;
                controller.brakeInput = carInternState.BrakeInput;
            }
            else if (controller.ControllerType == VehicleControllerType.Motor)
            {
                var motorController   = (MotorcycleController)controller;
                var motorInsternState = (MotorInternState)internalState;

                motorController.stuntInput          = motorInsternState.StuntInput;
                motorController.horizontalMassShift = motorInsternState.HorizontalShift;
            }
        }
 private void DirectSyncFromComponentToController(VehicleEntity vehicle, VehicleAbstractInternState state)
 {
     SyncStateFromComponentToController(vehicle, state);
 }