示例#1
0
        private void GetAccelerationSound()
        {
            WheelSpeed = VehicleControl.GetWheelRotationSpeeds(Vehicle)[3];

            // Define engine sound variation based on wheel speed
            _currentAccel = _engineAccell1Sound;

            if (CurrentGear == 2)
            {
                _currentAccel = _engineAccell2Sound;
            }
            if (CurrentGear == 3)
            {
                _currentAccel = _engineAccell3Sound;
            }
            if (CurrentGear >= 4)
            {
                _currentAccel = _engineAccell4Sound;
            }
        }
示例#2
0
        public EngineHandler(TimeCircuits circuits) : base(circuits)
        {
            OnGearUp      += OnGearUpEvent;
            OnGearDown    += OnGearDownEvent;
            OnGearChanged += OnGearChangedEvent;

            var audioEngine = circuits.AudioEngine;

            _engineSounds = new List <AudioPlayer>
            {
                (_engineIdleSound = audioEngine.Create($"{SoundsFolder}idle.wav", Presets.ExteriorLoop)),
                (_engineRevvingSound = audioEngine.Create($"{SoundsFolder}revving.wav", Presets.Exterior)),

                (_engineAccell1Sound = audioEngine.Create($"{SoundsFolder}acceleration1.wav", Presets.Exterior)),
                (_engineAccell2Sound = audioEngine.Create($"{SoundsFolder}acceleration2.wav", Presets.Exterior)),
                (_engineAccell3Sound = audioEngine.Create($"{SoundsFolder}acceleration3.wav", Presets.Exterior)),
                (_engineAccell4Sound = audioEngine.Create($"{SoundsFolder}acceleration4.wav", Presets.Exterior)),

                (_engineDecellSound = audioEngine.Create($"{SoundsFolder}decelleration.wav", Presets.Exterior)),
                (_engineNeutralSound = audioEngine.Create($"{SoundsFolder}neutral.wav", Presets.ExteriorLoop)),
                (_engineReverseSound = audioEngine.Create($"{SoundsFolder}reverse.wav", Presets.Exterior))
            };

            // Configure audio properties
            foreach (var sound in _engineSounds)
            {
                sound.SourceBone      = "engine";
                sound.Volume          = 0.65f;
                sound.MinimumDistance = 3f;
                sound.StopFadeOut     = true;
            }

            _accellSounds = new List <AudioPlayer>
            {
                _engineAccell1Sound, _engineAccell2Sound, _engineAccell3Sound, _engineAccell4Sound
            };

            _engineNeutralSound.FadeInMultiplier = 0.05f;
            _engineIdleSound.FadeInMultiplier    = 0.05f;

            _engineIdleSound.FadeInMultiplier     = 0.6f;
            _engineNeutralSound.FadeOutMultiplier = 0.4f;
            _engineDecellSound.FadeOutMultiplier  = 0.3f;
            _engineReverseSound.FadeOutMultiplier = 0.7f;

            _engineNeutralSound.MinimumDistance = 2f;
            _engineIdleSound.MinimumDistance    = 1f;
            _engineIdleSound.Volume             = 0.35f;

            foreach (var sound in _accellSounds)
            {
                sound.FadeOutMultiplier = 0.9f;
            }

            // Create allowed materials list for acceleration prediction
            _allowedSurfaces = new List <MaterialHash>
            {
                MaterialHash.Concrete,
                MaterialHash.ConcreteDusty,
                MaterialHash.MetalSolidRoadSurface,
                MaterialHash.Brick,
                MaterialHash.PavingSlab,
                MaterialHash.Tarmac,
                MaterialHash.TarmacPainted
            };
        }