Beispiel #1
0
        public static void DisableSystem(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.StartSave("ACC Backups/");
                        sys.Disable();
                    }
                    m_RegSystems[system] = false;
                }
            }
            else
            {
                Console.WriteLine("Invalid System - {0} - Cannot disable.", system);
            }
        }
Beispiel #2
0
        public static void Save(WorldSaveEventArgs args)
        {
            if (!Directory.Exists("Saves/ACC"))
            {
                Directory.CreateDirectory("Saves/ACC");
            }

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

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

            try
            {
                using (FileStream m_FileStream = new FileStream(pathNfile, FileMode.OpenOrCreate, FileAccess.Write))
                {
                    BinaryFileWriter writer = new BinaryFileWriter(m_FileStream, true);

                    writer.Write((int)m_RegSystems.Count);
                    foreach (KeyValuePair <string, bool> kvp in m_RegSystems)
                    {
                        Type t = ScriptCompiler.FindTypeByFullName(kvp.Key);
                        if (t != null)
                        {
                            writer.Write(kvp.Key);
                            writer.Write(kvp.Value);

                            if (kvp.Value)
                            {
                                ACCSystem system = (ACCSystem)Activator.CreateInstance(t);
                                if (system != null)
                                {
                                    system.StartSave(path);
                                }
                            }
                        }
                    }

                    writer.Close();
                    m_FileStream.Close();
                }

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