LevelSelectionController - alexneargarder/Broforce-Docs GitHub Wiki

LevelSelectionController

Table of Contents

Level Loading & Transitions

Methods

public static MapData GetCurrentMap()

Retrieves the MapData for the current level based on the game's load mode and settings. This is the primary method for obtaining level data and handles all different load scenarios.

Returns:

  • MapData: The MapData for the current level, or null if no valid level data could be loaded.

private static MapData GetMapDataForCampaign()

Loads map data for the current campaign based on game mode and level number. Handles special cases for BroDown mode (player count based levels), versus modes with rotation, and victory screen for completed campaigns.

Returns:

  • MapData: The MapData for the current level, or victory screen data if the campaign is complete.

private static MapData GetMapDataFromFile()

Loads map data from a file on disk. Attempts to load as a campaign first, falling back to single level loading if that fails. Updates the level file name tracking.

Returns:

  • MapData: The loaded MapData, or null if no valid file name is set.

public static void GotoNextCampaignScene()

Handles the transition to the next scene in the campaign sequence, including special handling for the helicopter intro cutscene at the start of the main campaign.


public static void GotoNextLevel()

Advances to the next level in the current campaign by incrementing the level number and reloading the current scene. Resets to level 0 if past the end of the campaign.


public static void ResetLevelAndGameModeToDefault()

Resets all level selection and game mode settings to their default values. This comprehensive reset is called when returning to the main menu or starting a fresh game session.


public static void RestartCampaignScene()

Initiates a restart of the current campaign scene by triggering a fade transition. This method is called when the player chooses to retry a failed level.


Campaign Management

Methods

public static void CompleteCurrentLevel()

Marks the current level as complete by incrementing the level number and saving progress for online campaigns. Resets the helicopter intro flag for the next level.


internal static void DmRotationLevelLoadComplete(Campaign campaign)

Called when a deathmatch rotation level finishes downloading. Assigns the campaign to the appropriate rotation slot and initiates download of the next level if needed.

Parameters:

  • Campaign campaign: The downloaded campaign to add to the rotation.

public static void FindOnlineDeathmatchLevels()

Queries Steam Workshop for deathmatch levels using either vote ranking (70% chance) or trend ranking (30% chance). Initiates the asynchronous query and sets up the callback handler.


public static string GetFormattedCampaignName(string campaignFileName)

Formats a campaign file name into a display name by converting to uppercase, removing prefixes, and looking up formatted names. Used for campaign display in UI and presence text.

Parameters:

  • string campaignFileName: The raw campaign file name to format (e.g., "WM_Mission1").

Returns:

  • string: The formatted campaign name (e.g., "2" for "MISSION1") or the cleaned uppercase name if no lookup exists.

internal static void LoadNextVersusCampaign()

Loads the next campaign in the versus rotation system. Handles both online deathmatch rotation with Steam Workshop levels and offline rotation with local campaigns. Manages the campaign queue and initiates downloads for upcoming levels.


private static void SetLevelPresence()

Sets the platform-specific presence text based on the current campaign and level. Displays different text for challenge levels, arcade levels, and campaign levels.


private static void UGC_UGCQueryCompleted(SteamUGCQueryCompleted_t value, bool ioFailure)

Callback handler for Steam Workshop queries. Processes the returned deathmatch levels, creates WorkshopLevelDetails objects, and selects levels for the current and next rotation slots.

Parameters:

  • SteamUGCQueryCompleted_t value: The Steam UGC query result containing workshop level information.
  • bool ioFailure: Whether the query failed due to an IO error.

Properties

public static string campaignToLoad { get; set; }

Gets or sets the name of the campaign that should be loaded. This property stores and retrieves the campaign name from the GameState singleton instance, ensuring that the campaign name persists across scene transitions.


public static Campaign currentCampaign { get; set; }

Gets or sets the currently loaded Campaign object containing all level data for the active campaign. Setting this property also updates the campaign name in GameState for persistence.


public static string levelFileNameToLoad { get; set; }

Gets or sets the name of the level file to be loaded. This property is used when loading individual level files from disk rather than campaign files. The property acts as a wrapper around the internal _levelFileNameToLoad field.


public static bool loadCustomCampaign { get; set; }

Gets or sets whether a custom campaign (user-created or downloaded) should be loaded instead of the built-in campaigns. This flag is stored in the GameState singleton and controls the campaign loading behavior.


public static bool returnToWorldMap { get; set; }

Gets or sets whether the game should return to the world map after completing the current level or campaign. This property controls the flow between the world map mode and individual levels.


Fields

public static string _levelFileNameToLoad

Internal backing field for the levelFileNameToLoad property. Stores the file name of a level to be loaded from disk.


private static Campaign CurrentCampaign

Private backing field that stores the currently loaded campaign. Accessed through the currentCampaign property which handles campaign validation and loading.


public static Campaign currentVSRotationCampaign

Stores the current campaign in the versus mode rotation for online deathmatch games. When using online deathmatch level rotation, this holds the campaign that is currently active. Gets set when a deathmatch rotation level completes loading via DmRotationLevelLoadComplete. Used by LoadNextVersusCampaign to determine which campaign to load as the current campaign.


public static WorkshopLevelDetails currentWorkshopLevel

Stores details about the currently loaded Steam Workshop level. Used when playing custom user-created content from the Workshop. Null when playing built-in campaigns.


public static string DefaultCampaign = LevelSelectionController.OfflineCampaign

The default campaign to load when no specific campaign is selected. Initialized to the offline campaign ("vietnam") by default.


public static bool defaultDeathmatchCampaignIncludedInRotation = false

Whether the default deathmatch campaign should be included in the versus rotation. Allows the built-in deathmatch maps to be part of the rotation.


public static bool defaultRaceCampaignIncludedInRotation = false

Whether the default race campaign should be included in the versus rotation. Allows the built-in race maps to be part of the rotation.


public static string ExpendabrosCampaign = "Expendabros_Campaign"

The campaign name for the Expendabros crossover content. Set to "Expendabros_Campaign" to identify and load Expendabros-specific levels.


private static bool haveSetListCallResult

Private flag tracking whether the Steam Workshop query callback has been initialized. Prevents duplicate callback registration when querying Workshop content.


public static bool isOnlineCampaign

Flag indicating whether the currently loaded campaign is an online multiplayer campaign. Used to determine networking behavior and level selection logic.


private static int lastVersusCampaign = -100

Private field tracking the index of the last versus campaign played. Initialized to -100 to ensure no campaign matches on first selection. Used to prevent immediate repetition of versus campaigns.


public static WorkshopLevelDetails levelDetailsCurrentVSRotationCampaign

Stores the workshop level details for the current campaign in the versus rotation. Contains metadata about the current online deathmatch level including file ID and creator info. Set when online VS levels are loaded from Steam Workshop query results. Used to track which specific workshop level is currently active in the rotation.


public static WorkshopLevelDetails levelDetailsNextVSRotationCampaign

Stores the workshop level details for the next campaign queued in the versus rotation. Contains metadata about the next online deathmatch level to be loaded after the current one. Set when selecting random levels from the online VS levels list during Steam query processing. Cleared when the next level is promoted to current in LoadNextVersusCampaign.


private static CallResult<SteamUGCQueryCompleted_t> listCallResult

Private Steam API callback result for Workshop content queries. Used internally when fetching lists of available Workshop levels for versus mode or custom campaigns.


public static bool loadPublishedCampaign

Flag indicating whether the game should load a published campaign from the Workshop or other external source. Checked during campaign loading to determine the source.


public static MapData MapDataToLoad

Stores pre-loaded map data to be used when LoadFromMapdata mode is active. Allows external code to set specific map data before level loading.


public static Campaign nextVSRotationCampaign

Stores the next campaign queued in the versus mode rotation for online deathmatch games. When the current VS rotation campaign ends, this campaign becomes the new current campaign. Gets set by DmRotationLevelLoadComplete when a second campaign loads while one is already current. Cleared after being promoted to current campaign in LoadNextVersusCampaign.


public static string OfflineCampaign = "vietnam"

The default campaign name used for offline single-player gameplay. Set to "vietnam" to use the standard Vietnam campaign levels.


public static string OnlineCampaign = "VietnamNetworked"

The default campaign name used for online multiplayer gameplay. Set to "VietnamNetworked" to use the networked version of the Vietnam campaign levels.


private static List<WorkshopLevelDetails> onlineVSLevels

Private list storing available online versus mode levels from the Workshop. Used to randomly select levels for versus mode rotation without repeating recently played levels.


public static bool usingOnlineDMLevelRotation

Indicates whether the game is currently using online deathmatch level rotation mode. When true, LoadNextVersusCampaign will use the VS rotation campaign fields instead of standard progression. Set to false during initialization and controlled by the deathmatch menu system. Determines whether to use rotation-based campaign loading for versus mode.


public static List<string> versusRotationList = new List<string>()

List of campaign file names included in the versus mode rotation. Used for offline deathmatch and race modes to cycle through available maps.


Level Progression

Properties

public static int CurrentLevelNum { get; set; }

Gets or sets the current level number (index) within the active campaign. This property wraps GameState.Instance.levelNumber for consistency.


Fields

public static int exhibitionCount = -1

Counter for exhibition mode levels. Initialized to -1, likely incremented during exhibition gameplay to track progress or determine exhibition-specific behavior.


public const int levelNumBrodownBurningJungle = 1

Constant defining the level number for the Brodown Burning Jungle level. Set to 1, used for identifying this specific level in campaigns or level sequences.


public const int levelNumBrodownCity = 2

Constant defining the level number for the Brodown City level. Set to 2, used for identifying this specific level in campaigns or level sequences.


public static bool shownHelicopterIntro = false

Flag tracking whether the helicopter intro sequence has been shown to the player. Prevents the intro from playing multiple times when starting campaigns from the beginning.


public static int totalNumberOfArcadeLevels = 63

The total number of levels available in arcade mode. Set to 63, used to determine when players have completed all arcade content and for progress tracking.


Campaign State Queries

Methods

public static int GetCurrentCampaignLength()

Gets the total number of levels in the current campaign based on the game mode.

Returns:

  • int: The number of levels in the current campaign. Returns 1 for cutscene mode, 0 if no campaign is loaded, or the actual campaign length for other modes.

public static bool IsCustomCampaign()

Determines whether the currently loaded campaign is a custom campaign (user-created or from Steam Workshop).

Returns:

  • bool: True if either loadCustomCampaign or isOnlineCampaign flags are set, false for built-in campaigns.

public static bool IsInProcGenCampaign()

Determines whether the game is currently playing procedurally generated levels rather than pre-designed campaign levels.

Returns:

  • bool: True if not in world map mode and the load mode is set to Generated, false otherwise.

public static bool IsInWorldMapCampaign()

Determines whether the game is currently in world map campaign mode where players progress through a 3D world map selecting territories.

Returns:

  • bool: True if the returnToWorldMap flag is set, false otherwise.

public static bool SpawnAsheAndHisCar()

Determines whether Ash Williams and his car should spawn in the current level. This is used for special Evil Dead crossover content in specific levels.

Returns:

  • bool: True if the current level's description contains "deep throat" (case-insensitive), false otherwise.

Scene Management

Properties

public static string CurrentGameModeScene { get; set; }

Gets the appropriate scene name for the current game mode. Different game modes use different scenes to handle their specific gameplay requirements.


public static string CustomCampaignVictoryScene { get; set; }

Gets the name of the victory scene to use when completing a custom campaign. Returns different scene names based on whether Steam is enabled to handle different victory screen requirements.


public static string ExhibitionCampaign { get; set; }

Gets the name of the campaign to use in exhibition mode, which varies based on demo settings and current scene. This property determines which special campaign should be loaded for exhibition/demo builds.


public static string MainMenuScene { get; set; }

Gets the appropriate main menu scene name based on the build type. Returns different scene names for the Expendabros promotional build versus the standard Broforce build.


Fields

private const string _MainMenuScene = "MainMenu"

Private constant storing the main menu scene name. Set to "MainMenu" and used internally for scene transitions back to the main game menu.


public static string BrodownSceneName = "Test Evan2"

The scene name used for brodown game mode. Default value is "Test Evan2".


public static string CampaignScene = "Test Evan2"

The current scene name used for campaign mode. Default value is "Test Evan2".


public static string CampaignSceneDefault = "Test Evan2"

The default scene name for campaign mode. Used as a fallback when no specific campaign scene is set. Default value is "Test Evan2".


public static string DeathmatchSceneName = "Test Evan2"

The scene name used for deathmatch game mode. Default value is "Test Evan2".


public static string ExplosionRunSceneName = "Test Evan2"

The scene name used for explosion run game mode. Default value is "Test Evan2".


public const string GameOverScene = "CutsceneGameOver"

The scene name for the game over cutscene. Set to "CutsceneGameOver" which plays when all players have died and no lives remain.


public static string HellArcade = "WM_Hell"

The scene name for the Hell-themed arcade mode. Set to "WM_Hell" which represents the Hell world map used in arcade gameplay.


public const string HeroSelectScreen = "HeroSelect"

The scene name for the hero selection screen. Set to "HeroSelect" which allows players to choose their character before starting gameplay.


public const string IntroScene = "Intro"

The scene name for the game's intro cutscene. Set to "Intro" which plays when starting a new campaign from the beginning.


public static string JoinScene = "newJoin"

The scene name used for joining multiplayer games. Default value is "newJoin".


public const int levelNumBrodownJungle = 0

Constant defining the level number for the Brodown jungle level. Value is 0.


public const string MainMenuSceneExpendabros = "MainMenuExpendabros"

The scene name for the Expendabros-specific main menu. Set to "MainMenuExpendabros" to provide a themed menu for the Expendabros crossover content.


public static string OfflineCustomVictoryScene = "VictoryCustomCampaign"

The scene name for the victory screen shown after completing offline custom campaigns. Set to "VictoryCustomCampaign" to provide a different ending for user-created content.


public static string RaceRunSceneName = "Test Evan2"

The scene name used for race game mode. Default value is "Test Evan2".


public static string SuicideHordeSceneName = "Test Evan2"

The scene name used for suicide horde game mode. Default value is "Test Evan2".


public static string VictoryScene = "Polaroid"

The scene name for the standard victory screen. Set to "Polaroid" which displays the victory polaroid photo sequence after completing a campaign.


public static string WorldMapScene = "WorldMap3D"

The scene name for the world map screen. Default value is "WorldMap3D".


Scene State

Properties

public static bool CurrentlyInGame { get; set; }

Gets whether the player is currently in an active game (not in the main menu).


public static bool IsCampaignScene { get; set; }

Gets whether the currently active scene is the campaign gameplay scene.


public static bool IsLoadingScene { get; set; }

Gets whether the currently active scene is the loading screen scene.


public static bool IsMainMenuScene { get; set; }

Gets whether the currently active scene is the main menu scene.


public static bool IsMainMenuSceneLoading { get; set; }

Gets whether the main menu scene is currently set to load next (during scene transitions).


public static bool IsWorldMapScene { get; set; }

Gets whether the currently active scene is the 3D world map scene.


⚠️ **GitHub.com Fallback** ⚠️