public static void load() { if (!File.Exists(misc.getServerPath() + @"\data\npcs.xml")) { misc.WriteError(@"Missing data\npcs.xml"); return; } try { //Deserialize text file to a new object. StreamReader objStreamReader = new StreamReader(misc.getServerPath() + @"\data\npcs.xml"); XmlSerializer serializer = new XmlSerializer(typeof(List<NpcSpawn>)); List<NpcSpawn> spawns = (List<NpcSpawn>)serializer.Deserialize(objStreamReader); foreach (NpcSpawn ns in spawns) { Npc n = new Npc(ns.id, ns.location); n.setMinimumCoords(ns.minimumCoords); n.setMaximumCoords(ns.maximumCoords); n.setWalkType(ns.walkType); n.setFaceDirection(ns.faceDirection); Server.getNpcList().Add(n); } } catch (Exception e) { misc.WriteError((e.InnerException == null ? e.ToString() : e.InnerException.ToString())); } Console.WriteLine("Spawned " + Server.getNpcList().Count + " npcs."); }