yyl
2025-09-04 cdf7098c937c5f4a70383ef70897bf9fedbb3d99
Main/System/Battle/RecordPlayer/RecordPlayer.cs
@@ -9,6 +9,8 @@
    private Queue<RecordAction> recordActionQueue = new Queue<RecordAction>();
    protected RecordAction currentRecordAction;
    protected List<RecordAction> immediatelyActionList = new List<RecordAction>();
    private bool isWaitingNextAction = false;
    private float waitTimer = 0f;
    private const float waitInterval = 0.2f;
@@ -20,7 +22,7 @@
    public bool IsPlaying()
    {
        return currentRecordAction != null || recordActionQueue.Count > 0;
        return currentRecordAction != null || recordActionQueue.Count > 0 || immediatelyActionList.Count > 0;
    }
    public void PlayRecord(RecordAction recordAction)
@@ -37,8 +39,60 @@
        }
    }
    public void InsertRecord(RecordAction recordAction)
    {
        BattleDebug.LogError("Insert record action " + recordAction.GetType());
        if (currentRecordAction != null)
        {
            Queue<RecordAction> tempQueue = new Queue<RecordAction>();
            tempQueue.Enqueue(recordAction);
            while (recordActionQueue.Count > 0)
            {
                tempQueue.Enqueue(recordActionQueue.Dequeue());
            }
            recordActionQueue = tempQueue;
        }
        else
        {
            recordActionQueue.Enqueue(recordAction);
        }
    }
    public void ImmediatelyPlay(RecordAction recordAction)
    {
        immediatelyActionList.Add(recordAction);
    }
    protected void ImmediatelyPlayRun()
    {
        if (immediatelyActionList.Count > 0)
        {
            List<int> removeIndexList = new List<int>();
            for (int i = immediatelyActionList.Count - 1; i >= 0; i--)
            {
                var action = immediatelyActionList[i];
                if (action.IsFinished())
                {
                    removeIndexList.Add(i);
                }
                else
                {
                    action.Run();
                }
            }
            for (int i = removeIndexList.Count - 1; i >= 0; i--)
            {
                immediatelyActionList.RemoveAt(removeIndexList[i]);
            }
        }
    }
    public virtual void Run()
    {
        ImmediatelyPlayRun();
        // 等待下一个action
        if (isWaitingNextAction)
        {