using System; using UnityEngine; #if ENABLE_INPUT_SYSTEM using UnityEngine.InputSystem; #endif namespace NightclubArcadia.Player { /// /// Receives pointer and camera-pan SendMessages from PlayerInput and /// exposes them as C# events for navigation and camera systems. /// [DefaultExecutionOrder(-100)] public sealed class PlayerPointerInput : MonoBehaviour { public Vector2 ScreenPosition { get; private set; } public bool IsPanning { get; private set; } public event Action Clicked; public event Action PanStarted; public event Action PanDelta; public event Action PanEnded; #if ENABLE_INPUT_SYSTEM void OnPoint(InputValue value) { ScreenPosition = value.Get(); } void OnClick(InputValue value) { if (value.isPressed) { Clicked?.Invoke(); } } void OnCameraPan(InputValue value) { if (value.isPressed && !IsPanning) { IsPanning = true; PanStarted?.Invoke(); } else if (!value.isPressed && IsPanning) { IsPanning = false; PanEnded?.Invoke(); } } void OnPointerDelta(InputValue value) { if (IsPanning) { PanDelta?.Invoke(value.Get()); } } #endif } }