Пример #1
0
 /// <summary>
 /// 恢复消息循环
 /// </summary>
 public static void ResumeUpdateContext()
 {
     Director.GetInstance().timer.Start();
     Director.IsContextUpdatePaused = false;
     LogUtils.LogLine("Context Update Dispatcher is resumed", "Director", LogLevel.Important);
 }
Пример #2
0
        /// <summary>
        /// 设置运行时环境管理器,用于读取保存的信息
        /// </summary>
        /// <param name="rm">反序列化后的RM实例</param>
        public static void ResumeFromSaveData(RuntimeManager rm)
        {
            // 停止消息循环
            Director.PauseUpdateContext();
            // 清空回滚器
            RollbackManager.Clear();
            // 清空画面
            ViewManager.GetInstance().RemoveView(ResourceType.Unknown);
            // 检查是否需要回滚当前的并行处理
            Director.RunMana.StopAllParallel();
            // 变更运行时环境
            Director.RunMana = rm;
            Director.RunMana.ParallelHandler = Director.GetInstance().ParallelUpdateContext;
            LogUtils.LogLine("RuntimeManager is replaced", "Director", LogLevel.Important);
            // 缓存指令指针
            var irname = rm.CallStack.ESP.IR;
            var isname = rm.CallStack.ESP.BindingSceneName;

            rm.CallStack.ESP.MircoStep(Director.GetInstance().resMana.GetScene(isname).YuriDict[irname]);
            // 变更屏幕管理器
            ScreenManager.ResetSynObject(Director.RunMana.Screen);
            LogUtils.LogLine("ScreenManager is replaced", "Director", LogLevel.Important);
            // 重绘整个画面
            ViewManager.GetInstance().ReDraw();
            // 重新绑定渲染器的作用堆栈
            UpdateRender render = Director.GetInstance().updateRender;

            render.VsmReference = Director.RunMana.CallStack;
            // 恢复背景音乐
            if (GlobalConfigContext.UseBassEngine)
            {
                MusicianBass.GetInstance().RePerform(Director.RunMana.Musics);
            }
            else
            {
                Musician.GetInstance().RePerform(Director.RunMana.Musics);
            }
            // 清空字符串缓冲
            render.dialogPreStr = String.Empty;
            render.pendingDialogQueue.Clear();
            // 关闭自动播放
            Director.RunMana.IsAutoplaying = false;
            // 弹空全部等待,复现保存最后一个动作
            Director.RunMana.ExitUserWait();
            Interrupt reactionNtr = new Interrupt()
            {
                Type              = InterruptType.LoadReaction,
                Detail            = "Reaction for load data",
                InterruptSA       = Director.RunMana.DashingPureSa,
                InterruptFuncSign = String.Empty,
                ReturnTarget      = null,
                PureInterrupt     = true
            };

            // 提交中断
            Director.RunMana.CallStack.Submit(reactionNtr);
            // 重启并行调度系统
            var sc = ResourceManager.GetInstance().GetScene(Director.RunMana.CallStack.EBP.BindingSceneName);

            Director.RunMana.ParallelExecutorStack = new Stack <List <ParallelExecutor> >();
            Director.RunMana.ConstructParallel(sc);
            Director.RunMana.RestartParallel();
            Director.RunMana.LastScenario = sc.Scenario;
            // 重启信号分发系统
            SemaphoreDispatcher.ReBinding(sc, Director.RunMana.SemaphoreBindings);
            // 重启主调用堆栈上的消息循环
            Director.ResumeUpdateContext();
        }
Пример #3
0
 /// <summary>
 /// 暂停消息循环
 /// </summary>
 public static void PauseUpdateContext()
 {
     Director.IsContextUpdatePaused = true;
     Director.GetInstance().timer.Stop();
     LogUtils.LogLine("Context Update Dispatcher is stopped", "Director", LogLevel.Important);
 }
Пример #4
0
        /// <summary>
        /// 将系统跳转到指定的稳定状态
        /// </summary>
        /// <param name="ssp">要演绎的状态包装</param>
        public static void GotoSteadyState(RollbackableSnapshot ssp)
        {
            // 停止消息循环
            Director.PauseUpdateContext();
            // 结束全部动画
            SpriteAnimation.ClearAnimateWaitingDict();
            // 检查是否需要回滚当前的并行处理和信号绑定
            bool needRepara = false;

            if (ssp.VMRef.ESP.BindingSceneName != Director.RunMana.CallStack.SAVEP.BindingSceneName)
            {
                Director.RunMana.PauseParallel();
                needRepara = true;
            }
            // 退到SSP所描述的状态
            SymbolTable.GetInstance().SetDAO(ssp.sceneDao.Fork() as SceneContextDAO, ssp.globalDao.Fork() as GlobalContextDAO);
            ScreenManager.ResetSynObject(ssp.ScreenStateRef.Fork() as ScreenManager);
            Director.RunMana.ResetCallstackObject(ssp.VMRef.Fork() as StackMachine);
            Director.RunMana.Musics            = ForkableState.DeepCopyBySerialization(ssp.MusicRef);
            Director.RunMana.DashingPureSa     = ssp.ReactionRef.Clone(true);
            Director.RunMana.SemaphoreBindings = ForkableState.DeepCopyBySerialization(ssp.SemaphoreDict);
            Director.ScrMana = ScreenManager.GetInstance();
            // 刷新主渲染器上的堆栈绑定
            Director.GetInstance().RefreshMainRenderVMReference();
            Director.GetInstance().GetMainRender().IsBranching = ssp.IsBranchingRefer;
            // 重绘整个画面
            ViewManager.GetInstance().ReDraw();
            // 恢复音效
            UpdateRender render = Director.GetInstance().GetMainRender();

            if (GlobalConfigContext.UseBassEngine)
            {
                MusicianBass.GetInstance().RePerform(Director.RunMana.Musics);
            }
            else
            {
                Musician.GetInstance().RePerform(Director.RunMana.Musics);
            }
            // 清空字符串缓冲
            render.dialogPreStr = String.Empty;
            render.pendingDialogQueue.Clear();
            // 关闭自动播放
            Director.RunMana.IsAutoplaying = false;
            // 弹空全部等待,复现保存最后一个动作
            Director.RunMana.ExitUserWait();
            Interrupt reactionNtr = new Interrupt()
            {
                Type              = InterruptType.LoadReaction,
                Detail            = "Reaction for rollback",
                InterruptSA       = ssp.ReactionRef,
                InterruptFuncSign = String.Empty,
                ReturnTarget      = null,
                PureInterrupt     = true
            };

            // 提交中断到主调用堆栈
            Director.RunMana.CallStack.Submit(reactionNtr);
            // 重启并行处理和信号系统
            if (needRepara)
            {
                var sc = ResourceManager.GetInstance().GetScene(ssp.VMRef.EBP.BindingSceneName);
                Director.RunMana.ConstructParallelForRollingBack(sc);
                Director.RunMana.BackTraceParallel();
                Director.RunMana.LastScenario = sc.Scenario;
                SemaphoreDispatcher.ReBinding(sc, Director.RunMana.SemaphoreBindings);
            }
            // 重启消息循环
            Director.ResumeUpdateContext();
        }