mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2026-02-04 17:06:10 +00:00
mass commit of laziness
This commit is contained in:
parent
ce992c70ee
commit
6d4fc549d9
167 changed files with 5471 additions and 675 deletions
85
.Deprecated/SuperAwesomeMod/Interaction/Input/CustomInput.cs
Normal file
85
.Deprecated/SuperAwesomeMod/Interaction/Input/CustomInput.cs
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
using ABI_RC.Core;
|
||||
using ABI_RC.Core.InteractionSystem;
|
||||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using ABI_RC.Systems.InputManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace NAK.SuperAwesomeMod.Interaction;
|
||||
|
||||
[DefaultExecutionOrder(1000)]
|
||||
public class CustomBaseInput : BaseInput
|
||||
{
|
||||
private Vector2 mousePositionCache;
|
||||
|
||||
#region Input Overrides
|
||||
|
||||
public override Vector2 mousePosition => Input.mousePosition;
|
||||
|
||||
public override bool GetMouseButton(int button)
|
||||
=> button == (int)CVRHand.Right
|
||||
? CVRInputManager.Instance.interactLeftValue > 0.75f
|
||||
: CVRInputManager.Instance.interactRightValue > 0.75f;
|
||||
|
||||
public override bool GetMouseButtonDown(int button)
|
||||
=> button == (int)CVRHand.Right
|
||||
? CVRInputManager.Instance.interactLeftDown
|
||||
: CVRInputManager.Instance.interactRightDown;
|
||||
|
||||
public override Vector2 mouseScrollDelta => Vector2.zero;
|
||||
|
||||
public override float GetAxisRaw(string axisName)
|
||||
{
|
||||
return axisName switch
|
||||
{
|
||||
"Mouse ScrollWheel" => CVRInputManager.Instance.scrollValue,
|
||||
"Horizontal" => CVRInputManager.Instance.movementVector.x,
|
||||
"Vertical" => CVRInputManager.Instance.movementVector.y,
|
||||
_ => 0f
|
||||
};
|
||||
}
|
||||
|
||||
public override bool GetButtonDown(string buttonName)
|
||||
{
|
||||
return buttonName switch
|
||||
{
|
||||
"Mouse ScrollWheel" => CVRInputManager.Instance.scrollValue > 0.1f,
|
||||
"Horizontal" => CVRInputManager.Instance.movementVector.x > 0.5f,
|
||||
"Vertical" => CVRInputManager.Instance.movementVector.y > 0.5f,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
#endregion Input Overrides
|
||||
|
||||
private CVRHand lastInteractHand;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!MetaPort.Instance.isUsingVr)
|
||||
{
|
||||
mousePositionCache = Input.mousePosition;
|
||||
return;
|
||||
}
|
||||
|
||||
ControllerRay leftRay = PlayerSetup.Instance.vrRayLeft;
|
||||
ControllerRay rightRay = PlayerSetup.Instance.vrRayRight;
|
||||
|
||||
if (leftRay._interactDown) lastInteractHand = leftRay.hand;
|
||||
if (rightRay._interactDown) lastInteractHand = rightRay.hand;
|
||||
|
||||
Camera vrCamera = PlayerSetup.Instance.vrCam;
|
||||
|
||||
// transform the raycast position to screen position
|
||||
Vector3 hitPoint = lastInteractHand == CVRHand.Left
|
||||
? leftRay.HitPoint
|
||||
: rightRay.HitPoint;
|
||||
|
||||
Vector3 screenPoint = vrCamera.WorldToScreenPoint(hitPoint);
|
||||
screenPoint.x = Mathf.Clamp(screenPoint.x, 0, Screen.width);
|
||||
screenPoint.y = Mathf.Clamp(screenPoint.y, 0, Screen.height);
|
||||
mousePositionCache = new Vector2(screenPoint.x, screenPoint.y);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue