Stash work!

This commit is contained in:
Michal Pikulski
2025-11-17 17:10:24 +01:00
parent c6f635f871
commit b5364a2bbc
29 changed files with 665 additions and 2444 deletions

View File

@@ -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);
}
}