public bool loadFromSTR(bool onlyTriggers, bool escapeNewLines, string triggersText, ref int lastReadPosition, ref int lastReadPositionEnd) { if (triggersText != null) { if (escapeNewLines) { triggersText = triggersText.Replace("\n", "\r\n"); } //File.WriteAllText("loaded.txt", triggersText); Scanner scanner = new src.Scanner(triggersText); Parser parser = new src.Parser(scanner); AllTrigers.Clear(); TriggerData.Clear(); if (parser.parse(onlyTriggers, ref lastReadPosition, ref lastReadPositionEnd)) { List <Trigger> triggers = parser.getTriggers(); foreach (Trigger trigger in triggers) { AllTrigers.Add(trigger); foreach (PlayerDef affected in trigger.getAffectedPlayers()) { if (!TriggerData.ContainsKey(affected)) { TriggerData[affected] = new List <Trigger>(); } TriggerData[affected].Add(trigger); } } return(true); } } return(false); }
public Trigger loadAndInsertAfter(string str, Trigger trigger) { Scanner scanner = new src.Scanner(str); Parser parser = new src.Parser(scanner); int zer = 0; if (parser.parse(true, ref zer, ref zer)) { List <Trigger> triggers = parser.getTriggers(); if (triggers.Count == 1) { Trigger trig = triggers[0]; InsertAfter(AllTrigers, trigger, trig); foreach (KeyValuePair <PlayerDef, List <Trigger> > subList in TriggerData) { InsertAfter(subList.Value, trigger, trig); } return(trig); } } throw new NotImplementedException(); }