Refactor, cleanup code and add documentaiton

This commit is contained in:
Michal Pikulski
2025-11-18 09:29:59 +01:00
parent 034654c308
commit cf13fb78b5
100 changed files with 689 additions and 537 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: abf7a5def55e43178a4c88caf5686cc9
timeCreated: 1763454388

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 619e69d1b6e44ecabc40657b2bcd13f9
timeCreated: 1763454353

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2a6295f642a94601ada9c21dc400d180
timeCreated: 1763454480

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7cb791415c884e97ac181816424200e4
timeCreated: 1763454497

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c548995da9c746d1916b79304734c1c9
timeCreated: 1763454486

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: e0b15b90103942c3b0e630462ecc5de1
timeCreated: 1757518020

View File

@@ -1,71 +0,0 @@
 using System.Collections.Generic;
using Core;
using UI.DragAndDrop.Core;
using UnityEngine;
namespace UI.CardSystem
{
/// <summary>
/// Helper utility for shuffling draggable objects in a SlotContainer.
/// Moves objects to occupy the first available slots (0, 1, 2, etc.)
/// </summary>
public static class SlotContainerHelper
{
/// <summary>
/// Shuffles draggable objects to always occupy the first available slots.
/// Unassigns all objects from their current slots, then reassigns them starting from slot 0.
/// </summary>
/// <param name="container">The slot container holding the slots</param>
/// <param name="objects">List of draggable objects to shuffle</param>
/// <param name="animate">Whether to animate the movement</param>
public static void ShuffleToFront(SlotContainer container, List<DraggableObject> objects, bool animate = true)
{
if (container == null || objects == null || objects.Count == 0)
return;
Logging.Debug($"[SlotContainerHelper] Shuffling {objects.Count} objects to front slots");
// Unassign all objects from their current slots
foreach (var obj in objects)
{
if (obj.CurrentSlot != null)
{
obj.CurrentSlot.Vacate();
}
}
// Reassign objects to first N slots starting from slot 0
for (int i = 0; i < objects.Count; i++)
{
DraggableSlot targetSlot = FindSlotByIndex(container, i);
DraggableObject obj = objects[i];
if (targetSlot != null)
{
Logging.Debug($"[SlotContainerHelper] Assigning object to slot with SlotIndex {i}");
obj.AssignToSlot(targetSlot, animate);
}
else
{
Logging.Warning($"[SlotContainerHelper] Could not find slot with SlotIndex {i}");
}
}
}
/// <summary>
/// Find a slot by its SlotIndex property (not list position)
/// </summary>
private static DraggableSlot FindSlotByIndex(SlotContainer container, int slotIndex)
{
foreach (var slot in container.Slots)
{
if (slot.SlotIndex == slotIndex)
{
return slot;
}
}
return null;
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: cad44f85ab1a4672ab4bb14e2f919413
timeCreated: 1762470959