Skip to content

Commit 9a617e9

Browse files
authored
Change tool hiding logic in the dream (#531)
1 parent 4af0a10 commit 9a617e9

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

NomaiVR/Tools/HoldTranslator.cs

-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ public override void ApplyPatches()
177177
{
178178
Postfix<ToolModeSwapper>(nameof(ToolModeSwapper.IsTranslatorEquipPromptAllowed), nameof(IsPromptAllowed));
179179
Postfix<ToolModeSwapper>(nameof(ToolModeSwapper.GetAutoEquipTranslator), nameof(IsPromptAllowed));
180-
Postfix<ToolModeSwapper>(nameof(ToolModeSwapper.IsNomaiTextInFocus), nameof(IsPromptAllowed));
181180
}
182181

183182
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Unusued parameter is needed for return value passthrough.")]

NomaiVR/Tools/HolsterTool.cs

+12-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ internal class HolsterTool : MonoBehaviour
1616
public float scale;
1717
private MeshRenderer[] renderers;
1818
private bool visible = true;
19+
private bool showInDream = false;
1920
private int equippedIndex = -1;
2021
private Transform hand;
2122
public Action ONUnequip;
@@ -100,13 +101,22 @@ private void OnGripUpdated(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sour
100101

101102
private bool IsHandNear(Transform hand) => (hand.position - cachedTransform.position).sqrMagnitude < minHandDistance;
102103

104+
private void UpdateDreamVisibility(bool isInDream)
105+
{
106+
if (!isInDream) showInDream = false;
107+
else showInDream |= (mode == ToolMode.Translator && VRToolSwapper.NomaiTextFocused);
108+
}
109+
103110
private void UpdateVisibility()
104111
{
105112
var isCharacterMode = OWInput.IsInputMode(InputMode.Character);
106-
var isInDream = Locator.GetDreamWorldController() != null && Locator.GetDreamWorldController().IsInDream();
107113
var isHoldingVisionTorch = Locator.GetToolModeSwapper()?.GetItemCarryTool()?.GetHeldItemType() == ItemType.VisionTorch;
108114
var isHandClose = !ModSettings.AutoHideToolbelt || IsHandNear(HandsController.Behaviour.RightHand) || IsHandNear(HandsController.Behaviour.LeftHand);
109-
var shouldBeVisible = !ToolHelper.IsUsingAnyTool() && isCharacterMode && !isInDream && !isHoldingVisionTorch && isHandClose;
115+
var isInDream = Locator.GetDreamWorldController() != null && Locator.GetDreamWorldController().IsInDream();
116+
117+
UpdateDreamVisibility(isInDream);
118+
119+
var shouldBeVisible = !ToolHelper.IsUsingAnyTool() && isCharacterMode && (!isInDream || showInDream) && !isHoldingVisionTorch && isHandClose;
110120

111121
if (!visible && shouldBeVisible)
112122
{

NomaiVR/Tools/VRToolSwapper.cs

+12
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ internal class VRToolSwapper : NomaiVRModule<NomaiVRModule.EmptyBehaviour, VRToo
1919
public static event Action Equipped;
2020
public static event Action UnEquipped;
2121

22+
public static bool NomaiTextFocused = false;
23+
2224
private static readonly Dictionary<ToolMode, bool> toolsAllowedToEquip = new Dictionary<ToolMode, bool>() {
2325
{ ToolMode.Item, true }
2426
};
@@ -72,6 +74,7 @@ public override void ApplyPatches()
7274
{
7375
Prefix<ToolModeSwapper>(nameof(ToolModeSwapper.EquipToolMode), nameof(PreEquipTool));
7476
Prefix<ShipCockpitController>(nameof(ShipCockpitController.OnPressInteract), nameof(PreShipCockpitController));
77+
Postfix<ToolModeSwapper>(nameof(ToolModeSwapper.IsNomaiTextInFocus), nameof(PreIsNomaiTextInFocus));
7578
}
7679

7780
private static void PreShipCockpitController()
@@ -83,6 +86,15 @@ private static bool PreEquipTool(ToolMode mode)
8386
{
8487
return IsAllowedToEquip(mode);
8588
}
89+
90+
91+
92+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Unusued parameter is needed for return value passthrough.")]
93+
private static bool PreIsNomaiTextInFocus(bool __result)
94+
{
95+
NomaiTextFocused = __result;
96+
return false;
97+
}
8698
}
8799
}
88100
}

0 commit comments

Comments
 (0)