private float Clutching(ISensorModel model, float clutch) { float maxClutch = ClutchMax; // Check if the current situation is the race start if (model.GetCurrentLapTime() < ClutchDeltaTime && Stage_ == Stage.RACE && model.GetDistanceRaced() < ClutchDeltaRaced) { clutch = maxClutch; } // Adjust the current value of the clutch if (clutch > 0) { double delta = ClutchDelta; if(model.GetGear() < 2) { // Apply a stronger clutch output when the gear is one and the race is just started delta /= 2; maxClutch *= ClutchMaxModifier; if(model.GetCurrentLapTime() < ClutchMaxTime) { clutch = maxClutch; } } // Check clutch is not bigger than maximum values clutch = Math.Min(maxClutch, clutch); // If clutch is not at max value decrease it quite quickly if (clutch != maxClutch) { clutch -= (float)delta; clutch = Math.Max(0.0f, clutch); } // if clutch is at max value decrease it very slowly else { clutch -= ClutchDec; } } return clutch; }