static void LoadScriptStemSave(Hashtable AttrIndex) { String ScriptName = (String)AttrIndex["#SCRIPTNAME"]; int SIndex = Convert.ToInt32((String)AttrIndex["#SCRIPTSHIFTINDEX"]); String[] Conditionals = ((String)AttrIndex["#CONDITIONALS"]).Split(','); Shell.UpdateQueue = new ArrayList(); Shell.RenderQueue = new ArrayList(); foreach (String C in Conditionals) { switch (C) { case "DEFAULTUI": ButtonScripts.InitDefaultUI(); break; } } ScriptProcessor.ScriptSniffer LoadSniffer = new ScriptProcessor.ScriptSniffer(ScriptName.ToUpper() + "_SNIFFER", ScriptProcessor.RetrieveScriptByName(ScriptName), ScriptName, true); LoadSniffer.SetLoadBreaker(SIndex); Shell.UpdateQueue.Add(LoadSniffer); }
public static void HandleConsoleInput(String Input) { pLastManualConsoleInput = Input; SortedDictionary <int, Color> Cols = new SortedDictionary <int, Color>(); Cols.Add(0, Color.LightGreen); WriteLine(Input, Cols); String[] Commands = Input.Split(' '); try { switch (Commands[0].ToUpper()) { //Run ScriptProcessor commands as a forced script shift (by default, shift conditions are unchanged). case "INSERT": ScriptProcessor.ScriptSniffer FoundSniffer = ScriptProcessor.SnifferSearch(); if (FoundSniffer != null) { FoundSniffer.ForceInsertScriptElement((Input.Remove(0, Input.IndexOf(' ') + 1)).Split(' '), false); } else { WriteLine("Cannot insert new script shift as a script is not running."); } break; //Activate a single script element. case "ACTIVATE": ScriptProcessor.ActivateScriptElement(Input.Remove(0, Input.IndexOf(' ') + 1)); break; //Freshly load a new script. case "LOAD": WriteLine("Attempting to load script " + Commands[1].ToUpper() + "."); ButtonScripts.StartScript(Commands[1].ToUpper()); break; //Executes a function statement per the EntityFactory's inbuilt function parser. case "DO": RunQueue.Add(EntityFactory.AssembleVoidDelegate("do=" + Input.Remove(0, Input.IndexOf(' ') + 1))); break; //Executes a method specifier (instance return) per the EntityFactory's inbuilt function parser. case "RUN": RunQueue.Add(EntityFactory.AssembleVoidDelegate(Input.Remove(0, Input.IndexOf(' ') + 1))); break; //Fork to a new script from your current state. Equivalent to "do B|[Script name]". case "FORK": ScriptProcessor.ActivateScriptElement("B|" + Commands[1].ToUpper()); break; //Close the program. case "QUIT": WriteLine("Closing the VNF client..."); ExitOut = true; break; default: WriteLine("Unrecognized command."); break; } } catch (Exception e) { WriteLine(e.GetType().Name + ": " + e.Message); } }
static String GenerateSave(String ThumbName, String Type) { String Save = "EVENT HORIZON ENGINE SAVE FILE\n" + "#VERSION=" + Shell.FrameworkVersion + "\n" + "#TIME=" + System.DateTime.Now.ToBinary() + "\n" + "#THUMB=" + ThumbName + "\n" + "#SAVETYPE=" + Type + "\n" + "#FLAGS=" + RecordApplicableFlags() + "\n"; if (Type == "ScriptStem") { ScriptProcessor.ScriptSniffer CurrentSniffer = null; Boolean Found = false; foreach (WorldEntity E in Shell.UpdateQueue) { if (E is ScriptProcessor.ScriptSniffer) { CurrentSniffer = (ScriptProcessor.ScriptSniffer)E; Found = true; break; } } if (!Found) { throw new SaveLoadException("Error when saving the game - no active script!"); } Save += "#SCRIPTNAME=" + CurrentSniffer.Name.Replace("_SNIFFER", "") + "\n"; Save += "#SCRIPTSHIFTINDEX=" + CurrentSniffer.Index + "\n"; Save += "#CONDITIONALS="; switch (CurrentSniffer.Name.Replace("_SNIFFER", "").ToUpper()) { default: Save += "DEFAULTUI"; break; case "VS_MAIN_INTRO": Save += "NULL"; break; } } else if (Type == "FullySerializedBinary") { if (ScriptProcessor.PastStates.Count == 0) { Shell.WriteLine("Could not generate save file: No valid RecallableState stored."); return(null); } RecallableState?State = (RecallableState?)ScriptProcessor.PastStates.Peek(); if (State is null) { Stack StatesClone = (Stack)ScriptProcessor.PastStates.Clone(); StatesClone.Pop(); while (State is null) { if (StatesClone.Count == 0) { Shell.WriteLine("Could not generate save file: No valid RecallableState stored."); return(null); } State = (RecallableState?)StatesClone.Pop(); } } IFormatter SerFormatter = new BinaryFormatter(); ArrayList Streams = new ArrayList(); MemoryStream EntityStream = new MemoryStream(); SerFormatter.Serialize(EntityStream, State); EntityStream.Close(); byte[] Bin = EntityStream.ToArray(); String BinString = Convert.ToBase64String(Bin); Save += "#DATASTREAM=" + BinString + "&ENDDATASTREAM"; } Save += "\n"; Save += "END"; return(Save); }