Update assets, working save kerfuffle

This commit is contained in:
Michal Pikulski
2025-11-17 14:30:07 +01:00
parent ee07d89d3e
commit c6f635f871
30 changed files with 44358 additions and 462 deletions

View File

@@ -6,12 +6,7 @@ using UnityEngine;
namespace UI.CardSystem.StateMachine
{
/// <summary>
/// Main Card controller component.
/// Orchestrates the card state machine, context, and animator.
/// Inherits from DraggableObject to provide drag/drop capabilities for album placement.
/// This is the single entry point for working with cards.
/// </summary>
// ...existing code...
public class Card : DraggableObject
{
[Header("Components")]
@@ -57,34 +52,45 @@ namespace UI.CardSystem.StateMachine
{
base.OnDragStartedHook();
// Always emit the generic drag started event - consumers can decide what to do
// Always emit the generic drag started event for external consumers (AlbumViewPage, etc.)
context?.NotifyDragStarted();
string current = GetCurrentStateName();
if (current == "PendingFaceDownState")
// Check if current state wants to handle drag behavior
if (stateMachine?.currentState != null)
{
// Let the state handle the flip transition
var pendingState = GetStateComponent<States.CardPendingFaceDownState>("PendingFaceDownState");
if (pendingState != null)
var dragHandler = stateMachine.currentState.GetComponent<ICardStateDragHandler>();
if (dragHandler != null && dragHandler.OnCardDragStarted(context))
{
pendingState.OnDragStarted();
return; // State handled it, don't do default behavior
}
}
else
{
Logging.Debug($"[Card] Drag started on {CardData?.Name}, transitioning to DraggingState");
ChangeState("DraggingState");
}
// Default behavior: transition to DraggingState
Logging.Debug($"[Card] Drag started on {CardData?.Name}, transitioning to DraggingState");
ChangeState("DraggingState");
}
protected override void OnDragEndedHook()
{
base.OnDragEndedHook();
// Always emit the generic drag ended event for external consumers
context?.NotifyDragEnded();
// Check if current state wants to handle drag end
if (stateMachine?.currentState != null)
{
var dragHandler = stateMachine.currentState.GetComponent<ICardStateDragHandler>();
if (dragHandler != null && dragHandler.OnCardDragEnded(context))
{
return; // State handled it
}
}
// Default behavior for states that don't implement custom drag end
string current = GetCurrentStateName();
if (current == "DraggingState")
{
// Existing logic
if (CurrentSlot is AlbumCardSlot albumSlot)
{
Logging.Debug($"[Card] Dropped in album slot, transitioning to PlacedInSlotState");
@@ -102,22 +108,6 @@ namespace UI.CardSystem.StateMachine
ChangeState("RevealedState");
}
}
else if (current == "DraggingRevealedState")
{
// Pending revealed drag state end
if (CurrentSlot is AlbumCardSlot albumSlot)
{
var placedState = GetStateComponent<States.CardPlacedInSlotState>("PlacedInSlotState");
if (placedState != null) placedState.SetParentSlot(albumSlot);
ChangeState("PlacedInSlotState");
OnPlacedInAlbumSlot?.Invoke(this, albumSlot);
}
else
{
// Return to corner face-down
ChangeState("PendingFaceDownState");
}
}
}
#endregion
@@ -151,16 +141,6 @@ namespace UI.CardSystem.StateMachine
SetDraggingEnabled(false); // Booster cards cannot be dragged
}
/// <summary>
/// Setup for album placement flow (starts at RevealedState, can be dragged)
/// Dragging is ENABLED for album placement cards
/// </summary>
public void SetupForAlbumPlacement(CardData data)
{
SetupCard(data, "RevealedState");
SetDraggingEnabled(true); // Album placement cards can be dragged
}
/// <summary>
/// Setup for album placement (starts at PlacedInSlotState)
/// Dragging is DISABLED once placed in slot