public void Load(string oplfile) { Name = Path.GetFileNameWithoutExtension(oplfile).ToLowerInvariant(); var lines = File.ReadAllLines(oplfile); bool ininst = false; bool incars = false; foreach (var line in lines) { string tline = line.Trim(); if (string.IsNullOrEmpty(tline)) { continue; //blank line } if (tline.StartsWith("#")) { continue; //commented out } if (tline.StartsWith("version")) { continue; } if (tline.StartsWith("inst")) { ininst = true; continue; } //start of instances if (tline.StartsWith("cars")) { incars = true; continue; } //start of car gens if (tline.StartsWith("end") && (ininst || incars)) { ininst = false; incars = false; continue; } if (ininst) { Entity ent = new Entity(tline); AllEntities.Add(ent); } if (incars) { CarGen cgen = new CarGen(tline); CarGenerators.Add(cgen); } } //ProcessEntities(); }
public void Load(string iplfile) { Name = Path.GetFileNameWithoutExtension(iplfile).ToLowerInvariant(); var lines = File.ReadAllLines(iplfile); bool ininst = false; bool incars = false; foreach (var line in lines) { string tline = line.Trim(); if (string.IsNullOrEmpty(tline)) { continue; //blank line } if (tline.StartsWith("#")) { continue; //commented out } //if (tline.StartsWith("version")) continue; if (tline.StartsWith("inst")) { ininst = true; continue; } //start of instances if (tline.StartsWith("cars")) { incars = true; continue; } //start of car gens if (tline.StartsWith("end") && (ininst || incars)) { ininst = false; incars = false; continue; } if (ininst) { Entity ent = new Entity(tline); AllEntities.Add(ent); if (ent.Name.StartsWith("slod")) { SlodEntities.Add(ent); } else if (ent.Name.StartsWith("lod")) { LodEntities.Add(ent); } else { if (ent.ParentIndex < 0) { OEntities.Add(ent); } else { HdEntities.Add(ent); } } } if (incars) { CarGen cgen = new CarGen(tline); CarGenerators.Add(cgen); } } AllLodEntities.Clear(); AllLodEntities.AddRange(SlodEntities); AllLodEntities.AddRange(LodEntities); AllHdEntities.Clear(); AllHdEntities.AddRange(HdEntities); AllHdEntities.AddRange(OEntities); for (int i = 0; i < AllLodEntities.Count; i++) { AllLodEntities[i].NewIndex = i; } for (int i = 0; i < AllHdEntities.Count; i++) { AllHdEntities[i].NewIndex = i; } }