除了充盈都做完了

This commit is contained in:
SoulliesOfficial
2025-10-31 10:02:30 -04:00
parent 5d09ef7b53
commit ee1d3d9c0a
179 changed files with 3239 additions and 200 deletions

View File

@@ -19,7 +19,7 @@ namespace SLSFramework.General
// 队列的入口现在需要一个能接收 Context 的指令工厂
// 1. 我们使用一个标准的 Queue<T> 来存储待执行的指令。
// 这比 Subject 更能明确地表达“队列”的意图。
private readonly Queue<Tuple<CommandBase, CommandContext>> commandQueue = new Queue<Tuple<CommandBase, CommandContext>>();
private readonly LinkedList<Tuple<CommandBase, CommandContext>> commandQueue = new LinkedList<Tuple<CommandBase, CommandContext>>();
// 2. 一个布尔值标志,用于追踪管理器当前是否正在执行一个指令。
private bool isBusy = false;
@@ -71,10 +71,23 @@ namespace SLSFramework.General
}
public CommandBase AddCommand(CommandBase command, CommandContext context = null)
{
return AddCommand(command, true, context);
}
public CommandBase AddCommand(CommandBase command, bool insertAtTail, CommandContext context = null)
{
context ??= new CommandContext();
// 将指令和其上下文入队
commandQueue.Enqueue(Tuple.Create(command, context));
if (insertAtTail)
{
commandQueue.AddLast(Tuple.Create(command, context));
}
else
{
commandQueue.AddFirst(Tuple.Create(command, context));
}
//Debug.Log($"[Queue] 添加指令: {command.GetType()},队列长度: {commandQueue.Count}");
// 尝试启动队列处理。
// 如果队列当前不忙,这个调用会立即开始处理我们刚刚添加的指令。
@@ -100,7 +113,8 @@ namespace SLSFramework.General
// 4. 标记为“忙碌”,并从队列中取出下一个指令。
isBusy = true;
var nextEntry = commandQueue.Dequeue();
var nextEntry = commandQueue.First.Value;
commandQueue.RemoveFirst();
var commandToExecute = nextEntry.Item1;
var context = nextEntry.Item2;