private static IEnumerator SetupBellLamp(DieselDashboardControls __instance) { AudioSource bellAudioSource; do { yield return(null); bellAudioSource = TrainCar.Resolve(__instance.gameObject).transform.Find("AudioDiesel(Clone)/Horn/ZSounds bell").GetComponent <AudioSource>(); }while (bellAudioSource == null); var bellButton = __instance.transform.Find("offset/C bell button").GetComponent <ButtonBase>(); bellButton.SetValue(bellAudioSource.loop ? 1 : 0); var bellLampControl = __instance.transform.Find("offset/I Indicator lamps/I bell_lamp").GetComponent <LampControl>(); bellLampControl.lampInd = __instance.transform.Find("offset/I Indicator lamps/I bell_lamp/lamp emmision indicator").GetComponent <IndicatorEmission>(); bellLampControl.SetLampState(bellAudioSource.loop ? LampControl.LampState.On : LampControl.LampState.Off); bellButton.ValueChanged += (ValueChangedEventArgs e) => { bellLampControl.SetLampState(e.newValue >= 0.5f ? LampControl.LampState.On : LampControl.LampState.Off); bellAudioSource.loop = e.newValue >= 0.5f; if (bellAudioSource.loop && !bellAudioSource.isPlaying) { bellAudioSource.Play(); } }; }
private static IEnumerator ResetHornCallback(DieselDashboardControls __instance) { while ((__instance.hornControl?.ValueChanged?.GetInvocationList()?.Length ?? 0) == 0) { yield return(null); } var hornControl = __instance.hornControl !; hornControl.ValueChanged = null; hornControl.ValueChanged += e => __instance.horn.SetInput(e.newValue); }
public static void Postfix(DieselDashboardControls __instance) { __instance.StartCoroutine(ResetHornCallback(__instance)); }
public static void Postfix(DieselDashboardControls __instance) { __instance.StartCoroutine(SetupBellLamp(__instance)); }
static void Postfix(DieselDashboardControls __instance) { instance = __instance; __instance.StartCoroutine(AttachListeners()); }