Stash work!
This commit is contained in:
@@ -88,11 +88,44 @@ namespace UI.CardSystem.DragDrop
|
||||
{
|
||||
base.OnDragEndedHook();
|
||||
|
||||
// Optionally trigger open when dropped in specific zones
|
||||
if (canOpenOnDrop)
|
||||
// Find closest slot and assign to it (replaces removed auto-slotting from base class)
|
||||
SlotContainer[] containers = FindObjectsByType<SlotContainer>(FindObjectsSortMode.None);
|
||||
DraggableSlot closestSlot = null;
|
||||
float closestDistance = float.MaxValue;
|
||||
|
||||
// Get position (handle both overlay and world space canvas)
|
||||
Vector3 myPosition = (RectTransform != null &&
|
||||
GetComponentInParent<Canvas>()?.renderMode == RenderMode.ScreenSpaceOverlay)
|
||||
? RectTransform.position
|
||||
: transform.position;
|
||||
|
||||
// Find closest slot among all containers
|
||||
foreach (var container in containers)
|
||||
{
|
||||
// Could check if dropped in an "opening zone"
|
||||
// For now, just a placeholder
|
||||
DraggableSlot slot = container.FindClosestSlot(myPosition, this);
|
||||
if (slot != null)
|
||||
{
|
||||
Vector3 slotPosition = slot.RectTransform != null ? slot.RectTransform.position : slot.transform.position;
|
||||
float distance = Vector3.Distance(myPosition, slotPosition);
|
||||
if (distance < closestDistance)
|
||||
{
|
||||
closestDistance = distance;
|
||||
closestSlot = slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Assign to closest slot if found
|
||||
if (closestSlot != null)
|
||||
{
|
||||
Logging.Debug($"[BoosterPackDraggable] Drag ended, assigning to closest slot: {closestSlot.name}");
|
||||
AssignToSlot(closestSlot, true);
|
||||
}
|
||||
else if (CurrentSlot != null)
|
||||
{
|
||||
// No valid slot found, return to current slot
|
||||
Logging.Debug($"[BoosterPackDraggable] No valid slot found, snapping back to current slot");
|
||||
AssignToSlot(CurrentSlot, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user