public void JumpToScript(string scriptname, string blockname = "main") { Logger.Log((currentScript == null) ? $"Starting at script {scriptname} (block {blockname})" : $"Jumping from script {currentScript.Filename} to script {scriptname} (block {blockname})"); callStack.Clear(); scriptname = scriptname.ToLower(); if (!scriptFiles.TryGetValue(scriptname + ".mg", out currentScript)) { throw new KeyNotFoundException($"Could not JumpToScript {scriptname}, as the file was not found."); } if (!currentScript.IsInitialized) { currentScript.InitializeScript(); } memoryManager.ResetScope(); currentScript.JumpToBlock(blockname); }
public void LoadGame(int slotnum) { SaveEntry saveInfoInSlot = saveManager.GetSaveInfoInSlot(slotnum); if (saveInfoInSlot != null) { GameSystem.Instance.TextController.ClearText(); GameSystem.Instance.MainUIController.FadeOut(0f, isBlocking: true); byte[] array = File.ReadAllBytes(saveInfoInSlot.Path); MGHelper.KeyEncode(array); byte[] buffer = tempSnapshotData = (snapshotData = CLZF2.Decompress(array)); hasSnapshot = true; GameSystem.Instance.ClearAllWaits(); GameSystem.Instance.ClearActions(); using (MemoryStream memoryStream = new MemoryStream(buffer)) { using (BinaryReader binaryReader = new BinaryReader(memoryStream)) { if (new string(binaryReader.ReadChars(4)) != "MGSV") { throw new FileLoadException("Save file does not appear to be valid! Invalid header."); } if (binaryReader.ReadInt32() != 1) { throw new FileLoadException("Save file does not appear to be valid! Invalid version number."); } binaryReader.ReadInt64(); string text = binaryReader.ReadString(); string text2 = binaryReader.ReadString(); string text3 = binaryReader.ReadString(); string text4 = binaryReader.ReadString(); bool num = binaryReader.ReadBoolean(); GameSystem.Instance.TextController.SetPrevText(text3, 0); GameSystem.Instance.TextController.SetPrevText(text4, 1); if (num) { if (GameSystem.Instance.UseEnglishText) { GameSystem.Instance.TextController.TypeTextImmediately(text4); GameSystem.Instance.TextController.SetFullText(text3, 0); } else { GameSystem.Instance.TextController.TypeTextImmediately(text3); GameSystem.Instance.TextController.SetFullText(text4, 1); } tempSnapshotText[0] = text3; tempSnapshotText[1] = text4; GameSystem.Instance.TextController.SetAppendState(append: true); } else { GameSystem.Instance.TextController.SetFullText(text, 0); GameSystem.Instance.TextController.SetFullText(text2, 1); tempSnapshotText[0] = text; tempSnapshotText[1] = text2; GameSystem.Instance.TextController.SetAppendState(append: false); } callStack.Clear(); int num2 = binaryReader.ReadInt32(); for (int i = 0; i < num2; i++) { string key = binaryReader.ReadString(); int linenum = binaryReader.ReadInt32(); BurikoScriptFile script = scriptFiles[key]; callStack.Push(new BurikoStackEntry(script, 0, linenum)); } string key2 = binaryReader.ReadString(); int linenum2 = binaryReader.ReadInt32(); currentScript = scriptFiles[key2]; if (!currentScript.IsInitialized) { currentScript.InitializeScript(); } currentScript.JumpToLineNum(linenum2); memoryManager.LoadMemory(memoryStream); AudioController.Instance.DeSerializeCurrentAudio(memoryStream); GameSystem.Instance.SceneController.DeSerializeScene(memoryStream); GameSystem.Instance.ForceReturnNormalState(); GameSystem.Instance.CloseChoiceIfExists(); GameSystem.Instance.TextHistory.ClearHistory(); GameSystem.Instance.IsSkipping = false; GameSystem.Instance.IsAuto = false; GameSystem.Instance.CanSkip = true; GameSystem.Instance.CanInput = true; GameSystem.Instance.CanSave = true; int flag = GetFlag("LTextFade"); GameSystem.Instance.TextController.SetTextFade(flag == 1); if (BurikoMemory.Instance.GetGlobalFlag("GADVMode").IntValue() == 1 && BurikoMemory.Instance.GetGlobalFlag("GLinemodeSp").IntValue() == 2 && BurikoMemory.Instance.GetFlag("NVL_in_ADV").IntValue() == 0) { GameSystem.Instance.MainUIController.MODdisableNVLModeINADVMode(); } if (BurikoMemory.Instance.GetGlobalFlag("GADVMode").IntValue() == 1 && BurikoMemory.Instance.GetGlobalFlag("GLinemodeSp").IntValue() == 0 && BurikoMemory.Instance.GetFlag("NVL_in_ADV").IntValue() == 1) { GameSystem.Instance.MainUIController.MODenableNVLModeINADVMode(); } } } } }