Exemplo n.º 1
0
 public bool Filter(string lev, LevelLocation location = LevelLocation.Any)
 {
     try
     {
         LevelType levelType = LevelType.Invalid;
         if (LSFilterLevelType._types.TryGetValue(lev, out levelType))
         {
             return(levelType == this._type);
         }
         LevelData levelData = (LevelData)null;
         if (!LSItem.bullshitLevelCache.TryGetValue(lev, out levelData))
         {
             levelData = DuckFile.LoadLevel(lev);
             LSItem.bullshitLevelCache[lev] = levelData;
         }
         if (levelData == null)
         {
             LSFilterLevelType._types[lev] = LevelType.Invalid;
             return(false);
         }
         if (this._needsDeathmatchTag && location == LevelLocation.Workshop && (levelData.metaData.workshopID != 0UL && !levelData.metaData.deathmatchReady))
         {
             LSFilterLevelType._types[lev] = LevelType.Strange;
             return(false);
         }
         LevelType type = levelData.metaData.type;
         LSFilterLevelType._types[lev] = type;
         return(type == this._type);
     }
     catch
     {
         LSFilterLevelType._types[lev] = LevelType.Invalid;
         return(false);
     }
 }
Exemplo n.º 2
0
 private static void ProcessLevel(string path, LevelLocation location)
 {
     try
     {
         Main.SpecialCode = "Loading Level " + path != null ? path : "null";
         if (!path.EndsWith(".lev"))
         {
             return;
         }
         path = path.Replace('\\', '/');
         LevelData dat = location != LevelLocation.Content ? DuckFile.LoadLevel(path) : DuckFile.LoadLevel(DuckFile.ReadEntireStream(TitleContainer.OpenStream(path)));
         if (dat != null)
         {
             dat.SetPath(path);
             path = path.Substring(0, path.Length - 4);
             path.Substring(path.IndexOf("/levels/") + 8);
             if (dat.metaData.guid != null)
             {
                 DuckGame.Content.MapLevel(dat.metaData.guid, dat, location);
             }
         }
         ++MonoMain.loadyBits;
     }
     catch (Exception ex)
     {
         DuckGame.Content.LogLevelFailure(ex.ToString());
     }
 }
Exemplo n.º 3
0
 private static void SearchDirLevels(string dir, LevelLocation location)
 {
     foreach (string path in location == LevelLocation.Content ? DuckGame.Content.GetFiles(dir) : DuckFile.GetFiles(dir))
     {
         DuckGame.Content.ProcessLevel(path, location);
     }
     foreach (string dir1 in location == LevelLocation.Content ? DuckGame.Content.GetDirectories(dir) : DuckFile.GetDirectories(dir))
     {
         DuckGame.Content.SearchDirLevels(dir1, location);
     }
 }
Exemplo n.º 4
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
     SceneManager.sceneLoaded += LevelCheck;
     bolaEmUso = PlayerPrefs.GetInt("BolaUse");
 }
Exemplo n.º 5
0
        public static LevelData GetLevel(string guid, LevelLocation location = LevelLocation.Any)
        {
            List <LevelData> list;

            if (DuckGame.Content._levels.TryGetValue(guid, out list))
            {
                foreach (LevelData levelData in list)
                {
                    if (levelData.GetLocation() == location || location == LevelLocation.Any)
                    {
                        return(levelData);
                    }
                }
            }
            return((LevelData)null);
        }
Exemplo n.º 6
0
        public static List <string> GetLevels(string dir, LevelLocation location)
        {
            List <string> stringList = new List <string>();

            foreach (KeyValuePair <string, List <LevelData> > level in (MultiMap <string, LevelData, List <LevelData> >)DuckGame.Content._levels)
            {
                foreach (LevelData levelData in level.Value)
                {
                    if ((levelData.GetLocation() == location || location == LevelLocation.Any) && levelData.GetPath().IndexOf(dir + "/") >= 0)
                    {
                        stringList.Add(level.Key);
                    }
                }
            }
            return(stringList);
        }
Exemplo n.º 7
0
        private static void ProcessLevel(string path, LevelLocation location)
        {
            Main.SpecialCode = "Loading Level " + path != null ? path : "null";
            if (!path.EndsWith(".lev"))
            {
                return;
            }
            path = path.Replace('\\', '/');
            LevelData levelData = DuckFile.LoadLevel(path);

            levelData.SetPath(path);
            path = path.Substring(0, path.Length - 4);
            path.Substring(path.IndexOf("/levels/") + 8);
            bool flag1 = true;

            if (levelData.modData.workshopIDs.Count != 0)
            {
                foreach (ulong workshopId in levelData.modData.workshopIDs)
                {
                    bool flag2 = false;
                    foreach (Mod accessibleMod in (IEnumerable <Mod>)ModLoader.accessibleMods)
                    {
                        if (accessibleMod.configuration != null && (long)accessibleMod.configuration.workshopID == (long)workshopId)
                        {
                            flag2 = true;
                            break;
                        }
                    }
                    if (!flag2)
                    {
                        flag1 = false;
                        break;
                    }
                }
            }
            if (flag1 && !levelData.modData.hasLocalMods)
            {
                RandomLevelDownloader._readyLevels.Add(levelData);
                DevConsole.Log(DCSection.Steam, "Downloaded random level " + RandomLevelDownloader._readyLevels.Count.ToString() + "/" + RandomLevelDownloader.numToHaveReady.ToString());
            }
            else
            {
                DevConsole.Log(DCSection.Steam, "Downloaded level had mods, and was ignored!");
            }
        }
Exemplo n.º 8
0
        public static string GetLevelID(string path, LevelLocation loc = LevelLocation.Content)
        {
            if (!path.EndsWith(".lev"))
            {
                path += ".lev";
            }
            foreach (KeyValuePair <string, List <LevelData> > level in (MultiMap <string, LevelData, List <LevelData> >)DuckGame.Content._levels)
            {
                foreach (LevelData levelData in level.Value)
                {
                    if ((levelData.GetLocation() == loc || loc == LevelLocation.Any) && levelData.GetPath().EndsWith("/" + path))
                    {
                        return(levelData.metaData.guid);
                    }
                }
            }
            LevelData levelData1 = DuckFile.LoadLevel(DuckGame.Content.path + "/levels/" + path + ".lev");

            return(levelData1 != null ? levelData1.metaData.guid : "");
        }
Exemplo n.º 9
0
        public static void MapLevel(string lev, LevelData dat, LevelLocation location)
        {
            List <LevelData> list;

            if (DuckGame.Content._levels.TryGetValue(lev, out list))
            {
                LevelData levelData1 = (LevelData)null;
                foreach (LevelData levelData2 in list)
                {
                    if (levelData2.GetLocation() == location)
                    {
                        levelData1 = levelData2;
                        break;
                    }
                }
                if (levelData1 != null)
                {
                    list.Remove(levelData1);
                }
            }
            dat.SetLocation(location);
            DuckGame.Content._levels.Add(lev, dat);
        }
Exemplo n.º 10
0
 public void SetLocation(LevelLocation loc) => this._location = loc;