Exemplo n.º 1
0
        public static void loadSavedData()
        {
            loadConfigs();

            string world = MyAPIGateway.Session.Name;

            try {
                EMP.blockReactivations.Clear();

                if (MyAPIGateway.Utilities.FileExistsInWorldStorage("blocks_to_reactivate_" + world + ".cfg", typeof(SavedTimedBlock)))
                {
                    TextReader reader  = MyAPIGateway.Utilities.ReadFileInWorldStorage("blocks_to_reactivate_" + world + ".cfg", typeof(SavedTimedBlock));
                    string     xmlText = reader.ReadToEnd();
                    reader.Close();
                    List <SavedTimedBlock> li = MyAPIGateway.Utilities.SerializeFromXML <List <SavedTimedBlock> >(xmlText);
                    if (li != null)
                    {
                        EMP.blockReactivations.AddList(li);
                    }
                }
                IO.log("Loaded reactivation list. Data = " + toUsefulString(EMP.blockReactivations));
            }
            catch (Exception ex) {
                log("Threw exception reading reactivation list: " + ex.ToString());
            }

            try {
                List <long> li = new List <long>();
                if (MyAPIGateway.Utilities.FileExistsInWorldStorage("cloaked_grids_" + world + ".cfg", typeof(long)))
                {
                    TextReader reader  = MyAPIGateway.Utilities.ReadFileInWorldStorage("cloaked_grids_" + world + ".cfg", typeof(long));
                    string     xmlText = reader.ReadToEnd();
                    reader.Close();
                    li = MyAPIGateway.Utilities.SerializeFromXML <List <long> >(xmlText);
                    CloakingDevice.loadCloakedGridsFromFile(li);
                }
                IO.log("Loaded cloaking list. Data = " + toUsefulString(li));
            }
            catch (Exception ex) {
                log("Threw exception reading cloaking list: " + ex.ToString());
            }
        }