Files
SVSimServer/SVSim.BattleEngine/Engine/Wizard.DeckCardEdit/CardCreator.cs
gamer147 0d9d8acae0 feat(battle-engine): M1 auto-copy closure (782 battle-logic files)
Compile-driven bulk-copy loop (tools/engine-port/m1_copy_loop.py) pulled the precise reference closure of the battle-core roots, stopping at the classify god-object/View-VFX-UI boundary. 782 files; no re-explosion (M0 had estimated ~order 1000). Residual frontier = 52 shim-classified + 80 external (Unity/BCL) types to author next.
2026-06-05 16:57:20 -04:00

90 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using Cute;
namespace Wizard.DeckCardEdit;
public class CardCreator
{
private class Task
{
public List<int> Order;
public Action<List<UIBase_CardManager.CardObjData>> OnFinish;
public Task(List<int> order, Action<List<UIBase_CardManager.CardObjData>> onFinish)
{
Order = order;
OnFinish = onFinish;
}
}
private const int QUEUE_CAPACITY = 8;
private bool _isBusy;
private List<Task> _taskQueue;
private CardMaster.CardMasterId _cardMasterId;
public event Action OnFinishedLatest;
public CardCreator()
{
_taskQueue = new List<Task>(8);
}
public void Request(Func<List<int>> order, bool isPreferentially, Action<List<UIBase_CardManager.CardObjData>> onFinish, CardMaster.CardMasterId cardMasterId)
{
_cardMasterId = cardMasterId;
if (isPreferentially)
{
_taskQueue.Insert(0, new Task(order(), onFinish));
}
else
{
_taskQueue.Add(new Task(order(), onFinish));
}
}
public void Tick()
{
if (!_isBusy)
{
StartCreate(Dequeue());
}
}
public void Clear()
{
_taskQueue.Clear();
}
private void StartCreate(Task task)
{
if (task != null)
{
_isBusy = true;
Toolbox.ResourcesManager.CardListAssetPathList.Clear();
UIManager.GetInstance().CardLoadSelect(null, task.Order, 0, is2D: true, delegate
{
task.OnFinish.Call(UIManager.GetInstance().getCardList2DObjs());
UIManager.GetInstance().getCardList2DObjs().Clear();
_isBusy = false;
this.OnFinishedLatest.Call();
}, isDefaultSleeve: false, _cardMasterId);
}
}
private Task Dequeue()
{
Task result = null;
if (_taskQueue.Count > 0)
{
result = _taskQueue[0];
_taskQueue.RemoveAt(0);
}
return result;
}
}