和顺 / 知白 返回所属 Agent
ZB-07.03

困难情境预演

原能力

用对话草稿预演误解、沉默或拒绝,标明可以停下、换说法或改约的节点。(细化版 p.2–3)

首选项目

Ink(MIT)。 Ink

匹配范围

将沉默、拒绝、换话题和暂停做成可运行分支。

源码

Ink · public void ChooseChoiceIndex(

ink-engine-runtime/Story.cs · 1794–1807 行。 在 GitHub 查看源码 · 许可证与声明

源码片段
        public void ChooseChoiceIndex(int choiceIdx)
        {
            var choices = currentChoices;
            Assert (choiceIdx >= 0 && choiceIdx < choices.Count, "choice out of range");

            // Replace callstack with the one from the thread at the choosing point, 
            // so that we can jump into the right place in the flow.
            // This is important in case the flow was forked by a new thread, which
            // can create multiple leading edges for the story, each of
            // which has its own context.
            var choiceToChoose = choices [choiceIdx];
            if(onMakeChoice != null) onMakeChoice(choiceToChoose);
            state.callStack.currentThread = choiceToChoose.threadAtGeneration;

Ink · public string ToJson(

ink-engine-runtime/StoryState.cs · 37–50 行。 在 GitHub 查看源码 · 许可证与声明

源码片段
        public string ToJson() {
            var writer = new SimpleJson.Writer();
            WriteJson(writer);
            return writer.ToString();
        }

        /// <summary>
        /// Exports the current state to json format, in order to save the game.
        /// For this overload you can pass in a custom stream, such as a FileStream.
        /// </summary>
        public void ToJson(Stream stream) {
            var writer = new SimpleJson.Writer(stream);
            WriteJson(writer);
        }

实现与验收要点

情境脚本、有效性验证及参与者退出条件需自行设计。