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!"); }
static void SetSaberLength(Saber saber, float length) { var saberTop = saber.GetPrivateField <Transform>("_topPos"); var saberBottom = saber.GetPrivateField <Transform>("_bottomPos"); saberTop.localPosition = new Vector3(saberTop.localPosition.x, saberTop.localPosition.y, saberBottom.localPosition.z + length); var trail = Resources.FindObjectsOfTypeAll <GameCoreInstaller>().FirstOrDefault() ?.GetPrivateField <BasicSaberModelController>("_basicSaberModelControllerPrefab") ?.GetPrivateField <SaberWeaponTrail>("_saberWeaponTrail"); if (trail != null) { var trailTop = trail.GetPrivateField <Transform>("_pointEnd"); var trailBottom = trail.GetPrivateField <Transform>("_pointStart"); trailTop.localPosition = new Vector3(trailTop.localPosition.x, trailTop.localPosition.y, trailBottom.localPosition.z + length); } }