public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != Conditions.ConditionFunctions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "ST_"; string cmdname = sp.NextQuotedWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in Star"); return(true); } cmdname = sp.NextQuotedWord(); } if (cmdname != null) { DB.SystemClassDB sc = DB.SystemClassDB.GetSystem(cmdname); ap[prefix + "Found"] = sc != null ? "1" : "0"; if (sc != null) { Conditions.ConditionVariables vars = new Conditions.ConditionVariables(); ActionVars.SystemVars(vars, sc, prefix); ap.Add(vars); ActionVars.SystemVarsFurtherInfo(ap, (ap.actioncontroller as ActionController).HistoryList, sc, prefix); } } else { ap.ReportError("Missing starname in Star"); } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != Conditions.ConditionFunctions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "S_"; string cmdname = sp.NextQuotedWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in Scan"); return(true); } cmdname = sp.NextQuotedWord(); } bool edsm = false; if (cmdname != null && cmdname.Equals("EDSM", StringComparison.InvariantCultureIgnoreCase)) { edsm = true; cmdname = sp.NextQuotedWord(); } if (cmdname != null) { EliteDangerous.StarScan scan = (ap.actioncontroller as ActionController).HistoryList.starscan; DB.SystemClassDB sc = DB.SystemClassDB.GetSystem(cmdname); if (sc == null) { sc = new DB.SystemClassDB(cmdname); sc.id_edsm = 0; } EliteDangerous.StarScan.SystemNode sn = scan.FindSystem(sc, edsm); System.Globalization.CultureInfo ct = System.Globalization.CultureInfo.InvariantCulture; if (sn != null) { int starno = 1; ap[prefix + "Stars"] = sn.starnodes.Count.ToString(ct); foreach (KeyValuePair <string, EliteDangerous.StarScan.ScanNode> scannode in sn.starnodes) { DumpInfo(ap, scannode, prefix + "Star_" + starno.ToString(ct), "_Planets"); int pcount = 1; if (scannode.Value.children != null) { foreach (KeyValuePair <string, EliteDangerous.StarScan.ScanNode> planetnodes in scannode.Value.children) { DumpInfo(ap, planetnodes, prefix + "Planet_" + starno.ToString(ct) + "_" + pcount.ToString(ct), "_Moons"); if (planetnodes.Value.children != null) { int mcount = 1; foreach (KeyValuePair <string, EliteDangerous.StarScan.ScanNode> moonnodes in planetnodes.Value.children) { DumpInfo(ap, moonnodes, prefix + "Moon_" + starno.ToString(ct) + "_" + pcount.ToString(ct) + "_" + mcount.ToString(ct), "_Submoons"); if (moonnodes.Value.children != null) { int smcount = 1; foreach (KeyValuePair <string, EliteDangerous.StarScan.ScanNode> submoonnodes in moonnodes.Value.children) { DumpInfo(ap, submoonnodes, prefix + "SubMoon_" + starno.ToString(ct) + "_" + pcount.ToString(ct) + "_" + mcount.ToString(ct) + "_" + smcount.ToString(ct), null); smcount++; } } mcount++; } } pcount++; } } starno++; } } else { ap[prefix + "Stars"] = "0"; } } else { ap.ReportError("Missing starname in Scan"); } } else { ap.ReportError(res); } return(true); }