private static Settings GetDefaultSettings(LocoTrainAudio audio) { if (audio is LocoAudioShunter audioShunter) { return(new Settings { fadeInStart = audioShunter.engineOnClip.length * 0.15f, fadeOutStart = audioShunter.engineOffClip.length * 0.10f, }); } else if (audio is LocoAudioDiesel audioDiesel) { return(new Settings { fadeInStart = audioDiesel.engineOnClip.length * 0.15f, fadeOutStart = audioDiesel.engineOffClip.length * 0.10f, }); } else if ((UnityModManager.FindMod("DVCustomCarLoader")?.Loaded ?? false) && audio is CustomLocoAudioDiesel audioCustom) { return(new Settings { fadeInStart = audioCustom.engineOnClip.length * 0.15f, fadeOutStart = audioCustom.engineOffClip.length * 0.10f, }); } else { throw new System.Exception($"{audio.GetType().Name} received by EngineFade"); } }
public static void SetFadeSettings(LocoTrainAudio audio, Settings fadeSettings) { settings[audio] = fadeSettings; }
public static float GetFadeOutDuration(LocoTrainAudio audio) => GetSettings(audio).fadeOutDuration;
public static float GetFadeOutStart(LocoTrainAudio audio) => GetSettings(audio).fadeOutStart;
private static Settings GetSettings(LocoTrainAudio audio) { return(settings.ContainsKey(audio) ? settings[audio] : GetDefaultSettings(audio)); }