Refactor, cleanup code and add documentaiton
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
using Core;
|
||||
using AppleHills.Core.Settings;
|
||||
|
||||
namespace UI.CardSystem.StateMachine.States
|
||||
{
|
||||
/// <summary>
|
||||
/// Dragging state - provides visual feedback when card is being dragged.
|
||||
/// The actual drag logic is handled by Card.cs (inherits from DraggableObject).
|
||||
/// This state only manages visual scaling during drag.
|
||||
/// </summary>
|
||||
public class CardDraggingState : AppleState
|
||||
{
|
||||
private CardContext _context;
|
||||
private ICardSystemSettings _settings;
|
||||
private Vector3 _originalScale;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_context = GetComponentInParent<CardContext>();
|
||||
_settings = GameManager.GetSettingsObject<ICardSystemSettings>();
|
||||
}
|
||||
|
||||
public override void OnEnterState()
|
||||
{
|
||||
// Ensure card front is visible and facing camera (in case we transitioned from an unexpected state)
|
||||
if (_context.CardDisplay != null)
|
||||
{
|
||||
_context.CardDisplay.gameObject.SetActive(true);
|
||||
_context.CardDisplay.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||
}
|
||||
|
||||
// Store original scale
|
||||
_originalScale = _context.RootTransform.localScale;
|
||||
|
||||
// Scale up slightly during drag for visual feedback
|
||||
// DraggableObject handles actual position updates
|
||||
_context.RootTransform.localScale = _originalScale * _settings.DragScale;
|
||||
|
||||
Logging.Debug($"[CardDraggingState] Entered drag state for card: {_context.CardData?.Name}, scale: {_settings.DragScale}");
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
// Restore original scale when exiting drag
|
||||
if (_context?.RootTransform != null)
|
||||
{
|
||||
_context.RootTransform.localScale = _originalScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user