/// <summary> /// Move back to a previously stepped node, the lazy execution block and callbacks at the target dialogue entry /// will be executed again. /// </summary> /// <param name="nodeName">the node to move to</param> /// <param name="dialogueIndex">the index of the dialogue to move to</param> /// <param name="variablesHash">hash of variables of the target</param> /// <param name="clearFuture">clear saved checkpoints in the future</param> public void MoveBackTo(string nodeName, int dialogueIndex, string variablesHash, bool clearFuture = false) { if (CheckActionRunning()) { return; } // animation should stop NovaAnimation.StopAll(AnimationType.All ^ AnimationType.UI); // restore history var backNodeIndex = walkedThroughNodes.FindLastIndex(x => x == nodeName); Assert.IsFalse(backNodeIndex < 0, $"Nova: move back to node {nodeName} that has not been walked through."); // state should be normal when goes backward state = State.Normal; if (clearFuture) { // all save data of nodes to be removed are deleted for (var i = backNodeIndex + 1; i < walkedThroughNodes.Count; i++) { checkpointManager.UnsetReach(walkedThroughNodes[i]); } // all save data of later dialogues are deleted for (var i = dialogueIndex + 1; i < flowChartTree.GetNode(nodeName).dialogueEntryCount; i++) { checkpointManager.UnsetReach(nodeName, i); } } var nodeHistoryRemoveLength = walkedThroughNodes.Count - backNodeIndex - 1; walkedThroughNodes.RemoveRange(backNodeIndex + 1, nodeHistoryRemoveLength); currentNode = flowChartTree.GetNode(walkedThroughNodes.Last()); currentIndex = dialogueIndex; // restore status var entry = checkpointManager.IsReached(nodeName, dialogueIndex, variablesHash); if (entry == null) { Debug.LogWarning( $"Nova: Unable to find node with varhash = {variablesHash}, falling back to any variable."); entry = checkpointManager.IsReachedForAnyVariables(nodeName, dialogueIndex); } Restore(entry); }