Example #1
0
        void LoadMainLevel()
        {
            try {
                if (LevelInfo.ExistsOffline(level))
                {
                    mainLevel        = Level.Load(level);
                    mainLevel.unload = false;
                    if (mainLevel == null)
                    {
                        if (File.Exists(LevelInfo.LevelPath(level) + ".backup"))
                        {
                            Log("Attempting to load backup of " + level + ".");
                            File.Copy(LevelInfo.LevelPath(level) + ".backup", LevelInfo.LevelPath(level), true);
                            mainLevel = Level.Load(level);
                            if (mainLevel == null)
                            {
                                Log("BACKUP FAILED!");
                                Console.ReadLine(); return;
                            }
                        }
                        else
                        {
                            Log("mainlevel not found");
                            mainLevel = new Level(level, 128, 64, 128);
                            MapGen.Generate(mainLevel, "flat", "", null);
                            mainLevel.Save();
                        }
                    }
                }
                else
                {
                    Log("mainlevel not found");
                    mainLevel = new Level(level, 128, 64, 128);
                    MapGen.Generate(mainLevel, "flat", "", null);
                    mainLevel.Save();
                }
                LevelInfo.Loaded.Add(mainLevel);

                // fenderrock - Make sure the level does have a physics thread
                if (mainLevel.physThread == null)
                {
                    mainLevel.StartPhysics();
                }
            } catch (Exception e) {
                ErrorLog(e);
            }
        }
Example #2
0
 public Level(string n, ushort x, ushort y, ushort z, string type, int seed = 0, bool useSeed = false)
 {
     Init(n, x, y, z);
     MapGen.Generate(this, type, seed, useSeed);
 }
Example #3
0
 public Level(string n, ushort x, ushort y, ushort z, string theme, string genArgs)
 {
     Init(n, x, y, z);
     MapGen.Generate(this, theme, genArgs, null);
 }