private async Task SetOffsetDelay(ControllerOffset.OffsetType offsetType, float value) { await offsetSemaphore.WaitAsync(); if (offsetToApply == null) { offsetToApply = new ControllerOffset(positionOffset, rotationOffset); offsetToApply.SetValue(offsetType, value); offsetSemaphore.Release(); do { await waitSemaphore.WaitAsync(); waitAgain = false; waitSemaphore.Release(); await Task.Delay(1000); } while (waitAgain); await offsetSemaphore.WaitAsync(); positionOffset.value = new Vector3(Mathf.Clamp(offsetToApply.positionX, -0.1f, 0.1f), Mathf.Clamp(offsetToApply.positionY, -0.1f, 0.1f), Mathf.Clamp(offsetToApply.positionZ, -0.1f, 0.1f)); rotationOffset.value = new Vector3(Mathf.Clamp(offsetToApply.rotationX, -180f, 180f), Mathf.Clamp(offsetToApply.rotationY, -180f, 180f), Mathf.Clamp(offsetToApply.rotationZ, -180f, 180f)); offsetToApply = null; offsetSemaphore.Release(); UpdateOffsetValues(); } else { offsetToApply.SetValue(offsetType, value); offsetSemaphore.Release(); await waitSemaphore.WaitAsync(); waitAgain = true; waitSemaphore.Release(); } }
public virtual void Initialize() { offsetSemaphore = new SemaphoreSlim(1, 1); offsetToApply = null; waitSemaphore = new SemaphoreSlim(1, 1); waitAgain = false; controllerOffsetPresetsModalController.offsetPresetLoadedEvent += UpdateOffsetValues; }
public void Register(ControllerOffset controller) { this.controllers.Add(controller); controller.SetStrategy(factory.Create(controller)); controller.SetVisible(controllersVisible); if (currentPrefab != null) { controller.SetFoodPrefab(currentPrefab); } }
private void CreatePreset(string presetName) { if (presetName != "" && !PluginConfig.Instance.OffsetPresets.ContainsKey(presetName)) { ControllerOffset newPreset = new ControllerOffset(); PluginConfig.Instance.OffsetPresets.Add(presetName, newPreset); customListTableData.data.Add(new CustomListTableData.CustomCellInfo(presetName, newPreset.ToString())); customListTableData.tableView.ScrollToCellWithIdx(customListTableData.data.Count, TableView.ScrollPositionType.End, true); customListTableData.tableView.ReloadData(); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ScrollButtonsEnabled))); } }
private void LoadPreset() { if (selectedIndex != -1) { ControllerOffset selectedPreset = PluginConfig.Instance.OffsetPresets[customListTableData.data[selectedIndex].text]; positionOffset.value = new Vector3(Mathf.Clamp(selectedPreset.positionX, -0.1f, 0.1f), Mathf.Clamp(selectedPreset.positionY, -0.1f, 0.1f), Mathf.Clamp(selectedPreset.positionZ, -0.1f, 0.1f)); rotationOffset.value = new Vector3(Mathf.Clamp(selectedPreset.rotationX, -180f, 180f), Mathf.Clamp(selectedPreset.rotationY, -180f, 180f), Mathf.Clamp(selectedPreset.rotationZ, -180f, 180f)); offsetPresetLoadedEvent?.Invoke(); customListTableData.tableView.ClearSelection(); selectedIndex = -1; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ModifyButtonsEnabled))); } }
private void SavePreset() { if (selectedIndex != -1) { ControllerOffset selectedPreset = new ControllerOffset(positionOffset, rotationOffset); PluginConfig.Instance.OffsetPresets[customListTableData.data[selectedIndex].text] = selectedPreset; customListTableData.data[selectedIndex].subtext = selectedPreset.ToString(); customListTableData.tableView.ClearSelection(); customListTableData.tableView.ReloadData(); customListTableData.tableView.ScrollToCellWithIdx(selectedIndex, TableView.ScrollPositionType.Center, false); selectedIndex = -1; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ModifyButtonsEnabled))); } }
private Vector3 GetPositionByOffset(ControllerOffset offset) { switch (offset) { case ControllerOffset.Standard: return(FinchVR.State.GetPosition(Bone)); case ControllerOffset.Wrist: return(Chirality == FinchChirality.Right ? FinchVR.State.GetPosition(FinchBone.RightHand) : FinchVR.State.GetPosition(FinchBone.LeftHand)); case ControllerOffset.Elbow: return(Chirality == FinchChirality.Right ? FinchVR.State.GetPosition(FinchBone.RightLowerArm) : FinchVR.State.GetPosition(FinchBone.LeftLowerArm)); case ControllerOffset.Shoulder: return(Chirality == FinchChirality.Right ? FinchVR.State.GetPosition(FinchBone.RightUpperArm) : FinchVR.State.GetPosition(FinchBone.LeftUpperArm)); default: return(FinchVR.State.GetPosition(Bone)); } }
public IOffsetStrategy Create(ControllerOffset controller) { return(new TranslationOffsetStrategy(controller.transform, controller.actual, controller.head, translation)); }
public IOffsetStrategy Create(ControllerOffset controller) { return(new WobbleOffsetStrategy(controller.transform, controller.actual, controller.head, controller.fork)); }
public static void InitPlayerSettings(FinchChirality handedness = FinchChirality.Right, ControllerOffset offset = ControllerOffset.Standard) { preferredHandedness = (FinchChirality)PlayerPrefs.GetInt(PreferredHandednessKey, (int)handedness); controllerOffset = (ControllerOffset)PlayerPrefs.GetInt(ControllerOffsetKey, (int)offset); }
private void OnEnable() { _controllerOffset = target as ControllerOffset; _offsetPositionProperty = serializedObject.FindProperty("_offset"); _rotationProperty = serializedObject.FindProperty("_rotation"); }
public IOffsetStrategy Create(ControllerOffset controller) { return(new LagOffsetStrategy(controller.transform, controller.actual, this.delay)); }
public IOffsetStrategy Create(ControllerOffset controller) { return(new TruthOffsetStrategy(controller.transform, controller.actual)); }