Moving some things over to the InputData system.

This commit is contained in:
Dan Foster
2026-02-12 00:02:53 +00:00
parent 2abadf0b3e
commit 13ccde8e96
6 changed files with 142 additions and 261 deletions

View File

@@ -20,43 +20,11 @@ public static class InputData
public static MouseButton middleMouseButton;
public static MouseButton rightMouseButton;
public static Button up;
public static Button down;
public static Button debugButton;
public static Button agentDebugButton;
public static Button fireWeapon;
public static Button reload;
public static Button jump;
public static Button rotateLeft;
public static Button rotateRight;
public static Button cancel;
public static Button floorUp;
public static Button floorDown;
public static Button cameraLeft;
public static Button cameraRight;
public static Button cameraUp;
public static Button cameraDown;
public static Button cameraRotateLeft;
public static Button cameraRotateRight;
public static Button cameraSpeedBoost;
public static Button pauseTime;
public static Button pauseGame;
public static Axis cameraHorizontal;
public static Axis cameraVertical;
#if MARKETING_BUILD
public static Axis fovAxis;
public static Axis cameraUpDownAxis;
public static Axis marketingCameraX;
public static Axis marketingCameraY;
#endif
public static Axis horizontalMovement;
private static List<Button> allButtons = new List<Button>();
private static List<Axis> allAxis = new List<Axis>();
@@ -71,85 +39,20 @@ public static class InputData
middleMouseButton = AddButton( new MouseButton( Defines.Input.kMiddleMouseButton ) );
rightMouseButton = AddButton( new MouseButton( Defines.Input.kRightMouseButton ) );
up = AddButton( new KeyboardButton( KeyCode.UpArrow ) );
down = AddButton( new KeyboardButton( KeyCode.DownArrow ) );
rotateLeft = AddButton( new KeyboardButton( Defines.Input.rotateLeftKey ) );
rotateRight = AddButton( new KeyboardButton( Defines.Input.rotateRightKey ) );
cancel = AddButton( new KeyboardButton( Defines.Input.kCancelKeyCode ) );
pauseGame = AddButton( new KeyboardButton( KeyCode.Escape ) );
debugButton = AddButton( new KeyboardButton( KeyCode.Space ) );
agentDebugButton = AddButton( new KeyboardButton( KeyCode.Z ) );
floorUp = AddButton( new MultiButton(
fireWeapon = AddButton( new MultiButton(
new Button[]
{
new KeyboardButton( KeyCode.Alpha2 ),
new KeyboardButton( KeyCode.G )
} ) );
floorDown = AddButton( new MultiButton(
new Button[]
{
new KeyboardButton( KeyCode.Alpha1 ),
new KeyboardButton( KeyCode.F )
new MouseButton( Defines.Input.kLeftMouseButton),
new KeyboardButton( KeyCode.LeftControl ),
} ) );
reload = AddButton( new KeyboardButton( KeyCode.Space ) );
jump = AddButton( new KeyboardButton( KeyCode.Space ) );
cameraLeft = AddButton( new MultiButton(
new Button[]
{
new KeyboardButton( KeyCode.A ),
new KeyboardButton( KeyCode.LeftArrow )
} ) );
cameraRight = AddButton( new MultiButton(
new Button[]
{
new KeyboardButton( KeyCode.D ),
new KeyboardButton( KeyCode.RightArrow )
} ) );
cameraUp = AddButton( new MultiButton(
new Button[]
{
new KeyboardButton( KeyCode.W ),
new KeyboardButton( KeyCode.UpArrow )
} ) );
cameraDown = AddButton( new MultiButton(
new Button[]
{
new KeyboardButton( KeyCode.S ),
new KeyboardButton( KeyCode.DownArrow )
} ) );
cameraRotateLeft = AddButton( new KeyboardButton( KeyCode.Q ) );
cameraRotateRight = AddButton( new KeyboardButton( KeyCode.E ) );
cameraSpeedBoost = AddButton( new KeyboardButton( KeyCode.LeftShift ) );
pauseTime = AddButton( new KeyboardButton( KeyCode.Space ) );
inputConfig.Default.Enable();
cameraHorizontal = AddAxis( new MultiAxis(
horizontalMovement = AddAxis( new MultiAxis(
new Axis[]
{
new InputActionAxis( inputConfig.Default.CameraHorizontal )
new ButtonAxis( new KeyboardButton( KeyCode.A ), new KeyboardButton( KeyCode.D ) )
} ) );
cameraVertical = AddAxis( new MultiAxis(
new Axis[]
{
new InputActionAxis( inputConfig.Default.CameraVertical )
} ) );
#if MARKETING_BUILD
inputConfig.Marketing.Enable();
fovAxis = AddAxis( new InputActionAxis( inputConfig.Marketing.CameraFOV ) );
cameraUpDownAxis = AddAxis( new InputActionAxis( inputConfig.Marketing.CameraUpDown ) );
marketingCameraX = AddAxis( new InputActionAxis( inputConfig.Marketing.CameraRotationX ) );
marketingCameraY = AddAxis( new InputActionAxis( inputConfig.Marketing.CameraRotationY ) );
#endif
}
public static T AddButton<T>( T value ) where T : Button
@@ -331,7 +234,7 @@ public static class InputData
public abstract float GetAxisValue();
public virtual void Update()
public virtual void Update( float unscaledTime)
{
value = GetAxisValue();
}
@@ -406,6 +309,13 @@ public static class InputData
{
return ( positiveButton.down ? 1.0f : 0.0f ) + ( negativeButton.down ? -1.0f : 0.0f );
}
public override void Update( float unscaledTime )
{
positiveButton.Update( unscaledTime );
negativeButton.Update( unscaledTime );
base.Update( unscaledTime );
}
}
public class InputActionAxis : Axis
@@ -458,7 +368,7 @@ public static class InputData
foreach( Axis i in allAxis )
{
i.Update();
i.Update( unscaledTime);
}
#if UNITY_STANDALONE_WIN