Beispiel #1
0
        public void ApplyEvent(IEvent @event)
        {
            switch (@event)
            {
            case GearChanged gearChanged:
                CurrentGear = gearChanged.EnteredGear;
                break;

            case ManualGearshiftingModeEntered _:
                if (_vehicleInTemporalManualControlMode)
                {
                    _service.StopTargetingAnyGear();
                    _tokenSource.Cancel();
                }

                VehicleInManualMode = true;
                break;

            case ManualGearshiftingModeExited _:
                VehicleInManualMode = false;
                break;

            case GearUpshiftedManually _ when !VehicleInManualMode:
                _vehicleInTemporalManualControlMode = true;
                _service.TargetGear(CurrentGear.UpshiftedBy(new Gear(1)));
                RescheduleComebackTimer();
                break;

            case GearDownshiftedManually _ when !VehicleInManualMode:
                _vehicleInTemporalManualControlMode = true;
                _service.TargetGear(CurrentGear.DownshiftedBy(new Gear(1)));
                RescheduleComebackTimer();
                break;
            }
        }
        public void ApplyEvent(IEvent @event)
        {
            switch (@event)
            {
            case GearChanged gearChanged:
                CurrentGear = gearChanged.EnteredGear;
                break;

            case ManualGearshiftingModeEntered _:
                VehicleInManualMode = true;

                SelectedGear = CurrentGear;

                _service.TargetGear(SelectedGear);
                break;

            case ManualGearshiftingModeExited _:
                VehicleInManualMode = false;

                _service.StopTargetingAnyGear();
                break;

            case GearUpshiftedManually _:
                if (!VehicleInManualMode)
                {
                    break;
                }

                SelectedGear = SelectedGear.UpshiftedBy(new Gear(1));
                _service.TargetGear(SelectedGear);
                break;

            case GearDownshiftedManually _:
                if (!VehicleInManualMode)
                {
                    break;
                }

                SelectedGear = SelectedGear.DownshiftedBy(new Gear(1));
                _service.TargetGear(SelectedGear);
                break;
            }
        }