public static void Init() { if (platformHelper == null) { platformHelper = Resources.FindObjectsOfTypeAll <VRPlatformHelper>().FirstOrDefault(); } if (platformHelper.vrPlatformSDK == VRPlatformHelper.VRPlatformSDK.OpenVR) { platform = 0; } else if (platformHelper.vrPlatformSDK == VRPlatformHelper.VRPlatformSDK.Oculus) { platform = 1; } else if (Environment.CommandLine.Contains("fpfc") && platformHelper.vrPlatformSDK == VRPlatformHelper.VRPlatformSDK.Unknown) { platform = 2; } else { platform = -1; } initialized = true; }
public static void Init() { if (vrPlatformHelper == null) { vrPlatformHelper = Resources.FindObjectsOfTypeAll <VRPlatformHelper>().FirstOrDefault(); } rumbleEnahncerInstalled = IPA.Loader.PluginManager.AllPlugins.Any(x => x.Metadata.Id == "rumbleenhancer"); Plugin.log.Info("Rumble Enahncer installed: " + rumbleEnahncerInstalled); if (vrPlatformHelper.vrPlatformSDK == VRPlatformHelper.VRPlatformSDK.OpenVR) { platform = 0; } else if (vrPlatformHelper.vrPlatformSDK == VRPlatformHelper.VRPlatformSDK.Oculus) { platform = 1; } else if (Environment.CommandLine.Contains("fpfc") && vrPlatformHelper.vrPlatformSDK == VRPlatformHelper.VRPlatformSDK.Unknown) { platform = 2; } else { platform = -1; } Plugin.log.Info($"Detected platform: {platform}"); initialized = true; }
private void Inject(MainSettingsModelSO mainSettingsModel, ILoggerProvider loggerProvider, IAvatarInput input, SpawnedAvatar spawnedAvatar, VRPlatformHelper vrPlatformHelper, AvatarTailor tailor) { _mainSettingsModel = mainSettingsModel; _logger = loggerProvider.CreateLogger <AvatarTracking>(spawnedAvatar.avatar.descriptor.name); _input = input; _spawnedAvatar = spawnedAvatar; _vrPlatformHelper = vrPlatformHelper; _tailor = tailor; }
public OnlineVRController() { VRController original = GetComponent <VRController>(); foreach (FieldInfo info in original.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic)) { info.SetValue(this, info.GetValue(original)); } _platformHelper = original.GetPrivateField <VRPlatformHelper>("_vrPlatformHelper"); _transformOffset = original.GetPrivateField <VRControllerTransformOffset>("_transformOffset"); Destroy(original); }
private void Inject(MainSettingsModelSO mainSettingsModel, ILoggerProvider loggerProvider, IAvatarInput input, SpawnedAvatar avatar, VRPlatformHelper vrPlatformHelper, AvatarTailor tailor) { _mainSettingsModel = mainSettingsModel; _logger = loggerProvider.CreateLogger <AvatarTracking>(avatar.avatar.descriptor.name); _input = input; _avatar = avatar; _vrPlatformHelper = vrPlatformHelper; _tailor = tailor; if (_avatar.pelvis) { _initialPelvisPose = new Pose(_avatar.pelvis.position, _avatar.pelvis.rotation); } if (_avatar.leftLeg) { _initialLeftFootPose = new Pose(_avatar.leftLeg.position, _avatar.leftLeg.rotation); } if (_avatar.rightLeg) { _initialRightFootPose = new Pose(_avatar.rightLeg.position, _avatar.rightLeg.rotation); } }
private IEnumerator Start() { Saber = gameObject.GetComponent <Saber>(); Controller = gameObject.GetComponent <VRController>(); if (IsLeftSaber) { GlobalTrickManager.Instance.LeftSaberSaberTrickManager = this; } else { GlobalTrickManager.Instance.RightSaberSaberTrickManager = this; } VRPlatformHelper vrPlatformHelper = Controller.GetField <VRPlatformHelper, VRController>("_vrPlatformHelper"); MovementController = gameObject.AddComponent <MovementController>(); MovementController.Controller = Controller; MovementController.VrPlatformHelper = vrPlatformHelper; MovementController.SaberTrickManager = this; _inputManager = gameObject.AddComponent <InputManager>(); _inputManager.Init(Saber.saberType, Controller.GetField <VRControllersInputManager, VRController>("_vrControllersInputManager")); _inputManager.TrickActivated += OnTrickActivated; _inputManager.TrickDeactivated += OnTrickDeactivated; //We need to wait for CustomSabers to potentially change the saber models yield return(WaitForSaberModel(1)); SaberTrickModel = new SaberTrickModel(GetSaberModel()); AddTrick <ThrowTrick>(); AddTrick <SpinTrick>(); Plugin.Log.Debug("Trick Manager initialized"); }
public static bool Prefix(XRNode node, Transform transform, Vector3 addPosition, Vector3 addRotation, VRPlatformHelper __instance) { if (__instance.vrPlatformSDK != VRPlatformHelper.VRPlatformSDK.OpenVR) { return(true); } OpenVRHelper openVRHelper = Traverse.Create(__instance).Field("_openVRHeper").GetValue <OpenVRHelper>(); if (openVRHelper.vrControllerManufacturerName != OpenVRHelper.VRControllerManufacturerName.Valve) { return(true); } transform.Rotate(new Vector3(15f, 0f, 0f) + addRotation); transform.Translate(new Vector3(0f, -0.03f, 0f) + addPosition); return(false); }
public void UpdatePlayerInfo() { if (Client.Instance.playerInfo.avatarHash == null || Client.Instance.playerInfo.avatarHash == "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") { if (Config.Instance.SeparateAvatarForMultiplayer) { Client.Instance.playerInfo.avatarHash = Config.Instance.PublicAvatarHash; } else { Client.Instance.playerInfo.avatarHash = ModelSaberAPI.cachedAvatars.FirstOrDefault(x => x.Value == CustomAvatar.Plugin.Instance.PlayerAvatarManager.GetCurrentAvatar()).Key; } #if DEBUG Misc.Logger.Info("Updating avatar hash... New hash: " + (Client.Instance.playerInfo.avatarHash == null ? "NULL" : Client.Instance.playerInfo.avatarHash)); #endif } if (Client.Instance.playerInfo.avatarHash == null) { Client.Instance.playerInfo.avatarHash = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; } Client.Instance.playerInfo.headPos = GetXRNodeWorldPosRot(XRNode.Head).Position; Client.Instance.playerInfo.headRot = GetXRNodeWorldPosRot(XRNode.Head).Rotation; Client.Instance.playerInfo.leftHandPos = GetXRNodeWorldPosRot(XRNode.LeftHand).Position; Client.Instance.playerInfo.leftHandRot = GetXRNodeWorldPosRot(XRNode.LeftHand).Rotation; Client.Instance.playerInfo.rightHandPos = GetXRNodeWorldPosRot(XRNode.RightHand).Position; Client.Instance.playerInfo.rightHandRot = GetXRNodeWorldPosRot(XRNode.RightHand).Rotation; if (_vrPlatformHelper == null) { _vrPlatformHelper = PersistentSingleton <VRPlatformHelper> .instance; } if (_vrPlatformHelper.vrPlatformSDK == VRPlatformHelper.VRPlatformSDK.Oculus) { Client.Instance.playerInfo.leftHandRot *= oculusTouchRotOffset; Client.Instance.playerInfo.leftHandPos += Client.Instance.playerInfo.leftHandRot * oculusTouchPosOffset; Client.Instance.playerInfo.rightHandRot *= oculusTouchRotOffset; Client.Instance.playerInfo.rightHandPos += Client.Instance.playerInfo.rightHandRot * oculusTouchPosOffset; } else if (_vrPlatformHelper.vrPlatformSDK == VRPlatformHelper.VRPlatformSDK.OpenVR) { Client.Instance.playerInfo.leftHandRot *= openVrRotOffset; Client.Instance.playerInfo.leftHandPos += Client.Instance.playerInfo.leftHandRot * openVrPosOffset; Client.Instance.playerInfo.rightHandRot *= openVrRotOffset; Client.Instance.playerInfo.rightHandPos += Client.Instance.playerInfo.rightHandRot * openVrPosOffset; } if (_currentScene == "GameCore" && loaded) { Client.Instance.playerInfo.playerProgress = audioTimeSync.songTime; } else if (Client.Instance.playerInfo.playerState != PlayerState.DownloadingSongs) { Client.Instance.playerInfo.playerProgress = 0; } if (Config.Instance.SpectatorMode) { Client.Instance.playerInfo.playerScore = 0; Client.Instance.playerInfo.playerEnergy = 0f; Client.Instance.playerInfo.playerCutBlocks = 0; Client.Instance.playerInfo.playerComboBlocks = 0; } Client.Instance.SendPlayerInfo(); }
public void UpdatePlayerInfo() { if (string.IsNullOrEmpty(Client.Instance.playerInfo.avatarHash) || Client.Instance.playerInfo.avatarHash == PlayerInfo.avatarHashPlaceholder) { if (Config.Instance.SeparateAvatarForMultiplayer) { Client.Instance.playerInfo.avatarHash = Config.Instance.PublicAvatarHash; } else { Client.Instance.playerInfo.avatarHash = ModelSaberAPI.cachedAvatars.FirstOrDefault(x => x.Value == CustomAvatar.Plugin.Instance.PlayerAvatarManager.GetCurrentAvatar()).Key; } #if DEBUG if (Client.Instance.playerInfo.avatarHash != PlayerInfo.avatarHashPlaceholder) { Plugin.log.Info("Updating avatar hash... New hash: " + (Client.Instance.playerInfo.avatarHash)); } #endif } Client.Instance.playerInfo.headPos = GetXRNodeWorldPosRot(XRNode.Head).Position; Client.Instance.playerInfo.headRot = GetXRNodeWorldPosRot(XRNode.Head).Rotation; Client.Instance.playerInfo.leftHandPos = GetXRNodeWorldPosRot(XRNode.LeftHand).Position; Client.Instance.playerInfo.leftHandRot = GetXRNodeWorldPosRot(XRNode.LeftHand).Rotation; Client.Instance.playerInfo.rightHandPos = GetXRNodeWorldPosRot(XRNode.RightHand).Position; Client.Instance.playerInfo.rightHandRot = GetXRNodeWorldPosRot(XRNode.RightHand).Rotation; if (CustomAvatar.Plugin.IsFullBodyTracking) { Client.Instance.playerInfo.fullBodyTracking = true; if (CustomAvatar.Plugin.FullBodyTrackingType == CustomAvatar.Plugin.TrackingType.Hips && CustomAvatar.Plugin.Trackers.Count >= 1) { Client.Instance.playerInfo.pelvisPos = GetTrackerWorldPosRot(CustomAvatar.Plugin.Trackers[0]).Position; Client.Instance.playerInfo.pelvisRot = GetTrackerWorldPosRot(CustomAvatar.Plugin.Trackers[0]).Rotation; } else if (CustomAvatar.Plugin.FullBodyTrackingType == CustomAvatar.Plugin.TrackingType.Full && CustomAvatar.Plugin.Trackers.Count >= 3) { Client.Instance.playerInfo.pelvisPos = GetTrackerWorldPosRot(CustomAvatar.Plugin.Trackers[2]).Position; Client.Instance.playerInfo.pelvisRot = GetTrackerWorldPosRot(CustomAvatar.Plugin.Trackers[2]).Rotation; } else { Client.Instance.playerInfo.pelvisPos = new Vector3(); Client.Instance.playerInfo.pelvisRot = new Quaternion(); } if (CustomAvatar.Plugin.FullBodyTrackingType >= CustomAvatar.Plugin.TrackingType.Feet && CustomAvatar.Plugin.Trackers.Count >= 2) { Client.Instance.playerInfo.leftLegPos = GetTrackerWorldPosRot(CustomAvatar.Plugin.Trackers[0]).Position; Client.Instance.playerInfo.leftLegRot = GetTrackerWorldPosRot(CustomAvatar.Plugin.Trackers[0]).Rotation; Client.Instance.playerInfo.rightLegPos = GetTrackerWorldPosRot(CustomAvatar.Plugin.Trackers[1]).Position; Client.Instance.playerInfo.rightLegRot = GetTrackerWorldPosRot(CustomAvatar.Plugin.Trackers[1]).Rotation; } else { Client.Instance.playerInfo.leftLegPos = new Vector3(); Client.Instance.playerInfo.leftLegRot = new Quaternion(); Client.Instance.playerInfo.rightLegPos = new Vector3(); Client.Instance.playerInfo.rightLegRot = new Quaternion(); } } else { Client.Instance.playerInfo.fullBodyTracking = false; } if (_vrPlatformHelper == null) { _vrPlatformHelper = PersistentSingleton <VRPlatformHelper> .instance; } if (_vrPlatformHelper.vrPlatformSDK == VRPlatformHelper.VRPlatformSDK.Oculus) { Client.Instance.playerInfo.leftHandRot *= oculusTouchRotOffset; Client.Instance.playerInfo.leftHandPos += Client.Instance.playerInfo.leftHandRot * oculusTouchPosOffset; Client.Instance.playerInfo.rightHandRot *= oculusTouchRotOffset; Client.Instance.playerInfo.rightHandPos += Client.Instance.playerInfo.rightHandRot * oculusTouchPosOffset; } else if (_vrPlatformHelper.vrPlatformSDK == VRPlatformHelper.VRPlatformSDK.OpenVR) { Client.Instance.playerInfo.leftHandRot *= openVrRotOffset; Client.Instance.playerInfo.leftHandPos += Client.Instance.playerInfo.leftHandRot * openVrPosOffset; Client.Instance.playerInfo.rightHandRot *= openVrRotOffset; Client.Instance.playerInfo.rightHandPos += Client.Instance.playerInfo.rightHandRot * openVrPosOffset; } if (_currentScene == "GameCore" && _loaded) { Client.Instance.playerInfo.playerProgress = audioTimeSync.songTime; } else if (Client.Instance.playerInfo.playerState != PlayerState.DownloadingSongs) { Client.Instance.playerInfo.playerProgress = 0; } if (Config.Instance.SpectatorMode) { Client.Instance.playerInfo.playerScore = 0; Client.Instance.playerInfo.playerEnergy = 0f; Client.Instance.playerInfo.playerCutBlocks = 0; Client.Instance.playerInfo.playerComboBlocks = 0; } Client.Instance.SendPlayerInfo(); }