using Core.SaveLoad; using UnityEngine; using Core; using AppleHills.Core.Settings; namespace UI.CardSystem.StateMachine.States { /// /// Dragging state - handles card being dragged for album placement. /// Integrates with existing drag/drop system. /// public class CardDraggingState : AppleState { private CardContext _context; private ICardSystemSettings _settings; private Vector3 _originalScale; private Vector3 _dragStartPosition; private void Awake() { _context = GetComponentInParent(); _settings = GameManager.GetSettingsObject(); } public override void OnEnterState() { // Store original transform _originalScale = _context.RootTransform.localScale; _dragStartPosition = _context.RootTransform.position; // Scale up slightly during drag for visual feedback _context.RootTransform.localScale = _originalScale * _settings.DragScale; Logging.Debug($"[CardDraggingState] Entered drag state for card: {_context.CardData?.Name}"); } /// /// Update drag position (called by external drag handler) /// public void UpdateDragPosition(Vector3 worldPosition) { _context.RootTransform.position = worldPosition; } /// /// Called when drag is released and card snaps to slot /// public void OnDroppedInSlot() { _context.StateMachine.ChangeState("PlacedInSlotState"); } /// /// Called when drag is released but not over valid slot /// public void OnDroppedOutsideSlot() { // Return to revealed state _context.StateMachine.ChangeState("RevealedState"); } private void OnDisable() { // Restore original scale when exiting drag if (_context?.RootTransform != null) { _context.RootTransform.localScale = _originalScale; } } } }