Example #1
0
        public static void EnableSystem(string system)
        {
            if (m_RegSystems.ContainsKey(system))
            {
                Type t = ScriptCompiler.FindTypeByFullName(system);
                if (t != null)
                {
                    if (!Directory.Exists("ACC Backups"))
                    {
                        Directory.CreateDirectory("ACC Backups");
                    }

                    ACCSystem sys = (ACCSystem)Activator.CreateInstance(t);
                    if (sys != null)
                    {
                        sys.StartLoad("ACC Backups/");
                        sys.Enable();
                    }
                    m_RegSystems[system] = true;
                }
            }
            else
            {
                Console.WriteLine("Invalid System - {0} - Cannot enable.", system);
            }
        }
Example #2
0
        public static void Load()
        {
            if (!Directory.Exists("Saves/ACC"))
            {
                return;
            }

            string   filename  = "acc.sav";
            string   path      = @"Saves/ACC/";
            string   pathNfile = path + filename;
            DateTime start     = DateTime.Now;

            Console.WriteLine();
            Console.WriteLine("----------");
            Console.WriteLine("Loading ACC...");

            try
            {
                using (FileStream m_FileStream = new FileStream(pathNfile, FileMode.Open, FileAccess.Read))
                {
                    BinaryReader     m_BinaryReader = new BinaryReader(m_FileStream);
                    BinaryFileReader reader         = new BinaryFileReader(m_BinaryReader);

                    if (m_RegSystems == null)
                    {
                        m_RegSystems = new Dictionary <string, bool>();
                    }

                    int Count = reader.ReadInt();
                    for (int i = 0; i < Count; i++)
                    {
                        string system  = reader.ReadString();
                        Type   t       = ScriptCompiler.FindTypeByFullName(system);
                        bool   enabled = reader.ReadBool();

                        if (t != null)
                        {
                            m_RegSystems[system] = enabled;

                            if (m_RegSystems[system])
                            {
                                ACCSystem sys = (ACCSystem)Activator.CreateInstance(t);
                                if (sys != null)
                                {
                                    sys.StartLoad(path);
                                }
                            }
                        }
                    }

                    reader.Close();
                    m_FileStream.Close();
                }

                Console.WriteLine("Done in {0:F1} seconds.", (DateTime.Now - start).TotalSeconds);
                Console.WriteLine("----------");
                Console.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed. Exception: " + e);
            }
        }