Развитие гоночек

This commit is contained in:
ThomasCharester committed 2026-02-06 10:30:50 +03:00
1 parent ec60c47652
commit b54083521f
532 files changed
+16091 -28231

No files matched your search

@@ -0,0 +1,32 @@
using Code.Infrastructure.Input;
using Reflex.Attributes;
using UnityEngine;
using UnityEngine.InputSystem;
namespace Code.Example.Race.Racer.Player
{
public class PlayerCarInput : MonoBehaviour
{
private IInputService _inputService;
public Vector2 MovementInput { get; private set; }
[Inject]
public void Construct(IInputService inputService)
{
_inputService = inputService;
_inputService.BindActionPerformed((int)ActionMappings.Gameplay, (int)GameplayActions.Move, MovementPerformed);
_inputService.BindActionCancel((int)ActionMappings.Gameplay, (int)GameplayActions.Move, MovementEnded);
}
private void MovementPerformed(InputAction.CallbackContext context) => MovementInput = context.ReadValue<Vector2>();
private void MovementEnded(InputAction.CallbackContext context) => MovementInput = Vector2.zero;
private void OnDestroy()
{
if (_inputService == null) return;
_inputService.UnbindActionPerformed((int)ActionMappings.Gameplay, (int)GameplayActions.Move, MovementPerformed);
_inputService.UnbindActionCanceled((int)ActionMappings.Gameplay, (int)GameplayActions.Move, MovementEnded);
}
}
}