public static RTSRace Parse(FileInfo infoFile, Dictionary <string, ReflectedScript> scripts) { // Check File Existence if (infoFile == null || !infoFile.Exists) { return(null); } // Read The Entire File string mStr; using (FileStream fs = File.OpenRead(infoFile.FullName)) { StreamReader s = new StreamReader(fs); mStr = s.ReadToEnd(); } // Set Environment Variables ZXParser.SetEnvironment("FILEROOTDIR", infoFile.Directory.FullName); ZXParser.SetEnvironment("DICTSCRIPTS", scripts); // Read Data RTSRace data = new RTSRace(); ZXParser.ParseInto(mStr, data); data.InfoFile = new FileInfo(PathHelper.GetRelativePath(infoFile.FullName)); data.UpdateActiveUnits(); data.UpdateActiveBuildings(); return(data); }
public static RTSUnitModel ParseModel(RTSRenderer renderer, FileInfo infoFile, RTSRace race) { // Check File Existence if (infoFile == null || !infoFile.Exists) { return(null); } ZXParser.SetEnvironment("FILEROOTDIR", infoFile.Directory.FullName); ZXParser.SetEnvironment("RENDERER", renderer); ZXParser.SetEnvironment("RACE", race); RTSUnitViewData vd = ZXParser.ParseFile(infoFile.FullName, typeof(RTSUnitViewData)) as RTSUnitViewData; return(vd.View); }