处理resetAction队列

This commit is contained in:
shenjianxing 2024-12-27 20:28:53 +08:00
parent d6f069c408
commit 24f97fedbb

View File

@ -125,17 +125,20 @@ public class OperationController : MonoSingleton<OperationController>
if (this.index < targetIndex) if (this.index < targetIndex)
{ {
var seq = ActionKit.Sequence(); var seq = ActionKit.Sequence();
for (int i = this.index + 1; i < targetIndex; i++) if (this.index >= 0)
{
for (int i = this.index; i < targetIndex; i++)
{ {
// 完成动作 直接执行 // 完成动作 直接执行
IAction finishAction = ActionHelper.GetActionAndSub(steps[i].Finished); IAction finishAction = ActionHelper.GetActionAndSub(steps[i].Finished);
TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = i, status = StepStatus.Finished }); TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = i, status = StepStatus.Finished });
if (finishAction!=null) if (finishAction != null)
{ {
seq.Append(finishAction); seq.Append(finishAction);
} }
} }
seq.Start(this,() => }
seq.Start(this, () =>
{ {
curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start); curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start);
RunCurAction(curAction, targetIndex); RunCurAction(curAction, targetIndex);
@ -143,19 +146,22 @@ public class OperationController : MonoSingleton<OperationController>
} }
else if (this.index > targetIndex) else if (this.index > targetIndex)
{ {
var seq = ActionKit.Sequence();
for (int i = this.index; i > targetIndex; i--) for (int i = this.index; i > targetIndex; i--)
{ {
// 重置动作 直接重置 // 重置动作 直接重置
IAction resetAction = ActionHelper.GetActionAndSub(steps[i].Reset); IAction resetAction = ActionHelper.GetActionAndSub(steps[i].Reset);
if (resetAction != null) if (resetAction != null)
{ {
resetAction.Start(this); seq.Append(resetAction);
} }
TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = i, status = StepStatus.NoStart }); TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = i, status = StepStatus.NoStart });
} }
seq.Start(this, () =>
{
curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start); curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start);
RunCurAction(curAction, targetIndex); RunCurAction(curAction, targetIndex);
});
} }
else else
{ {
@ -166,7 +172,7 @@ public class OperationController : MonoSingleton<OperationController>
} }
} }
public void RunCurAction(IAction curAction,int targetIndex) public void RunCurAction(IAction curAction, int targetIndex)
{ {
if (curAction != null) if (curAction != null)
{ {