2025-09-24 11:24:38 +05:00
using Fusion ;
namespace TPSBR
{
using UnityEngine ;
2025-10-22 19:35:34 +05:00
public enum EGameplayInputAction
{
Jump = 1 ,
Aim = 2 ,
Attack = 3 ,
Crouch = 4 ,
Reload = 6 ,
Interact = 7 ,
ToggleSide = 8 ,
ToggleJetpack = 9 ,
Thrust = 10 ,
}
2025-09-24 11:24:38 +05:00
public struct GameplayInput : INetworkInput
{
// PUBLIC MEMBERS
public Vector2 MoveDirection ;
public Vector2 LookRotationDelta ;
public NetworkButtons Actions ;
public byte Weapon ;
public float LocalAlpha ; // This value is used for render-accurate actions. Valid range is 0.0 - 1.0 and represents position of the time between current and last fixed tick.
public float InterpolationAlpha ; // This value is used for render-accurate lag compensated casts.
public int InterpolationFromTick ; // This value is used for render-accurate lag compensated casts.
public int InterpolationToTick ; // This value is used for render-accurate lag compensated casts.
public bool Jump { get { return Actions . IsSet ( EGameplayInputAction . Jump ) ; } set { Actions . Set ( EGameplayInputAction . Jump , value ) ; } }
public bool Aim { get { return Actions . IsSet ( EGameplayInputAction . Aim ) ; } set { Actions . Set ( EGameplayInputAction . Aim , value ) ; } }
public bool Attack { get { return Actions . IsSet ( EGameplayInputAction . Attack ) ; } set { Actions . Set ( EGameplayInputAction . Attack , value ) ; } }
2025-10-22 19:35:34 +05:00
public bool Crouch { get { return Actions . IsSet ( EGameplayInputAction . Crouch ) ; } set { Actions . Set ( EGameplayInputAction . Crouch , value ) ; } }
2025-09-24 11:24:38 +05:00
public bool Reload { get { return Actions . IsSet ( EGameplayInputAction . Reload ) ; } set { Actions . Set ( EGameplayInputAction . Reload , value ) ; } }
public bool Interact { get { return Actions . IsSet ( EGameplayInputAction . Interact ) ; } set { Actions . Set ( EGameplayInputAction . Interact , value ) ; } }
public bool ToggleSide { get { return Actions . IsSet ( EGameplayInputAction . ToggleSide ) ; } set { Actions . Set ( EGameplayInputAction . ToggleSide , value ) ; } }
public bool ToggleJetpack { get { return Actions . IsSet ( EGameplayInputAction . ToggleJetpack ) ; } set { Actions . Set ( EGameplayInputAction . ToggleJetpack , value ) ; } }
public bool Thrust { get { return Actions . IsSet ( EGameplayInputAction . Thrust ) ; } set { Actions . Set ( EGameplayInputAction . Thrust , value ) ; } }
}
public static class GameplayInputActionExtensions
{
// PUBLIC METHODS
public static bool IsActive ( this EGameplayInputAction action , GameplayInput input )
{
return input . Actions . IsSet ( action ) = = true ;
}
public static bool WasActivated ( this EGameplayInputAction action , GameplayInput currentInput , GameplayInput previousInput )
{
return currentInput . Actions . IsSet ( action ) = = true & & previousInput . Actions . IsSet ( action ) = = false ;
}
public static bool WasDeactivated ( this EGameplayInputAction action , GameplayInput currentInput , GameplayInput previousInput )
{
return currentInput . Actions . IsSet ( action ) = = false & & previousInput . Actions . IsSet ( action ) = = true ;
}
}
}