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); } }
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()); } }
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!"); } }
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 : ""); }
public static RandomLevelData LoadInTile(string tile, string realName = null) { RandomLevelData element = new RandomLevelData(); element.file = tile; if (realName != null) { element.file = realName; } LevelData levelData = Content.GetLevel(tile) ?? DuckFile.LoadLevel(tile); int sideMask = levelData.proceduralData.sideMask; if (sideMask == 0) { return((RandomLevelData)null); } if ((sideMask & 1) != 0) { element.up = true; } if ((sideMask & 2) != 0) { element.right = true; } if ((sideMask & 4) != 0) { element.down = true; } if ((sideMask & 8) != 0) { element.left = true; } element.chance = levelData.proceduralData.chance; element.max = levelData.proceduralData.maxPerLevel; element.single = levelData.proceduralData.enableSingle; element.multi = levelData.proceduralData.enableMulti; element.ApplyWeaponData(levelData.proceduralData.weaponConfig); element.ApplySpawnerData(levelData.proceduralData.spawnerConfig); element.numArmor = levelData.proceduralData.numArmor; element.numEquipment = levelData.proceduralData.numEquipment; element.numKeys = levelData.proceduralData.numKeys; element.numLockedDoors = levelData.proceduralData.numLockedDoors; element.numSpawns = levelData.proceduralData.numSpawns; element.numTeamSpawns = levelData.proceduralData.numTeamSpawns; element.canMirror = levelData.proceduralData.canMirror; element.isMirrored = levelData.proceduralData.isMirrored; element.data = levelData.objects.objects; LevelGenerator._tiles.Add(element); if (element.up) { LevelGenerator._connections.Add(TileConnection.Up, element); } if (element.down) { LevelGenerator._connections.Add(TileConnection.Down, element); } if (element.left) { LevelGenerator._connections.Add(TileConnection.Left, element); LevelGenerator._connections.Add(TileConnection.Right, element.Flipped()); } if (element.right) { LevelGenerator._connections.Add(TileConnection.Right, element); LevelGenerator._connections.Add(TileConnection.Left, element.Flipped()); } LevelGenerator._tiles.Add(element.Flipped()); return(element); }
public static LevelData LoadLevel(string path) { DuckFile.CreatePath(Path.GetDirectoryName(path)); DuckFile.PrepareToLoadCloudFile(path); return(!File.Exists(path) ? (LevelData)null : DuckFile.LoadLevel(File.ReadAllBytes(path))); }
public override void Initialize() { this._pauseGroup = new UIComponent(Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 0.0f, 0.0f); this._pauseMenu = new UIMenu("@LWING@PAUSE@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 160f, conString: "@DPAD@MOVE @SELECT@SELECT"); this._confirmMenu = new UIMenu("REALLY QUIT?", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 160f, conString: "@SELECT@SELECT"); this._testMode = new UIMenu("TEST MODE", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 160f, conString: "@SELECT@SELECT"); UIDivider uiDivider = new UIDivider(true, 0.8f); uiDivider.leftSection.Add((UIComponent) new UIMenuItem("RESTART", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._pauseGroup, this._restart), UIAlign.Left), true); uiDivider.leftSection.Add((UIComponent) new UIMenuItem("RESUME", (UIMenuAction) new UIMenuActionCloseMenu(this._pauseGroup), UIAlign.Left), true); uiDivider.leftSection.Add((UIComponent) new UIMenuItem("OPTIONS", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)this._pauseMenu, (UIComponent)Options.optionsMenu), UIAlign.Left), true); uiDivider.leftSection.Add((UIComponent) new UIMenuItem("TEST MODE", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)this._pauseMenu, (UIComponent)this._testMode), UIAlign.Left), true); uiDivider.leftSection.Add((UIComponent) new UIText("", Color.White), true); uiDivider.leftSection.Add((UIComponent) new UIMenuItem("QUIT", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._pauseGroup, this._quit), UIAlign.Left), true); uiDivider.rightSection.Add((UIComponent) new UIImage("pauseIcons", UIAlign.Right), true); this._pauseMenu.Add((UIComponent)uiDivider, true); this._pauseMenu.Close(); this._pauseGroup.Add((UIComponent)this._pauseMenu, false); this._pauseGroup.Add((UIComponent)Options.optionsMenu, false); Options.openOnClose = this._pauseMenu; this._confirmMenu.Add((UIComponent) new UIMenuItem("NO!", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)this._confirmMenu, (UIComponent)this._pauseMenu)), true); this._confirmMenu.Add((UIComponent) new UIMenuItem("YES!", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._pauseGroup, this._quit)), true); this._confirmMenu.Close(); this._pauseGroup.Add((UIComponent)this._confirmMenu, false); this._testMode.Add((UIComponent) new UIMenuItemNumber("PLAYERS", field: new FieldBinding((object)this, "numPlayers", 2f, 4f, 1f)), true); this._testMode.Add((UIComponent) new UIMenuItem("START", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._pauseGroup, this._startTestMode)), true); this._testMode.Add((UIComponent) new UIText("", Color.White), true); this._testMode.Add((UIComponent) new UIMenuItem("CANCEL", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)this._testMode, (UIComponent)this._pauseMenu), backButton: true), true); this._testMode.Close(); this._pauseGroup.Add((UIComponent)this._testMode, false); this._pauseGroup.Close(); Level.Add((Thing)this._pauseGroup); if (this._level == "RANDOM") { LevelGenerator.MakeLevel(this._center, this._center.left && this._center.right, this._seed, this._genType, Editor._procTilesWide, Editor._procTilesHigh, Editor._procXPos, Editor._procYPos).LoadParts(0.0f, 0.0f, (Level)this, this._seed); List <SpawnPoint> source1 = new List <SpawnPoint>(); foreach (SpawnPoint spawnPoint in this.things[typeof(SpawnPoint)]) { source1.Add(spawnPoint); } List <SpawnPoint> chosenSpawns = new List <SpawnPoint>(); for (int index = 0; index < 4; ++index) { if (chosenSpawns.Count == 0) { chosenSpawns.Add(source1.ElementAt <SpawnPoint>(Rando.Int(source1.Count - 1))); } else { IOrderedEnumerable <SpawnPoint> source2 = source1.OrderByDescending <SpawnPoint, int>((Func <SpawnPoint, int>)(x => { int num = 9999999; foreach (Transform transform in chosenSpawns) { num = (int)Math.Min((transform.position - x.position).length, (float)num); } return(num); })); chosenSpawns.Add(source2.First <SpawnPoint>()); } } foreach (SpawnPoint spawnPoint in source1) { if (!chosenSpawns.Contains(spawnPoint)) { Level.Remove((Thing)spawnPoint); } } PyramidBackground pyramidBackground = new PyramidBackground(0.0f, 0.0f); pyramidBackground.visible = false; Level.Add((Thing)pyramidBackground); } else { this._level = this._level.Replace(Directory.GetCurrentDirectory() + "\\", ""); LevelData levelData = DuckFile.LoadLevel(this._level); if (levelData != null) { foreach (BinaryClassChunk node in levelData.objects.objects) { Thing t = Thing.LoadThing(node); if (t != null) { if (!t.visibleInGame) { t.visible = false; } this.AddThing(t); } } } } this.things.RefreshState(); foreach (Duck spawnPlayer in new Deathmatch((Level)this).SpawnPlayers()) { Level.Add((Thing)spawnPlayer); this.followCam.Add((Thing)spawnPlayer); } }