first commit
This commit is contained in:
47
Code/Input/InputResolver.cs
Normal file
47
Code/Input/InputResolver.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using Sandbox;
|
||||
|
||||
namespace VeloX;
|
||||
public class InputResolver
|
||||
{
|
||||
public GameObject Driver { get; internal set; }
|
||||
|
||||
|
||||
private bool IsDriverActive => Driver.IsValid();
|
||||
|
||||
|
||||
public Vector2 MouseDelta => IsDriverActive ? Input.MouseDelta : default;
|
||||
public Vector2 MouseWheel => IsDriverActive ? Input.MouseWheel : default;
|
||||
public Angles AnalogLook => IsDriverActive ? Input.AnalogLook : default;
|
||||
public Vector3 AnalogMove => IsDriverActive ? Input.AnalogMove : default;
|
||||
|
||||
public bool Down( string action )
|
||||
{
|
||||
return IsDriverActive && Input.Down( action );
|
||||
}
|
||||
|
||||
public bool Pressed( string action )
|
||||
{
|
||||
return IsDriverActive && Input.Pressed( action );
|
||||
}
|
||||
|
||||
public bool Released( string action )
|
||||
{
|
||||
return IsDriverActive && Input.Released( action );
|
||||
}
|
||||
|
||||
public void TriggerHaptics( float leftMotor, float rightMotor, float leftTrigger = 0f, float rightTrigger = 0f, int duration = 500 )
|
||||
{
|
||||
if ( IsDriverActive )
|
||||
{
|
||||
Input.TriggerHaptics( leftMotor, rightMotor, leftTrigger, rightTrigger, duration );
|
||||
}
|
||||
}
|
||||
|
||||
public void StopAllHaptics()
|
||||
{
|
||||
if ( IsDriverActive )
|
||||
{
|
||||
Input.StopAllHaptics();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user