Пример #1
0
 public void Initialize()
 {
     effect = VehicleEffectsMod.FindEffect(effectName) as SoundEffect;
     if (effect == null)
     {
         Logging.LogWarning("Could not find effect: " + effectName + " for sound effect options");
         return;
     }
     EventSlide(savedVolume.value);
 }
Пример #2
0
        private static T CreateSoundEffect <T>(SoundEffectParams settings) where T : SoundEffect
        {
            if (settings == null || string.IsNullOrEmpty(settings.Base) || string.IsNullOrEmpty(settings.Name))
            {
                Logging.LogError("Invalid sound effect settings, name or base is empty");
                return(null);
            }

            var baseEffect = VehicleEffectsMod.FindEffect(settings.Base) as T;

            if (baseEffect == null)
            {
                Logging.LogError("Unable to find base sound effect " + settings.Base + " for effect " + settings.Name);
                return(null);
            }

            if (!File.Exists(settings.SoundFile))
            {
                Logging.LogError("Unable to find sound file for " + settings.Name + " at " + settings.SoundFile);
                return(null);
            }

            var clip = LoadAudioClip(settings.SoundFile);

            if (clip == null)
            {
                Logging.LogError("Unable to load sound file for " + settings.Name + " at " + settings.SoundFile);
                return(null);
            }

            // Create effect
            var effect = new GameObject().AddComponent <T>();

            Util.CopySoundEffect(baseEffect, effect, false);
            effect.m_audioInfo        = UnityEngine.Object.Instantiate(baseEffect.m_audioInfo) as AudioInfo;
            effect.m_audioInfo.m_clip = clip;

            // Apply general settings
            ApplySoundEffectSettings(effect, settings);

            return(effect);
        }
Пример #3
0
        private static EngineSoundEffect CreateEngineSoundEffect(SoundEffectParams settings)
        {
            var effect = CreateSoundEffect <EngineSoundEffect>(settings);

            if (effect == null)
            {
                return(null);
            }
            // Apply base settings, ignoring the audio info
            Util.CopyEngineSoundEffect(VehicleEffectsMod.FindEffect(settings.Base) as EngineSoundEffect, effect, false);
            // Reapply our settings
            ApplySoundEffectSettings(effect, settings);
            ApplyNullableSetting(ref effect.m_minPitch, settings.MinPitch);
            ApplyNullableSetting(ref effect.m_minRange, settings.MinRange);
            ApplyNullableSetting(ref effect.m_pitchAccelerationMultiplier, settings.PitchAccelerationMultiplier);
            ApplyNullableSetting(ref effect.m_pitchSpeedMultiplier, settings.PitchSpeedMultiplier);
            ApplyNullableSetting(ref effect.m_rangeAccelerationMultiplier, settings.RangeAccelerationMultiplier);
            ApplyNullableSetting(ref effect.m_rangeSpeedMultiplier, settings.RangeSpeedMultiplier);

            return(effect);
        }
Пример #4
0
        public static ParticleEffect CreateParticleEffect(ParticleEffectParams settings)
        {
            if (settings == null)
            {
                Logging.LogError("Null passed to CreateParticleEffect");
                return(null);
            }

            if (settings == null || string.IsNullOrEmpty(settings.Base) || string.IsNullOrEmpty(settings.Name))
            {
                Logging.LogError("Invalid particle effect settings, name or base is empty");
                return(null);
            }

            var baseEffect = VehicleEffectsMod.FindEffect(settings.Base) as ParticleEffect;

            if (baseEffect == null)
            {
                Logging.LogError("Unable to find base particle effect " + settings.Base + " for effect " + settings.Name);
                return(null);
            }


            // Create effect
            var effect = new GameObject().AddComponent <CustomMovementParticleEffect>();

            // Apply general settings
            ApplyNullableSettingWithDefault(ref effect.m_canUseBezier, settings.m_canUseBezier, baseEffect.m_canUseBezier);
            ApplyNullableSettingWithDefault(ref effect.m_canUseMeshData, settings.m_canUseMeshData, baseEffect.m_canUseMeshData);
            ApplyNullableSettingWithDefault(ref effect.m_canUsePositions, settings.m_canUsePositions, baseEffect.m_canUsePositions);
            ApplyNullableSettingWithDefault(ref effect.m_extraRadius, settings.m_extraRadius, baseEffect.m_extraRadius);
            effect.m_intensityCurve = baseEffect.m_intensityCurve;
            ApplyNullableSettingWithDefault(ref effect.m_maxLifeTime, settings.m_maxLifeTime, baseEffect.m_maxLifeTime);
            ApplyNullableSettingWithDefault(ref effect.m_maxSpawnAngle, settings.m_maxSpawnAngle, baseEffect.m_maxSpawnAngle);
            ApplyNullableSettingWithDefault(ref effect.m_maxStartSpeed, settings.m_maxStartSpeed, baseEffect.m_maxStartSpeed);
            ApplyNullableSettingWithDefault(ref effect.m_maxVisibilityDistance, settings.m_maxVisibilityDistance, baseEffect.m_maxVisibilityDistance);
            ApplyNullableSettingWithDefault(ref effect.m_minLifeTime, settings.m_minLifeTime, baseEffect.m_minLifeTime);
            ApplyNullableSettingWithDefault(ref effect.m_minSpawnAngle, settings.m_minSpawnAngle, baseEffect.m_minSpawnAngle);
            ApplyNullableSettingWithDefault(ref effect.m_minStartSpeed, settings.m_minStartSpeed, baseEffect.m_minStartSpeed);
            ApplyNullableSettingWithDefault(ref effect.m_renderDuration, settings.m_renderDuration, baseEffect.m_renderDuration);
            ApplyNullableSettingWithDefault(ref effect.m_useSimulationTime, settings.m_useSimulationTime, baseEffect.m_useSimulationTime);

            var baseMovementEffect = baseEffect as MovementParticleEffect;

            if (baseMovementEffect != null)
            {
                ApplyNullableSettingWithDefault(ref effect.m_magnitudeAccelerationMultiplier,
                                                settings.m_magnitudeAccelerationMultiplier,
                                                baseMovementEffect.m_magnitudeAccelerationMultiplier);
                ApplyNullableSettingWithDefault(ref effect.m_magnitudeSpeedMultiplier,
                                                settings.m_magnitudeSpeedMultiplier,
                                                baseMovementEffect.m_magnitudeSpeedMultiplier);
                ApplyNullableSettingWithDefault(ref effect.m_minMagnitude, settings.m_minMagnitude, baseMovementEffect.m_minMagnitude);
            }
            else
            {
                ApplyNullableSetting(ref effect.m_magnitudeAccelerationMultiplier, settings.m_magnitudeAccelerationMultiplier);
                ApplyNullableSetting(ref effect.m_magnitudeSpeedMultiplier, settings.m_magnitudeSpeedMultiplier);
                ApplyNullableSetting(ref effect.m_minMagnitude, settings.m_minMagnitude);
            }

            var baseCustomMovementEffect = baseEffect as CustomMovementParticleEffect;

            if (baseCustomMovementEffect != null)
            {
                ApplyNullableSettingWithDefault(ref effect.m_velocityMultiplier, settings.m_velocityMultiplier, baseCustomMovementEffect.m_velocityMultiplier);
                ApplyNullableSettingWithDefault(ref effect.m_spawnAreaRadius, settings.m_spawnAreaRadius, baseCustomMovementEffect.m_spawnAreaRadius);
            }
            else
            {
                ApplyNullableSetting(ref effect.m_velocityMultiplier, settings.m_velocityMultiplier);
                ApplyNullableSetting(ref effect.m_spawnAreaRadius, settings.m_spawnAreaRadius);
            }

            effect.name = settings.Name;

            // Specify particle system to use
            effect.ParticleSystemOverride = baseEffect.gameObject.GetComponent <ParticleSystem>();

            return(effect);
        }
Пример #5
0
 public void SetMod(VehicleEffectsMod mod)
 {
     this.mod = mod;
 }