Working refactor of cleaned up card structure
This commit is contained in:
@@ -19,8 +19,8 @@ namespace UI.CardSystem.StateMachine
|
||||
[Header("Card Data")]
|
||||
private CardData cardData;
|
||||
|
||||
// Cached reference to AlbumViewPage (lazy-loaded)
|
||||
private AlbumViewPage _albumViewPage;
|
||||
// Injected dependencies
|
||||
private AlbumViewPage albumViewPage;
|
||||
|
||||
// Public accessors
|
||||
public CardDisplay CardDisplay => cardDisplay;
|
||||
@@ -30,56 +30,44 @@ namespace UI.CardSystem.StateMachine
|
||||
public CardData CardData => cardData;
|
||||
|
||||
/// <summary>
|
||||
/// Get the AlbumViewPage instance (cached to avoid repeated FindFirstObjectByType calls)
|
||||
/// Get the injected AlbumViewPage (null if not set)
|
||||
/// </summary>
|
||||
public AlbumViewPage AlbumViewPage
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_albumViewPage == null)
|
||||
{
|
||||
_albumViewPage = FindFirstObjectByType<AlbumViewPage>();
|
||||
}
|
||||
return _albumViewPage;
|
||||
}
|
||||
}
|
||||
public AlbumViewPage AlbumViewPage => albumViewPage;
|
||||
|
||||
// Runtime state
|
||||
public bool IsClickable { get; set; } = true;
|
||||
|
||||
// TODO: Move to booster-specific states - this is workflow-specific, not generic context
|
||||
public bool SuppressRevealBadges { get; set; } = false; // Set by states to suppress NEW/REPEAT badges in revealed state
|
||||
|
||||
// Original transform data (captured on spawn for shrink animations)
|
||||
public Vector3 OriginalScale { get; private set; }
|
||||
public Vector3 OriginalPosition { get; private set; }
|
||||
public Quaternion OriginalRotation { get; private set; }
|
||||
|
||||
// TODO: Move to BoosterOpeningPage - reveal flow is booster-specific workflow coordination
|
||||
// Single event for reveal flow completion
|
||||
public event Action<CardContext> OnRevealFlowComplete;
|
||||
|
||||
// Generic drag event - fired when drag starts, consumers decide how to handle based on current state
|
||||
public event Action<CardContext> OnDragStarted;
|
||||
|
||||
// Generic drag end event - fired when drag ends, consumers decide how to handle based on current state
|
||||
public event Action<CardContext> OnDragEnded;
|
||||
|
||||
// TODO: Move to booster-specific states - this tracks reveal workflow completion
|
||||
private bool _hasCompletedReveal = false;
|
||||
public bool HasCompletedReveal => _hasCompletedReveal;
|
||||
|
||||
// TODO: Move to booster-specific states - workflow coordination method
|
||||
// Helper method for states to signal completion
|
||||
public void NotifyRevealComplete()
|
||||
// Booster-specific context (optional, only set for booster flow cards)
|
||||
private BoosterCardContext boosterContext;
|
||||
public BoosterCardContext BoosterContext
|
||||
{
|
||||
if (!_hasCompletedReveal)
|
||||
get
|
||||
{
|
||||
_hasCompletedReveal = true;
|
||||
OnRevealFlowComplete?.Invoke(this);
|
||||
if (boosterContext == null)
|
||||
boosterContext = new BoosterCardContext();
|
||||
return boosterContext;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inject AlbumViewPage dependency
|
||||
/// </summary>
|
||||
public void SetAlbumViewPage(AlbumViewPage page)
|
||||
{
|
||||
albumViewPage = page;
|
||||
}
|
||||
|
||||
// Helper method for states/card to signal drag started
|
||||
public void NotifyDragStarted()
|
||||
{
|
||||
@@ -141,7 +129,12 @@ namespace UI.CardSystem.StateMachine
|
||||
public void SetupCard(CardData data)
|
||||
{
|
||||
cardData = data;
|
||||
_hasCompletedReveal = false; // Reset completion flag
|
||||
|
||||
// Reset booster context if it exists
|
||||
if (boosterContext != null)
|
||||
{
|
||||
boosterContext.Reset();
|
||||
}
|
||||
|
||||
// Capture original transform for shrink animations.
|
||||
// If current scale is ~0 (pop-in staging), default to Vector3.one.
|
||||
@@ -171,7 +164,12 @@ namespace UI.CardSystem.StateMachine
|
||||
public void UpdateCardData(CardData data)
|
||||
{
|
||||
cardData = data;
|
||||
_hasCompletedReveal = false; // Reset completion flag
|
||||
|
||||
// Reset booster context if it exists
|
||||
if (boosterContext != null)
|
||||
{
|
||||
boosterContext.Reset();
|
||||
}
|
||||
|
||||
// Don't re-capture OriginalScale/Position/Rotation
|
||||
// This preserves the transform values captured during initial setup
|
||||
|
||||
Reference in New Issue
Block a user