// Warning: Any Runtime.Object content referenced within the StoryState will // be re-referenced rather than cloned. This is generally okay though since // Runtime.Objects are treated as immutable after they've been set up. // (e.g. we don't edit a Runtime.Text after it's been created an added.) // I wonder if there's a sensible way to enforce that..?? internal StoryState Copy() { var copy = new StoryState(story); copy.outputStream.AddRange(_outputStream); copy.currentChoices.AddRange(currentChoices); if (hasError) { copy.currentErrors = new List<string> (); copy.currentErrors.AddRange (currentErrors); } copy.callStack = new CallStack (callStack); copy._currentRightGlue = _currentRightGlue; copy.variablesState = new VariablesState (copy.callStack); copy.variablesState.CopyFrom (variablesState); copy.evaluationStack.AddRange (evaluationStack); if (divertedTargetObject != null) copy.divertedTargetObject = divertedTargetObject; copy.previousContentObject = previousContentObject; copy.visitCounts = new Dictionary<string, int> (visitCounts); copy.turnIndices = new Dictionary<string, int> (turnIndices); copy.currentTurnIndex = currentTurnIndex; copy.storySeed = storySeed; copy.didSafeExit = didSafeExit; return copy; }