Example #1
0
        void ReplaceControllers()
        {
            if (!Config.Instance.SpectatorMode || Client.Instance.inRadioMode)
            {
                return;
            }

            audioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();

            _leftSaber      = Resources.FindObjectsOfTypeAll <Saber>().First(x => x.saberType == Saber.SaberType.SaberB);
            _leftController = _leftSaber.GetPrivateField <VRController>("_vrController").gameObject.AddComponent <OnlineVRController>();
            _leftSaber.SetPrivateField("_vrController", _leftController);

            _rightSaber      = Resources.FindObjectsOfTypeAll <Saber>().First(x => x.saberType == Saber.SaberType.SaberA);
            _rightController = _rightSaber.GetPrivateField <VRController>("_vrController").gameObject.AddComponent <OnlineVRController>();
            _rightSaber.SetPrivateField("_vrController", _rightController);

            Plugin.log.Info("Controllers replaced!");

            _scoreController = FindObjectOfType <ScoreController>();

#if DEBUG
            _scoreController.noteWasMissedEvent += _scoreController_noteWasMissedEvent;
            _scoreController.noteWasCutEvent    += _scoreController_noteWasCutEvent;
#endif

            Plugin.log.Info("Score controller found!");

            _energyCounter = FindObjectOfType <GameEnergyCounter>();

            Plugin.log.Info("Energy counter found!");
        }
Example #2
0
        IEnumerator WaitForControllers()
        {
            if (!Config.Instance.SpectatorMode || Client.Instance.InRadioMode)
            {
                yield break;
            }

            Misc.Logger.Info("Waiting for controllers...");
            yield return(new WaitWhile(delegate() { return !Resources.FindObjectsOfTypeAll <Saber>().Any(); }));

            audioTimeSync    = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
            _songAudioSource = audioTimeSync.GetPrivateField <AudioSource>("_audioSource");

            var saberB = Resources.FindObjectsOfTypeAll <Saber>().First(x => x.saberType == Saber.SaberType.SaberB);

            _leftController = saberB.GetPrivateField <VRController>("_vrController").gameObject.AddComponent <OnlineVRController>();
            saberB.SetPrivateField("_vrController", _leftController);

            var saberA = Resources.FindObjectsOfTypeAll <Saber>().First(x => x.saberType == Saber.SaberType.SaberA);

            _rightController = saberA.GetPrivateField <VRController>("_vrController").gameObject.AddComponent <OnlineVRController>();
            saberA.SetPrivateField("_vrController", _rightController);

            _playerController = Resources.FindObjectsOfTypeAll <PlayerController>().First();

            Misc.Logger.Info("Controllers found!");

            _scoreController = FindObjectOfType <ScoreController>();

            Misc.Logger.Info("Score controller found!");
        }