Skip to content

Commit 7a6b00a

Browse files
Remove repeated if check
1 parent d2f1cce commit 7a6b00a

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

Mods/Important.cs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -261,24 +261,27 @@ public static void PCButtonClick()
261261
Ray ray = TPC.ScreenPointToRay(Mouse.current.position.ReadValue());
262262
Physics.Raycast(ray, out var Ray, 512f, NoInvisLayerMask());
263263

264-
foreach (Component component in Ray.collider.GetComponents<Component>())
264+
if (Time.time > keyboardDelay)
265265
{
266-
System.Type compType = component.GetType();
267-
string compName = compType.Name;
268-
269-
if (compName == "GorillaPressableButton" || typeof(GorillaPressableButton).IsAssignableFrom(compType) || (compName == "GorillaPlayerLineButton" && Time.time > keyboardDelay))
270-
compType.GetMethod("OnTriggerEnter", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(component, new object[] { GameObject.Find("Player Objects/Player VR Controller/GorillaPlayer/TurnParent/RightHandTriggerCollider").GetComponent<Collider>() });
271-
272-
if (compName == "CustomKeyboardKey" && Time.time > keyboardDelay)
273-
{
274-
keyboardDelay = Time.time + 0.1f;
275-
compType.GetMethod("OnTriggerEnter", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(component, new object[] { GameObject.Find("Player Objects/Player VR Controller/GorillaPlayer/TurnParent/RightHandTriggerCollider").GetComponent<Collider>() });
276-
}
277-
278-
if (compName == "GorillaKeyboardButton" && Time.time > keyboardDelay)
266+
foreach (Component component in Ray.collider.GetComponents<Component>())
279267
{
280-
keyboardDelay = Time.time + 0.1f;
281-
GameEvents.OnGorrillaKeyboardButtonPressedEvent.Invoke(Traverse.Create(component).Field("Binding").GetValue<GorillaKeyboardBindings>());
268+
System.Type compType = component.GetType();
269+
string compName = compType.Name;
270+
271+
if (compName == "GorillaPressableButton" || typeof(GorillaPressableButton).IsAssignableFrom(compType) || (compName == "GorillaPlayerLineButton"))
272+
compType.GetMethod("OnTriggerEnter", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(component, new object[] { GameObject.Find("Player Objects/Player VR Controller/GorillaPlayer/TurnParent/RightHandTriggerCollider").GetComponent<Collider>() });
273+
274+
if (compName == "CustomKeyboardKey")
275+
{
276+
keyboardDelay = Time.time + 0.1f;
277+
compType.GetMethod("OnTriggerEnter", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(component, new object[] { GameObject.Find("Player Objects/Player VR Controller/GorillaPlayer/TurnParent/RightHandTriggerCollider").GetComponent<Collider>() });
278+
}
279+
280+
if (compName == "GorillaKeyboardButton")
281+
{
282+
keyboardDelay = Time.time + 0.1f;
283+
GameEvents.OnGorrillaKeyboardButtonPressedEvent.Invoke(Traverse.Create(component).Field("Binding").GetValue<GorillaKeyboardBindings>());
284+
}
282285
}
283286
}
284287
}

0 commit comments

Comments
 (0)