public oMap(string filepath) { List <string> alll = System.IO.File.ReadAllLines(filepath).ToList(); SaveReader sr = new SaveReader(alll); //first line is save file format version string strVersion = sr.ReadLine(); while (true) { //first step is read the next object to add to the map. //second step is read the properties of that object. we knows in which order properties are written string newitem = sr.ReadLine(); if (newitem == "exit") { break; } if (newitem == "belt") { string strBeltOutput = sr.ReadLine(); MapObject mo = new MapObject(MOType.Belt, Utilz.GetFOTypeAssociatedToString(strBeltOutput)); mo.vpos.X = Convert.ToSingle(sr.ReadLine().Replace(".", ",")); mo.vpos.Y = Convert.ToSingle(sr.ReadLine().Replace(".", ",")); this.listMO.Add(mo); } if (newitem == "machine") { string strRecipe = sr.ReadLine(); MapObject mo = new MapObject(MOType.Machine, Utilz.GetFOTypeAssociatedToString(strRecipe)); mo.NeedCoal = sr.ReadLine() == "true"; mo.vpos.X = Convert.ToSingle(sr.ReadLine().Replace(".", ",")); mo.vpos.Y = Convert.ToSingle(sr.ReadLine().Replace(".", ",")); this.listMO.Add(mo); } } }
public oMap(string filepath) { this.EveryItemWhereLoadedCorrectly = true; //will becomes false if there is at least one item that wasn't found in the item list of the static class Crafts. List <string> alll = System.IO.File.ReadAllLines(filepath).ToList(); SaveReader sr = new SaveReader(alll); //first line is save file format version string strVersion = sr.ReadLine(); while (true) { //first step is read the next object to add to the map. //second step is read the properties of that object. we knows in which order properties are written string newitem = sr.ReadLine(); if (newitem == "exit") { break; } if (newitem == "belt") { string strBeltOutput = sr.ReadLine(); MapObject mo = new MapObject(MOType.Belt, Crafts.GetItemFromName(strBeltOutput)); mo.vpos.X = Convert.ToSingle(sr.ReadLine().Replace(".", ",")); mo.vpos.Y = Convert.ToSingle(sr.ReadLine().Replace(".", ",")); this.listMO.Add(mo); //check if the item was found when Crafts.GetItemFromName if (mo.BeltOutput != null) { if (mo.BeltOutput.Name == "none") { this.EveryItemWhereLoadedCorrectly = false; } } else { this.EveryItemWhereLoadedCorrectly = false; } } if (newitem == "machine") { string strRecipe = sr.ReadLine(); MapObject mo = new MapObject(MOType.Machine, Crafts.GetItemFromName(strRecipe)); mo.NeedCoal = sr.ReadLine() == "true"; mo.vpos.X = Convert.ToSingle(sr.ReadLine().Replace(".", ",")); mo.vpos.Y = Convert.ToSingle(sr.ReadLine().Replace(".", ",")); this.listMO.Add(mo); //check if the item was found when Crafts.GetItemFromName if (mo.TheRecipe != null) { if (mo.TheRecipe.Name == "none") { this.EveryItemWhereLoadedCorrectly = false; } } else { this.EveryItemWhereLoadedCorrectly = false; } } if (newitem == "mod") { string modname = sr.ReadLine(); //get the mod name this.listModNames.Add(modname); } } }