Exemplo n.º 1
0
            private static IEnumerator SetupBellLamp(ShunterDashboardControls __instance)
            {
                AudioSource      bellAudioSource;
                ToggleSwitchBase bellSwitch;

                do
                {
                    yield return(null);

                    bellAudioSource = TrainCar.Resolve(__instance.gameObject).transform.Find("AudioShunter(Clone)/Horn/ZSounds bell").GetComponent <AudioSource>();
                    bellSwitch      = __instance.transform.Find("C dashboard buttons controller/C bell switch").GetComponent <ToggleSwitchBase>();
                }while (bellAudioSource == null || bellSwitch == null);

                bellSwitch.SetValue(bellAudioSource.loop ? 1 : 0);

                var bellLampControl = __instance.transform.Find("C dashboard buttons controller/I bell lamp").GetComponent <LampControl>();

                bellLampControl.lampInd = __instance.transform.Find("C dashboard buttons controller/I bell lamp/lamp emmision indicator").GetComponent <IndicatorEmission>();
                bellLampControl.SetLampState(bellAudioSource.loop ? LampControl.LampState.On : LampControl.LampState.Off);

                bellSwitch.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();
                    }
                };
            }
Exemplo n.º 2
0
        static void Postfix(ShunterDashboardControls __instance)
        {
            instance = __instance;

            __instance.StartCoroutine(AttachListeners());
        }
    public void ListenToTrainInputEvents()
    {
        if (!loco.IsLoco && isAlreadyListening)
        {
            return;
        }

        if (loco.logicCar != null)
        {
            Main.Log($"[{loco.ID}] Listen to base loco controller");
        }
        baseController = loco.GetComponent <LocoControllerBase>();
        if (loco.logicCar != null)
        {
            Main.Log($"[{loco.ID}] Listen throttle change on base loco controller");
        }
        baseController.ThrottleUpdated += OnTrainThrottleChanged;
        if (loco.logicCar != null)
        {
            Main.Log($"[{loco.ID}] Listen brake change on base loco controller");
        }
        baseController.BrakeUpdated += OnTrainBrakeChanged;
        if (loco.logicCar != null)
        {
            Main.Log($"[{loco.ID}] Listen indepBrake change on base loco controller");
        }
        baseController.IndependentBrakeUpdated += OnTrainIndependentBrakeChanged;
        if (loco.logicCar != null)
        {
            Main.Log($"[{loco.ID}] Listen reverser change on base loco controller");
        }
        baseController.ReverserUpdated += OnTrainReverserStateChanged;
        if (loco.logicCar != null)
        {
            Main.Log($"[{loco.ID}] Listen sander change on base loco controller");
        }
        baseController.SandersUpdated += OnTrainSanderChanged;

        if (loco.logicCar != null)
        {
            Main.Log($"[{loco.ID}] Listen to specific train events");
        }
        switch (loco.carType)
        {
        case TrainCarType.LocoShunter:
            ShunterDashboardControls shunterDashboard = loco.interior.GetComponentInChildren <ShunterDashboardControls>();
            FuseBoxPowerController   fuseBox          = shunterDashboard.fuseBoxPowerController;
            for (int i = 0; i < fuseBox.sideFusesObj.Length; i++)
            {
                ToggleSwitchBase sideFuse = fuseBox.sideFusesObj[i].GetComponent <ToggleSwitchBase>();
                switch (i)
                {
                case 0:
                    sideFuse.ValueChanged += OnTrainSideFuse_1Changed;
                    break;

                case 1:
                    sideFuse.ValueChanged += OnTrainSideFuse_2Changed;
                    break;
                }
            }
            fuseBox.mainFuseObj.GetComponent <ToggleSwitchBase>().ValueChanged     += OnTrainMainFuseChanged;
            shunterDashboard.hornObj.GetComponent <ControlImplBase>().ValueChanged += ShunterHornUsed;
            SingletonBehaviour <CoroutineManager> .Instance.Run(RotaryAmplitudeCheckerStartListen(fuseBox));

            break;
        }

        isAlreadyListening = true;
    }
Exemplo n.º 4
0
 public static void Postfix(ShunterDashboardControls __instance)
 {
     __instance.StartCoroutine(SetupBellLamp(__instance));
 }