HeroController - alexneargarder/Broforce-Docs GitHub Wiki
- Unity Lifecycle & Setup
- Character State & Effects
- Input & Control
-
Player Management
-
Methods
- AddHeroToAlreadyChosenHeroes
- AddLife
- AddLocalPlayer
- AddPlayer
- AssignPlayerCharacter
- AttachHeroToHelicopter
- AutoJoinLocalHost
- ChangeBro
- DecreaseAmmo
- DeregisterPlayer
- DetachHeroFromHelicopter
- Dropout
- DropoutRPC
- FindAndFlashNextSpawnDoor
- FlagPlayerToDrop
- FlashSpecialAmmo
- GetCurrentHeroType
- GetDefaultPlayerName
- GetFireKeyDown
- GetHeroColor
- GetHeroColorName
- GetHeroName
- GetHeroPrefab
- GetHeroType
- GetLastSpecialAmmo
- GetMostRightHero
- GetNextUnusedPlayerNumber
- GetNthAvailableSlot
- GetNthLocalPlayerPlaying
- GetPidFromControl
- GetPlayerName
- GetPlayerNumForControllerID
- GetPlayerUsingController
- GetSpecialAmmo
- GiveAllLifelessPlayersALife
- HaveAllHerosBeenInstantiated
- IsControIdRegisteredToPID
- IsControllerIDUsed
- IsPlayerActiveForControllerID
- IsPlayerPlaying
- IsTypeInUse
- KickPlayersIfHeHasNotJoined
- KickPlayersIfHeHasNotJoinedRoutine
- MonitorPlayerDropin
- PlayerExists
- RecieveHeroTypeFromMaster
- RegisterHeroToPlayer
- RequestAllPlayerData
- RequestHeroTypeFromMaster
- RequestHeroTypeFromMasterRPC
- RequestJoinGame
- RestartAllHeroesBubbles
- SetAllHeroesImmuneToOutOfBounds
- SetAllHeroesInvulnerable
- SetIsPlaying
- SetLives
- SetOriginalSpecialAmmoCount
- SetPlayerCharacter
- SetPlayerName
- SetSpecialAmmo
- SpawnJoinedPlayers
- SpawnSuicideBro
- UpdatePlayerData
- UpdatePlayerUserData
- Fields
-
Methods
-
Player Status
-
Methods
- AreAllHerosDead
- AreAllOtherHerosDead
- AtLeastOnePlayerStillHasALife
- GetFirstHeroAlive
- GetFirstPlayerPosition
- GetLocalPlayerCount
- GetPlayerLives
- GetPlayersAliveCount
- GetPlayersOnHelicopterAmount
- GetPlayersPlayingCount
- GetTotalLives
- HasJustStarted
- HaveAllPlayersHaveSpawned
- HaveAllPlayersJoined
- IsAnyHeroDead
- IsAnyPlayerDead
- IsDead
- IsPlaying
- NumberOfPlayers
- NumberOfPlayersOnThisPC
- PlayerHasALife
- PlayerHasDied
- PlayerHasDiedRPC
- PlayerIsAlive
- PlayerIsBeingRescuedOrRespawned
- PlayerIsInvulnerable
- PlayerIsNotInStealth
- PlayerIsOnHelicopter
- ResetPlayersPlaying
- UpdateDeathOrder
-
Methods
-
Player Detection
-
Methods
- CanSeePlayer
- CanSeePlayer
- CanSeePlayer
- CanSeePlayer
- GetActualNearestPlayer
- GetNearestPlayer
- GetNearestPlayer
- GetNearestPlayerPos
- GetNearestPlayerPos
- GetPlayerPos
- GetPlayerPos
- GetPlayerPosition
- GetPlayerTransform
- GetRandomPlayerPlaying
- GetRandomPlayerPos
- GetRandomPlayerPos
- IsAnotherPlayerNearby
- IsPlayerNearby
- IsPlayerNearby
- IsPlayerNearby
- IsPlayerNearby
- IsPlayerNearby
- IsPlayerNearby
- IsPlayerNearby
- IsPlayerNearby
- IsPlayerThisWay
- IsPlayerThisWay
- IsPlayerThisWay
- Fields
-
Methods
- Rescue System
-
Game State Management
- Methods
- Properties
-
Fields
- _cameraHoldAfterLastHeroDeathTime
- _connectRegistered
- _curJoinMessageIndex
- _isCountdownFinished
- AllPlayersHaveJoined
- brosHaveBeenReleased
- checkPointSet
- checkPointStart
- currentCheckPointID
- explosivesCounter
- faded
- finishedCounter
- forceInvulnerability
- forceSpecificBro
- heroesHaveBeenReleasedFromTransport
- IDroppedOutThisRound
- lossCounterTime
- lossTimer
- nextHeroType
- playerDelayTime
- suicideBroSpawnDelay
- WaitForAllPlayersToSpawnBeforeStarting
- Game Flow Control
- Camera System
- UI/HUD System
- Serialization
- Testing/Debug
- Inner Class HeroDefinition
- Inner Class HeroSetupKeyPair
- Rescue System Section
- Camera System Section
Unity Awake method that initializes the HeroController singleton. Sets up the instance reference, registers network event handlers for player drops and disconnections, and initializes hero tracking collections. Also sets the initial spawn point if one exists in the scene.
Unity OnDestroy cleanup method. Unregisters network event handlers, clears the singleton instance reference, and disposes of all tracking collections to prevent memory leaks and ensure clean shutdown.
Unity Start method that initializes the HeroController. Sets up game state, loads input settings from PlayerPrefs, finds the spawn point, initializes perks system, spawns joined players, and begins the game sequence. Core initialization point for multiplayer hero management.
Main update loop for HeroController. Handles debug inputs, processes player drops, manages join messages, runs hero respawn logic, checks level completion, monitors player drop-ins, and updates time boost effects each frame.
Gets the singleton instance of HeroController, creating it if necessary. Provides global access to the hero controller for managing player spawning and game state. Uses lazy initialization with FindObjectOfType if the instance is null.
Returns:
-
HeroController
: The singleton HeroController instance.
Gets whether a HeroController instance currently exists in the scene. Used to check availability before accessing the singleton instance to avoid unnecessary creation.
Returns:
-
bool
: True if an instance exists; otherwise, false.
Private static instance reference for the singleton pattern. Stores the single HeroController instance to ensure only one exists. Accessed through the public Instance property with lazy initialization.
Reference to the Player prefab GameObject used for instantiating new players. Contains the template for creating networked player instances when players join the game session.
Static array holding all four possible Player instances. Central storage for player data, character references, and game state. Indexed by player number (0-3) for direct access to player information.
Activates steroid power-up for all living players simultaneously. Applies different time boost behavior based on game mode (competitive vs cooperative). Includes global time slow and color shift effects for dramatic impact.
Gets the chance for corpses to explode from any playing player's upgrades. Returns the exploding corpse chance value from the first playing player found. Used for applying consistent corpse explosion mechanics across all players.
Returns:
-
float
: The corpse explosion chance (0.0-1.0) or -1 if no players playing.
Gets the primary fire upgrade level for a specific player. Retrieves the modified value from the player's inventory value orchestrator. Returns 0 for invalid player numbers or if no upgrades are active.
Parameters:
- int playerNum: The player number to check.
Returns:
-
int
: The primary fire level (0 or higher).
Gets the secondary fire (special ability) upgrade level for a specific player. Retrieves the modified value from the player's inventory value orchestrator. Returns 0 for invalid player numbers or if no upgrades are active.
Parameters:
- int playerNum: The player number to check.
Returns:
-
int
: The secondary fire level (0 or higher).
public static void OneBroUseSteroids(int playerNum, float duration, bool timeSlowColors, bool highFiveSlowDown, float timeSlowDuration)
Activates steroid power-up for a single player with default settings. Applies networked steroid effect, Time Bro boost for 0.5 seconds, global time slow, and color shift visual effect. Standard quick steroid activation.
Parameters:
- int playerNum: The player number to apply steroids to.
public static void OneBroUseSteroids(int playerNum, float duration, bool timeSlowColors, bool highFiveSlowDown, float timeSlowDuration)
Activates steroid power-up for a single player with customizable parameters. Allows control over duration, visual effects, and whether to use high-five or standard time slow mechanics. Advanced steroid activation method.
Parameters:
- int playerNum: The player number to apply steroids to.
- float duration: Duration of the steroid effect in seconds.
- bool timeSlowColors: Whether to apply time slow color shift effect.
- bool highFiveSlowDown: Use high-five time slow instead of standard.
- float timeSlowDuration: Duration of the time slow effect.
Sets heroes within range to resurrect after death for the specified duration. This effect allows heroes to automatically respawn at their death location after being killed, useful for special game modes or power-ups.
Parameters:
- float x: X coordinate of the center position.
- float y: Y coordinate of the center position.
- float range: Radius of the effect area.
- float duration: Duration in seconds for the resurrection effect.
Sets a specific hero to invulnerable state for the specified duration. Validates the player number and checks that the player has a character instance before applying the invulnerability effect without showing halo or other visual indicators.
Parameters:
- int playerNum: The player number to set invulnerable.
- float duration: Duration in seconds for the invulnerability effect.
public static void SetHerosInvulnerable(float x, float y, float range, float duration, bool showHalo = false)
Sets all heroes within a specified range of a position to invulnerable state. Checks each player's distance from the center point and applies invulnerability if they are within the circular range. Optionally shows a visual halo effect.
Parameters:
- float x: X coordinate of the center position.
- float y: Y coordinate of the center position.
- float range: Radius of the effect area.
- float duration: Duration in seconds for the invulnerability effect.
- bool showHalo: Whether to display a visual halo effect on affected heroes.
Sets all offscreen heroes to invulnerable state for the specified duration. Loops through all players and applies invulnerability to characters that are not visible on screen. Also resets their teleport counter to -2 to prevent immediate teleportation.
Parameters:
- float duration: Duration in seconds for the invulnerability effect.
Remaining duration of time manipulation effects. Tracks how long time dilation from Time Bro abilities or power-ups should continue. Decrements each frame and restores normal time when it reaches zero.
Flag indicating if heroes have enhanced health. When true, heroes may have additional hit points or damage resistance. Used for special game modes or difficulty modifiers.
Sets controller vibration/rumble for all connected players simultaneously. Used for major events that should provide feedback to everyone, such as large explosions or environmental effects.
Parameters:
- float amount: The intensity of the rumble effect (0-1 range) for all controllers.
Sets controller vibration/rumble for a specific player. Provides haptic feedback through the controller to enhance game feel for explosions, impacts, or other significant events.
Parameters:
- int playerNum: The player number whose controller should rumble.
- float amount: The intensity of the rumble effect (0-1 range).
Adds a hero type to the list of already chosen heroes. Prevents duplicate entries and maintains the history of selected heroes for game modes that cycle through available characters.
Parameters:
- HeroType currentType: The hero type to add to the chosen list.
Adds one life to a specific player. Validates that the player exists and is actively playing before calling the player's AddLife method. Used for life pickups, rewards, or game mechanics that grant extra lives.
Parameters:
- int playerNum: The player number to add a life to.
Adds a new local player to the game session. Validates the controller isn't already in use, gets the player's username from the platform, and sends a join request to the server. Marks countdown as finished upon joining.
Parameters:
- int playernum: The player slot to add to (-1 for next available).
- int controllerID: The controller ID for the new player.
RPC method that adds a new player to the game. For local players, instantiates the player prefab with network buffering. For remote players, resets ping sampling. Also ensures enough bros are unlocked for all joined players.
Parameters:
- int playerNum: The slot number for the new player.
- int controllerNum: The controller ID for the new player.
- PID playerPID: The network player ID.
Assigns a character instance to a player who is not currently alive. Used during respawn operations to link the new character to the player's data structure. Only works if the player isn't already alive.
Parameters:
- int playerNum: The player number to assign the character to.
- TestVanDammeAnim character: The TestVanDammeAnim character instance to assign.
public void AttachHeroToHelicopter(Vector3 localPosition, float direction, TestVanDammeAnim hero, Helicopter heli, bool startExplosions)
Attaches a hero to a helicopter for extraction or transport. Disables the hero's normal functionality, parents them to the helicopter transform, and positions them appropriately. Handles special cases for different hero types.
Parameters:
- Vector3 localPosition: Local position relative to helicopter for attachment.
- float direction: Direction the hero should face (-1 or 1).
- TestVanDammeAnim hero: The hero character to attach to the helicopter.
- Helicopter heli: The helicopter to attach the hero to.
- bool startExplosions: Whether to trigger explosion effects on attachment.
Automatically joins the primary user as the host player. Gets the primary controller from the platform, uses the player name from options, and directly calls the join game request for immediate hosting.
Changes a player's hero type mid-game. Creates a new hero of the specified type at the current position, transfers ownership, and destroys the old hero. Handles special cases for vehicles and maintains game state consistency.
Parameters:
- int playerNum: The player number to change heroes for.
- HeroType newHeroType: The new hero type to switch to.
Resets ammunition tracking for all players to -1. Called during game state transitions to clear previous ammo counts before respawning or starting new rounds.
Removes a player from the game by their PID. Searches through all player slots to find the matching PID and calls DropoutRPC to remove them.
Parameters:
- PID pid: The PID of the player to deregister.
Detaches a hero from a helicopter and restores normal functionality. Re-enables physics, unparents from helicopter, and allows the hero to resume normal gameplay. Updates the player's helicopter status accordingly.
Parameters:
- TestVanDammeAnim hero: The hero character to detach from the helicopter.
Main dropout logic for removing a player from the game. Handles pause menu cleanup if the player was pausing, and optionally sends an RPC to notify all other players of the dropout.
Parameters:
- int playerNum: The player number to drop out.
- bool sendRPC: Whether to send network notification of the dropout.
RPC method that performs the actual player removal. Destroys the player's GameObject, resets controller colors for local players, clears all player data, removes from death order, and marks local players as dropped out.
Parameters:
- int playerNum: The player number to remove from the game.
Finds and highlights the next spawn door for a player in Suicide Horde mode. Randomly selects from available mook doors that are visible and not destroyed, ensuring no duplicate assignments. Flashes the door with the player's color.
Parameters:
- int playerNum: The player number to find a spawn door for.
Flags a player for removal during the next update cycle. Adds the player number to a pending drop list, preventing duplicate entries. Used for deferred player removal to avoid mid-frame state issues.
Parameters:
- int playerNum: The player number to flag for dropping.
Triggers a visual flash effect on the special ammunition display in the player's HUD. Used to draw attention to ammo changes or special events.
Parameters:
- int playerNum: The player number whose ammo display should flash.
Gets the current hero type for a specific player. Returns None if the player doesn't exist or has no hero type assigned.
Parameters:
- int playerNum: The player number to get hero type for.
Returns:
-
HeroType
: The current HeroType or HeroType.None if not found.
Generates a default player name based on the player ID. Returns names in the format "P1", "P2", etc. for players who haven't set custom names.
Parameters:
- int playerID: The zero-based index of the player.
Returns:
-
string
: A default name string like "P1" for player 0.
Detects if any controller is pressing the join game button (fire key). Excludes input from the DaisyWheel controller to prevent menu conflicts. Updates the controllerNum reference with the pressing controller's ID.
Parameters:
- out int controllerNum: Output parameter that receives the controller number pressing fire.
Returns:
-
bool
: True if a valid controller pressed the join button; otherwise, false.
Gets the color associated with a specific player number. Returns predefined colors for players 0-3 with additional colors available. Uses a switch with offset to provide unique colors for each player slot. Colors: Blue, Red, Orange, Purple.
Parameters:
- int playerNum: The player number to get color for (0-3).
Returns:
-
Color
: The Color associated with the player number.
Gets the localized color name for a specific player number. Returns translated strings for "Blue", "Red", "Orange", and "Purple" based on player index. Falls back to "WHITE" for invalid player numbers.
Parameters:
- string playerNum: The player number to get color name for.
Returns:
-
string
: The localized color name string.
Converts a HeroType enum value to its display name string. Provides proper formatting and spacing for hero names like "B.A. Broracus", "Bro Hard", etc. Falls back to the enum's ToString() for unhandled types.
Parameters:
- HeroType type: The HeroType to get the display name for.
Returns:
-
string
: The formatted display name of the hero.
Retrieves the prefab for a specific hero type from the theme's hero collection. Returns the TestVanDammeAnim prefab that can be instantiated to create the hero character.
Parameters:
- HeroType heroType: The hero type to get the prefab for.
Returns:
-
TestVanDammeAnim
: The hero prefab or null if not found.
public static HeroType GetHeroType(int playerNum, List<HeroType> unlockedBros, List<HeroType> yetToBeSeenUnlockedHereos, bool ignoreYetToBeSeenHeroes)
Determines the next hero type for a player based on game mode and availability. Handles forced hero mode, random selection, elimination mode cycling, and yet-to-be-seen hero prioritization. Complex logic for fair hero distribution.
Parameters:
- int playerNum: The player requesting a hero.
- System.Collections.Generic.List{HeroType} unlockedBros: List of all unlocked hero types.
- System.Collections.Generic.List{HeroType} yetToBeSeenUnlockedHereos: Heroes unlocked but not yet played.
- bool ignoreYetToBeSeenHeroes: Whether to skip unseen hero prioritization.
Returns:
-
HeroType
: The selected HeroType for the player.
Gets the last recorded special ammunition count for a player. Returns the stored value or 0 if no ammo count was previously recorded.
Parameters:
- int playerNum: The player number to get ammo for.
Returns:
-
int
: The last special ammo count or 0 if none recorded.
Finds and returns the hero character that is positioned furthest to the right. Only considers alive heroes and compares their X positions to find the rightmost one.
Returns:
-
TestVanDammeAnim
: The TestVanDammeAnim hero furthest right, or null if none alive.
Finds the first available player slot that is not currently in use. Scans through all four slots and returns the index of the first one where playersPlaying is false. Used when adding new players to find where to place them.
Returns:
-
int
: The first available player slot (0-3) or -1 if all slots are full.
Finds the Nth available player slot that is not currently occupied. Scans through all four player slots and counts empty slots until reaching the requested index. Used for assigning new players to available positions.
Parameters:
- int n: The zero-based index of the available slot to find.
Returns:
-
int
: Player slot number (0-3) or -1 if not enough slots available.
Gets the player number of the Nth local player who is actively playing. Counts only local players (IsMine) who have joined the game. Used for split-screen and local co-op player management.
Parameters:
- int n: The zero-based index of the local player to find.
Returns:
-
int
: Player number (0-3) of the Nth local player or -1 if not found.
Maps a controller ID to its corresponding network Player ID (PID). Used to identify which network player corresponds to a given local controller input for proper multiplayer synchronization.
Parameters:
- int controlID: The local controller ID to map.
Returns:
-
PID
: The PID enum value for the controller, or PID.NoID if not found.
Retrieves the name of a specific player. Returns either the custom name set via SetPlayerName or the default name if none was set.
Parameters:
- int index: The player index to get the name for.
Returns:
-
string
: The player's name string.
Gets the player number associated with a specific controller ID. Only checks local players (IsMine) and returns -1 if the controller is not assigned to any player. Used for mapping controller input to the correct player.
Parameters:
- int controllerID: The controller ID to look up.
Returns:
-
int
: Player number (0-3) or -1 if not found.
Finds the Player instance that is using a specific controller ID. Only returns local players (IsMine) that match the controller number. Used for mapping controller input to the correct player object.
Parameters:
- int controllerID: The controller ID to search for.
Returns:
-
Player
: The Player using the controller or null if not found.
Gets the appropriate special ammunition count for a player, choosing between the current count and the last recorded count based on which is higher. Used to maintain ammo across respawns.
Parameters:
- int playerNum: The player number to get ammo for.
- int currentSpecialAmmo: The current special ammo count.
Returns:
-
int
: The maximum of current and last recorded ammo counts.
Gives one life to all players who are currently at zero lives. Loops through all playing players and grants a life to those who have no lives remaining, preventing complete elimination from the game.
Checks whether all active players have had their hero characters instantiated. Used as a readiness check before starting gameplay to ensure all players have spawned characters in the scene.
Returns:
-
bool
: True if all playing players have character instances; otherwise, false.
Checks if a controller ID is already registered to a specific network player ID. Prevents the same controller-PID combination from joining multiple times, ensuring each network player has only one slot.
Parameters:
- int controlId: The controller ID to check.
- PID pid: The player network ID to check against.
Returns:
-
bool
: True if this controller-PID combination is already registered; otherwise, false.
Checks if a controller ID is already assigned to an active player. Used internally to prevent duplicate controller assignments when players join the game.
Parameters:
- int controllerID: The controller ID to check.
Returns:
-
bool
: True if the controller is already in use; otherwise, false.
Checks if the player using a specific controller is active and alive with lives remaining. More comprehensive than just checking if the controller is in use, this ensures the player can actually participate in gameplay.
Parameters:
- int controllerID: The controller ID to check.
Returns:
-
bool
: True if the player is active, alive, and has lives; otherwise, false.
Checks whether a specific player is currently active in the game. Used to determine which player slots are occupied for spawning and input handling.
Parameters:
- int index: The player index to check.
Returns:
-
bool
: True if the player at the given index is playing; otherwise, false.
Checks if a specific hero type is currently being used by any player. Iterates through all playing players to see if any have the specified hero type assigned. Used to prevent duplicate hero selection.
Parameters:
- HeroType typeTocheck: The HeroType to check for usage.
Returns:
-
bool
: True if the hero type is in use; otherwise, false.
Initiates a timeout check for a player who is expected to join. Starts a coroutine that will kick the player if they haven't joined within the timeout period (2 seconds).
Parameters:
- PID playerPid: The PID of the player to monitor for joining.
Coroutine that waits 2 seconds then checks if a player has joined. If the player's PID is not found in the active players list, sends a kick command to remove them from the session.
Parameters:
- PID playerPid: The PID of the player to check and potentially kick.
Returns:
-
IEnumerator
: IEnumerator for coroutine execution.
Monitors a potential player slot for controller input to join the game. Checks for fire button press from a logged-in controller and initiates the join process if valid input is detected.
Parameters:
- int playernum: The player slot number to monitor for drop-in.
Checks if a player exists and has valid data at the specified player number. Verifies both that the player object is not null and that it reports existing through its Exists() method.
Parameters:
- int playerNum: The player number to check.
Returns:
-
bool
: True if the player exists with valid data; otherwise, false.
private void RecieveHeroTypeFromMaster(HeroType nextHeroTypeRecieved, int playerNum, HeroType[] updatedHeroAlreadyChosenTypes, Ack ackResponse)
Client-side RPC that receives the hero type assignment from the master. Updates the local hero type, synchronizes the already-chosen heroes list, and triggers the spawn process for the assigned hero.
Parameters:
- HeroType nextHeroTypeRecieved: The hero type assigned by the master.
- int playerNum: The player number receiving the assignment.
- HeroType[] updatedHeroAlreadyChosenTypes: Updated list of heroes already chosen.
- Ack ackResponse: Network acknowledgment response.
public static void RegisterHeroToPlayer(TestVanDammeAnim hero, int playerNum, HeroType heroTypeEnum)
Registers a spawned hero character to a specific player slot. Links the hero instance to the player data, activates the HUD, sets the hero type, and handles rescue bro visibility. Core method for establishing the player-hero connection.
Parameters:
- TestVanDammeAnim hero: The TestVanDammeAnim hero instance to register.
- int playerNum: The player number to register the hero to.
- HeroType heroTypeEnum: The type of hero being registered.
RPC method that sends complete player data to a specific network target. Broadcasts all player slots' information including playing status, lives (optionally), and special ammo counts. Used when players join to synchronize game state.
Parameters:
- PID targetId: The network PID to send the data to.
- bool requestLives: Whether to include life counts in the synchronization.
Client-side method to request a hero type assignment from the master/host. Sends available hero types and preferences to the master who will assign an appropriate hero based on game rules and availability.
Parameters:
- int PlayerNum: The player number requesting a hero.
- bool ignoreYetToBeSeenHeroes: Whether to ignore heroes the player hasn't unlocked yet.
private void RequestHeroTypeFromMasterRPC(PID Requestee, int PlayerNum, HeroType[] unlockedTypes, HeroType preferedNextHero, HeroType[] yetToBeSeenUnlockedHereos, Ack ackRequest, bool ignoreYetToBeSeenHeroes)
Server-side RPC that processes hero type requests from clients. Determines the appropriate hero based on game mode, availability, and player preferences, then sends the assignment back to the requesting client.
Parameters:
- PID Requestee: The PID of the requesting player.
- int PlayerNum: The player slot number.
- HeroType[] unlockedTypes: Array of heroes the player has unlocked.
- HeroType preferedNextHero: The player's preferred hero choice.
- HeroType[] yetToBeSeenUnlockedHereos: Heroes unlocked but not yet seen by player.
- Ack ackRequest: Network acknowledgment request.
- bool ignoreYetToBeSeenHeroes: Whether to skip unseen heroes.
Processes a request to join the game from a client. Host-only method that validates the request, assigns an available player slot, broadcasts the addition to all players, and requests player data synchronization. Prevents duplicate joins and handles full games.
Parameters:
- int controllerNum: The controller number of the joining player.
- PID requesteeID: The network PID of the requesting player.
- string playerName: The display name of the joining player.
Shows the start bubble animation for all living heroes. Creates visual feedback at level start or after checkpoints to indicate player positions and readiness.
Makes all living heroes immune to out-of-bounds death. Prevents heroes from dying when they go outside level boundaries, used during transitions or special sequences.
Sets all living heroes to invulnerable state for the specified duration. Loops through all player slots and applies invulnerability to each active character. Used for level transitions or special events.
Parameters:
- float duration: Duration in seconds for the invulnerability effect.
Updates a player's playing status. Synchronizes with the platform controller, updates network room information, and manages player state. Handles both joining and leaving players with proper platform integration.
Parameters:
- int index: The player index to update.
- bool isPlaying: True if the player is joining; false if leaving.
Sets the number of lives for one or all players. Can target a specific player or set lives for all players when playerNum is -1. Updates both the lives count and any powerups that track lives.
Parameters:
- int playerNum: The player to set lives for, or -1 for all players.
- int livesCount: The number of lives to set.
Sets the original special ammunition count displayed in the HUD. Updates the player HUD's tracking of the base ammo count for display purposes, separate from the actual current ammo.
Parameters:
- int playerNum: The player number to update HUD for.
- int count: The original ammo count to display.
Assigns a character instance to a specific player slot. Links the spawned TestVanDammeAnim character to the player's data for tracking and control.
Parameters:
- int index: The player index to assign the character to.
- TestVanDammeAnim character: The TestVanDammeAnim character instance to assign.
Sets a custom name for a specific player. Overwrites the default "P1" style names with player-chosen or platform-provided names.
Parameters:
- int index: The player index to set the name for.
- string pName: The custom name to assign to the player.
Sets the special ammunition count for a specific player. Updates the ammo tracking array if the count is non-negative, used for restoring ammo counts after respawn or power-ups.
Parameters:
- int playerNum: The player number to set ammo for.
- int specialAmmo: The special ammo count to set.
Spawns hero characters for all joined players who haven't been spawned yet. Handles different game modes (BroDown, SuicideHorde, etc.) with appropriate spawn behavior. Uses RPC calls to synchronize player addition across the network.
Spawns a player in Suicide Horde mode. Calls the player's RespawnBro method without checkpoint and clears any associated spawn door reference. Used specifically for the Suicide Horde game mode's unique spawning system.
Parameters:
- int playerNum: The player number to spawn as suicide bro.
private static void UpdatePlayerData(int index, bool isPlaying, PID pid, string playerName, int controller)
RPC method that updates all player data for a specific slot. Synchronizes player information across the network including playing status, network ID, name, and controller assignment. Core method for keeping player data consistent.
Parameters:
- int index: The player slot index to update.
- bool isPlaying: Whether the player is actively playing.
- PID pid: The network player ID.
- string playerName: The player's display name.
- int controller: The controller ID assigned to this player.
Updates a player's controller and name information and broadcasts the change to other players. Also updates the primary user ID for single-player scenarios. Used when players change controllers or update their names mid-game.
Parameters:
- int playerNum: The player number to update.
- int controllerNum: The new controller ID.
- string playerName: The new player name.
Tracks current special ammunition counts for each player. Initialized to -1 to indicate no ammo data. Used for maintaining ammo state across respawns and for HUD display. Array indexed by player number.
Specifies which player number the bot brain should follow. When using AI control, bots will follow and assist the specified player. Initialized to -1 (no leader) for each slot.
Stores the last known special ammunition count for each player. Used to restore ammo after respawn or to track ammo changes. Helps maintain ammo persistence across death/respawn cycles.
Network Player IDs for each player slot. Maps local player indices to network identities for multiplayer synchronization. Initialized to NoID and updated when players join. Critical for network communication.
Maps player slots to physical controller IDs. Tracks which gamepad or input device controls each player. Initialized to -1 (no controller) and updated when players join with their controller ID.
Stores display names for each player slot. Can be custom names from platform profiles or default names like "P1". Initialized as empty strings and updated when players join or change names.
Private array tracking which player slots are actively in the game. True indicates the slot is occupied by a joined player, false means empty. Core state for player management.
Tracks whether each player slot is using AI bot brain control. When true, the player is controlled by AI instead of human input. Used for bot players in single player or when players disconnect.
Checks if all player heroes are currently dead. Used to determine game over conditions or trigger respawn sequences when no players remain alive.
Returns:
-
bool
: True if no players are alive; otherwise, false.
Checks if all heroes except the specified player are dead. Note: Current implementation has a bug and always returns false due to misplaced return statement. Intended to check if only one player remains alive.
Parameters:
- int playerNum: The player number to exclude from the death check.
Returns:
-
bool
: Always returns false due to implementation bug.
Checks if any playing player has at least one life remaining. Used to determine if the game should continue or trigger game over. Returns true as long as any player can still respawn.
Returns:
-
bool
: True if at least one player has lives remaining; otherwise, false.
Finds the first player who has a living hero character. Scans through all player slots in order and returns the index of the first one with an alive character. Defaults to 0 if no living heroes found.
Returns:
-
int
: The player number of the first living hero, or 0 if none alive.
Gets the position of the first living player other than the specified one. Used for finding ally positions for AI or camera logic. Falls back to checkpoint position if no other living players exist.
Parameters:
- int ignorePlayerNum: The player number to exclude from the search.
Returns:
-
Vector2
: Vector2 position of the first other living player or checkpoint position.
Gets the count of local players (non-network players) in the game. Checks the IsMine property of each player's PID to identify local vs remote players. Used for split-screen and local co-op scenarios.
Returns:
-
int
: The number of local players (0-4).
Gets the number of lives remaining for a specific player. Returns 0 if the player doesn't exist or isn't playing.
Parameters:
- int playerNum: The player number to get lives for.
Returns:
-
int
: The number of lives remaining for the player.
Counts the number of players who are currently alive. Checks each playing player to see if they have a character instance that is alive. Used for gameplay logic that depends on active player count.
Returns:
-
int
: The number of players with living characters.
Counts players who are both alive and currently on the extraction helicopter. Used for level completion checks to ensure all players have reached the extraction point before ending the level.
Returns:
-
int
: The number of living players on the helicopter.
Gets the total number of players currently marked as playing. Counts all players with isPlaying flag set to true, regardless of whether they are alive or have spawned characters.
Returns:
-
int
: The count of players currently in the game.
Calculates the total remaining lives across all playing players. Sums up the Lives count for each active player to determine overall lives pool for game over conditions.
Returns:
-
int
: The total number of lives remaining for all players.
Checks if the game has just started by testing if input is still delayed. Returns true during the initial game startup period before player input is enabled, used to prevent premature actions.
Returns:
-
bool
: True if the game just started and input is delayed; otherwise, false.
Checks if all players have completed spawning and are no longer in first deployment state. Game mode aware, checking only the expected number of players for BroDown or SuicideHorde modes.
Returns:
-
bool
: True if all expected players have spawned; otherwise, false.
Checks if all players who are supposed to be playing have joined the game. Considers different game modes (BroDown, SuicideHorde) to determine expected player count. Sets AllPlayersHaveJoined field when all expected players join.
Returns:
-
bool
: True if all expected players have joined; otherwise, false.
Checks if any playing hero is currently dead. Only considers players who are actively playing, ignoring empty slots. Used for respawn timing logic.
Returns:
-
bool
: True if any playing player is dead; otherwise, false.
Checks if any active player is currently dead. Only considers players who are marked as playing, ignoring empty slots. Used for game logic that triggers when at least one player needs respawning.
Returns:
-
bool
: True if any playing player is dead; otherwise, false.
Protected method that checks if a specific player is dead. Returns true if the player exists but has no living character instance, indicating they are awaiting respawn.
Parameters:
- int playerNum: The player number to check death status for.
Returns:
-
bool
: True if the player is dead; otherwise, false.
Checks if a specific player slot is active and playing. Simple accessor for the player's isPlaying flag without additional validation.
Parameters:
- int playerNum: The player number to check.
Returns:
-
bool
: True if the player is marked as playing; otherwise, false.
Counts the total number of players currently in the game. Includes both local and remote players who have joined but may not necessarily be alive. Used for game logic that depends on participant count.
Returns:
-
int
: The total number of players marked as playing (0-4).
Counts only local players on this machine. Checks each player's PID to determine if they belong to the local client. Used for split-screen management and local input handling.
Returns:
-
int
: The number of local players (0-4).
Checks if a specific player has any lives remaining. Used to determine if a player can still respawn after death.
Parameters:
- int playerNum: The player number to check.
Returns:
-
bool
: True if the player has at least one life; otherwise, false.
Public entry point for handling player death. Manages the complete death process including life deduction, death order tracking, game over checks, avatar updates, and network synchronization through RPC calls.
Parameters:
- int playerNum: The player number who died.
RPC method that notifies all clients when a player dies. Updates death tracking, manages lives, handles game over conditions, and coordinates the death state across the network. Only processes on non-host clients.
Parameters:
- int playerNum: The player number who died.
Simple check to determine if a player is currently alive. Verifies the player is playing and has a living character instance in the game world.
Parameters:
- int playerNum: The player number to check.
Returns:
-
bool
: True if the player has a living character; otherwise, false.
Checks if a player is currently in the process of being rescued or respawned. Used to prevent interference with ongoing rescue operations and to track player state during transitions.
Parameters:
- int playerNum: The player number to check.
Returns:
-
bool
: True if the player is being rescued or respawned; otherwise, false.
Checks if a specific player is currently invulnerable. Returns true only if the player is alive and their character's invulnerable property is set.
Parameters:
- int playerNum: The player number to check.
Returns:
-
bool
: True if the player is alive and invulnerable; otherwise, false.
Checks if a player exists and is not currently in stealth mode. Used by AI and detection systems to determine if a player should be visible to enemies.
Parameters:
- int playerNum: The player number to check.
Returns:
-
bool
: True if the player exists and is not stealthed; otherwise, false.
Checks if a specific player is currently on the extraction helicopter. Used for level completion checks to ensure all players have reached extraction.
Parameters:
- int playerNum: The player number to check.
Returns:
-
bool
: True if the player is alive and on the helicopter; otherwise, false.
Resets all player states to not playing. Clears the isPlaying flag for all four player slots, used when returning to menus or resetting the game session.
Updates the local death order array to match the authoritative version from the host. Ensures all clients maintain consistent death ordering for respawn priority and other death-related mechanics.
Parameters:
- int[] latestDeathOrder: The authoritative death order array from the host.
public static bool CanSeePlayer(float x, float y, float xRange, float yRange, ref int seenPlayerNum)
Performs a line of sight check for players in a specific direction. Uses raycasting to ensure no obstacles block the view. Checks both players and their owned units (like SnakeBroskin's grenade hologram).
Parameters:
- float x: X coordinate to check from.
- float y: Y coordinate to check from.
- int xDirection: Direction to check (-1 for left, 1 for right).
- float xRange: Maximum horizontal distance for line of sight.
- float yRange: Maximum vertical distance for line of sight.
- out int seenPlayerNum: Output parameter for the player number if seen.
Returns:
-
bool
: True if a player is visible in the specified direction; otherwise, false.
public static bool CanSeePlayer(float x, float y, float xRange, float yRange, ref int seenPlayerNum)
Line of sight check with both X and Y direction constraints. Most restrictive visibility check that requires the target to be in the correct quadrant and have an unobstructed line of sight.
Parameters:
- float x: X coordinate to check from.
- float y: Y coordinate to check from.
- int xDirection: Horizontal direction (-1 for left, 1 for right).
- int yDirection: Vertical direction (-1 for down, 1 for up).
- float xRange: Maximum horizontal distance for line of sight.
- float yRange: Maximum vertical distance for line of sight.
- out int seenPlayerNum: Output parameter for the player number if seen.
Returns:
-
bool
: True if a player is visible in the specified quadrant; otherwise, false.
public static bool CanSeePlayer(float x, float y, float xRange, float yRange, ref int seenPlayerNum)
Checks if a specific player is visible from a given position. Uses raycasting to verify line of sight is not blocked by terrain or obstacles. Considers stealth mode
- returns false if the player is in stealth.
Parameters:
- int lookForPlayerNum: The specific player number to look for.
- float x: X coordinate to check from.
- float y: Y coordinate to check from.
Returns:
-
bool
: True if the specified player is visible and not in stealth; otherwise, false.
public static bool CanSeePlayer(float x, float y, float xRange, float yRange, ref int seenPlayerNum)
Omnidirectional line of sight check for any player within range. Checks all living players and their units for visibility without direction constraints. Respects stealth mode and uses raycasting for obstacle detection.
Parameters:
- float x: X coordinate to check from.
- float y: Y coordinate to check from.
- float xRange: Maximum horizontal distance for line of sight.
- float yRange: Maximum vertical distance for line of sight.
- out int seenPlayerNum: Output parameter for the nearest visible player number.
Returns:
-
bool
: True if any player is visible within range; otherwise, false.
Finds the truly nearest player using combined X and Y distance. More accurate than GetNearestPlayer for finding the closest player as it uses actual distance rather than treating X and Y separately.
Parameters:
- float x: X coordinate to search from.
- float y: Y coordinate to search from.
- float xRange: Maximum horizontal distance to search.
- float yRange: Maximum vertical distance to search.
Returns:
-
int
: Player index (0-3) of nearest player or -1 if none in range.
public static bool GetNearestPlayer(float x, float y, float xRange, float yRange, ref int currentNearest)
Finds the nearest player within a specified rectangular range. Returns the player index of the closest player within the range or -1 if no players are found. Uses Manhattan distance for range checking.
Parameters:
- float x: X coordinate to search from.
- float y: Y coordinate to search from.
- float xRange: Maximum horizontal distance to search.
- float yRange: Maximum vertical distance to search.
Returns:
-
bool
: Player index (0-3) of nearest player or -1 if none in range.
public static bool GetNearestPlayer(float x, float y, float xRange, float yRange, ref int currentNearest)
Finds the nearest player within range and updates the current nearest reference. Returns true if a closer player was found than the current nearest. Used for iterative searches to find the closest among multiple candidates.
Parameters:
- float x: X coordinate to search from.
- float y: Y coordinate to search from.
- float xRange: Maximum horizontal distance to search.
- float yRange: Maximum vertical distance to search.
- out int currentNearest: Reference to current nearest player, updated if closer found.
Returns:
-
bool
: True if a closer player was found; otherwise, false.
Finds the position of the nearest living player to the specified coordinates. Returns the player's position as a Vector3 or a far-away position (1000, 1000, 0) if no players are alive.
Parameters:
- float x: X coordinate to search from.
- float y: Y coordinate to search from.
Returns:
-
Vector3
: Vector3 position of the nearest player or (1000, 1000, 0) if none found.
Finds the position of the nearest living player and returns their player number. Uses squared distance for efficiency and updates the playerNum reference with the nearest player's index.
Parameters:
- float x: X coordinate to search from.
- float y: Y coordinate to search from.
- out int playerNum: Output parameter for the nearest player's number.
Returns:
-
Vector3
: Vector3 position of the nearest player or (1000, 1000, 0) if none found.
Gets the position of a specific player through reference parameters. If the player doesn't exist or isn't alive, returns (-1000, -1000) as an invalid position marker.
Parameters:
- int playerNum: The player number to get position for.
- out float xPos: Output parameter that receives the player's X position.
- out float yPos: Output parameter that receives the player's Y position.
Gets the position of a specific player as a Vector3. Returns the player's current position or (-1000, -1000, 0) if the player doesn't exist or isn't alive.
Parameters:
- int playerNum: The player number to get position for.
Returns:
-
Vector3
: Vector3 position of the player or (-1000, -1000, 0) if invalid.
Gets the position of a specific player as a Vector3. Returns the player's current world position or Vector3.zero if the player doesn't exist or has no character instance.
Parameters:
- int playerNum: The player number to get position for.
Returns:
-
Vector3
: Vector3 position of the player or Vector3.zero if invalid.
Gets the Transform component of a specific player's character. Returns null if the player doesn't exist, isn't playing, or has no character instance.
Parameters:
- int playerNum: The player number to get the transform for.
Returns:
-
Transform
: The player's character Transform or null if unavailable.
Gets the player number of a random living player. Useful for AI that needs to target a random player rather than the nearest one. Returns -1 if no players are alive.
Returns:
-
int
: Player number (0-3) of a random living player or -1 if none.
Gets the position of a random living player through reference parameters. Randomly selects from all alive players and returns their position and player number. Returns false if no players are alive.
Parameters:
- out float xPos: Output parameter for the selected player's X position.
- out float yPos: Output parameter for the selected player's Y position.
- out int playerNum: Output parameter for the selected player's number.
Returns:
-
Vector3
: True if a living player was found; otherwise, false.
Gets the position of a random living player as a Vector3. Returns a far-away position (1000, 1000, 0) if no players are alive. Used for AI targeting when any player target is acceptable.
Returns:
-
Vector3
: Vector3 position of a random living player or (1000, 1000, 0) if none.
public static bool IsAnotherPlayerNearby(int currentPlayerNum, float x, float y, float xRange, float yRange)
Checks if any player other than the specified player is within range. Used for co-op mechanics, friendly fire detection, and ensuring players don't interact with their own detection zones.
Parameters:
- int currentPlayerNum: Player number to exclude from the search.
- float x: X coordinate to search from.
- float y: Y coordinate to search from.
- float xRange: Maximum horizontal distance to search.
- float yRange: Maximum vertical distance to search.
Returns:
-
bool
: True if another player is found within range; otherwise, false.
public static bool IsPlayerNearby(int playerNum, float x, float y, ref float xRange, float yRange, ref float targetX, ref float targetY)
Checks if any player is within the specified range and returns their position. Updates reference parameters with the nearest player's coordinates and player number. Used for AI targeting and interaction systems.
Parameters:
- float x: X coordinate to check from.
- float y: Y coordinate to check from.
- float xRange: Horizontal detection range.
- float yRange: Vertical detection range.
- out float playerX: Output parameter for found player's X position.
- out float playerY: Output parameter for found player's Y position.
- out int seenPlayer: Output parameter for found player's number.
Returns:
-
bool
: True if a player is found within range; otherwise, false.
public static bool IsPlayerNearby(int playerNum, float x, float y, ref float xRange, float yRange, ref float targetX, ref float targetY)
Directional player detection that checks for players in a specific direction. Only detects players in the direction specified by xDirection parameter and returns their position and player number through reference parameters.
Parameters:
- float x: X coordinate to check from.
- float y: Y coordinate to check from.
- int xDirection: Direction to check (-1 for left, 1 for right).
- float xRange: Horizontal detection range in the specified direction.
- float yRange: Vertical detection range.
- out float playerX: Output parameter for found player's X position.
- out float playerY: Output parameter for found player's Y position.
- out int seenPlayerNum: Output parameter for found player's number.
Returns:
-
bool
: True if a player is found in the specified direction; otherwise, false.
public static bool IsPlayerNearby(int playerNum, float x, float y, ref float xRange, float yRange, ref float targetX, ref float targetY)
Basic proximity check to determine if any player is within the specified rectangular range. Simple boolean check without returning player information.
Parameters:
- float x: X coordinate to check from.
- float y: Y coordinate to check from.
- float xRange: Horizontal detection range.
- float yRange: Vertical detection range.
Returns:
-
bool
: True if any player is within range; otherwise, false.
public static bool IsPlayerNearby(int playerNum, float x, float y, ref float xRange, float yRange, ref float targetX, ref float targetY)
Directional proximity check that only detects players in the specified direction. Used for directional attacks, line of sight checks, and facing-dependent interactions.
Parameters:
- float x: X coordinate to check from.
- float y: Y coordinate to check from.
- int xDirection: Direction to check (-1 for left, 1 for right).
- float xRange: Horizontal detection range in the specified direction.
- float yRange: Vertical detection range.
Returns:
-
bool
: True if a player is found in the specified direction; otherwise, false.
public static bool IsPlayerNearby(int playerNum, float x, float y, ref float xRange, float yRange, ref float targetX, ref float targetY)
Directional player detection that finds players in a specific direction and returns their player number. Only detects players whose position relative to the check point matches the specified direction.
Parameters:
- float x: X coordinate to check from.
- float y: Y coordinate to check from.
- int xDirection: Direction to check (-1 for left, 1 for right).
- float xRange: Horizontal detection range in the specified direction.
- float yRange: Vertical detection range.
- out int seenPlayerNum: Output parameter for found player's number.
Returns:
-
bool
: True if a player is found in the specified direction; otherwise, false.
public static bool IsPlayerNearby(int playerNum, float x, float y, ref float xRange, float yRange, ref float targetX, ref float targetY)
Checks if a specific player is nearby in a given direction and returns their position. Updates the xRange parameter and target position references if the player is found within the directional constraints.
Parameters:
- int playerNum: The specific player number to check for.
- float x: X coordinate to check from.
- float y: Y coordinate to check from.
- int xDirection: Direction to check (-1 for left, 1 for right).
- out float xRange: Reference to horizontal range, updated based on player distance.
- float yRange: Vertical detection range.
- out float targetX: Output parameter for the player's X position if found.
- out float targetY: Output parameter for the player's Y position if found.
Returns:
-
bool
: True if the specified player is found in range and direction; otherwise, false.
public static bool IsPlayerNearby(int playerNum, float x, float y, ref float xRange, float yRange, ref float targetX, ref float targetY)
Checks if a specific player is nearby with both X and Y direction constraints. Most restrictive proximity check that requires the player to be in the correct quadrant relative to the check position.
Parameters:
- int playerNum: The specific player number to check for.
- float x: X coordinate to check from.
- float y: Y coordinate to check from.
- int xDirection: Horizontal direction (-1 for left, 1 for right).
- int yDirection: Vertical direction (-1 for down, 1 for up).
- out float xRange: Reference to horizontal range, updated based on player distance.
- float yRange: Vertical detection range.
- out float targetX: Output parameter for the player's X position if found.
- out float targetY: Output parameter for the player's Y position if found.
Returns:
-
bool
: True if the player is found in the specified quadrant; otherwise, false.
public static bool IsPlayerNearby(int playerNum, float x, float y, ref float xRange, float yRange, ref float targetX, ref float targetY)
Checks if a specific player is within range without direction constraints. Updates the xRange parameter and returns the player's position through reference parameters if found.
Parameters:
- int playerNum: The specific player number to check for.
- float x: X coordinate to check from.
- float y: Y coordinate to check from.
- out float xRange: Reference to horizontal range, updated based on player distance.
- float yRange: Vertical detection range.
- out float targetX: Output parameter for the player's X position if found.
- out float targetY: Output parameter for the player's Y position if found.
Returns:
-
bool
: True if the specified player is within range; otherwise, false.
Checks if a specific player is positioned in the given direction from a point. Used for directional AI decisions and determining relative player positions.
Parameters:
- int playerNum: The player number to check.
- float x: X coordinate to check from.
- float y: Y coordinate to check from.
- int xDirection: Direction to check (-1 for left, 1 for right).
Returns:
-
bool
: True if the player is in the specified direction; otherwise, false.
Checks if any player is positioned in the given direction from a point. Searches all playing players to find if any are in the specified direction. Used for AI directional awareness without caring which specific player.
Parameters:
- float x: X coordinate to check from.
- float y: Y coordinate to check from.
- int xDirection: Direction to check (-1 for left, 1 for right).
Returns:
-
bool
: True if any player is in the specified direction; otherwise, false.
Checks if any player is in the given direction and returns the nearest one. Finds the closest player in the specified direction based on absolute X distance and updates the seenPlayerNum reference with their index.
Parameters:
- float x: X coordinate to check from.
- float y: Y coordinate to check from.
- int xDirection: Direction to check (-1 for left, 1 for right).
- out int seenPlayerNum: Output parameter for the nearest player's number in that direction.
Returns:
-
bool
: True if a player is found in the direction; otherwise, false.
Layer mask for fragile/destructible terrain detection. Used to identify breakable surfaces that might affect spawn positions or require special handling during physics checks.
Layer mask for ground collision detection. Used in raycasting operations to detect solid ground for spawn position validation, line of sight checks, and movement calculations.
Shared RaycastHit structure for physics queries. Reused across multiple raycast operations to avoid allocation overhead. Stores hit information from the most recent raycast operation.
Checks for rescue bros within range of the specified position and initiates rescue if found. Handles the rescue animation, network RPC calls, and returns whether any rescue was initiated. Only the host processes the actual rescue logic.
Parameters:
- int playerNum: The player number checking for rescues.
- float x: X coordinate to check from.
- float y: Y coordinate to check from.
- float range: Range to check for rescue bros.
Returns:
-
bool
: True if a rescue was initiated; otherwise, false.
RPC method to destroy a rescue bro across all clients. Handles null checks and ensures proper cleanup of the rescue bro game object to prevent orphaned references in multiplayer games.
Parameters:
- RescueBro rescueBro: The RescueBro instance to destroy.
Server-side validation method for rescue attempts. Coordinates rescue operations across the network to ensure only one player can rescue a bro. Handles both character swapping and respawning scenarios based on game state.
Parameters:
- int playerNum: The player number attempting the rescue.
- RescueBro rescueBro: The RescueBro object being rescued.
- Ack ackRequest: Network acknowledgment for the rescue request.
private void RespawnBro(int rescuedPlayer, RescueBro rescueBro, int[] latestDeathOrder, Ack ackResponse)
RPC method that respawns a dead player when their bro is rescued. Updates the death order to maintain consistency across the network and calls the player's RespawnBro method to create their new character at the rescue location.
Parameters:
- int rescuedPlayer: The player number being respawned.
- RescueBro rescueBro: The RescueBro that triggered the respawn.
- int[] latestDeathOrder: Array tracking the order of player deaths.
- Ack ackResponse: Network acknowledgment for the operation.
RPC method that performs character swapping when rescuing a bro while alive. Swaps the current character with the rescued bro type, maintaining the player's position and state. Updates death order tracking for consistency.
Parameters:
- int playerNum: The player number performing the swap.
- RescueBro rescueBro: The RescueBro being swapped to.
- int[] latestDeathOrder: Array tracking the order of player deaths.
- Ack ackResponse: Network acknowledgment for the operation.
Array tracking the assigned spawn door for each player in Suicide Horde mode. Each player gets a specific mook door to spawn from, preventing spawn conflicts and providing visual indicators of where players will appear.
Coroutine that manages the pre-game countdown sequence. Handles different countdown behaviors for various game modes, displays countdown numbers and announcements, manages encouragement messages for struggling players, and triggers game start when countdown completes. Special handling for edit mode, test runs, and DeathMatch.
Returns:
-
IEnumerator
: IEnumerator for coroutine execution.
Calculates the spawn offset for a player at a checkpoint based on their player number. Players 0-1 spawn 8 units apart, players 2-3 spawn 12 units apart, creating a staggered formation to prevent spawn overlapping.
Parameters:
- int playerNum: The player number to get offset for.
Returns:
-
Vector2
: Vector2 offset to apply to the checkpoint position.
Calculates the final spawn position for a player at the current checkpoint. For airdrop spawns, positions the player high above the screen. For ground spawns, applies the player-specific offset to prevent overlapping.
Parameters:
- int playerNum: The player number to get spawn position for.
- bool spawnViaAirDrop: Whether the player should spawn via airdrop from above.
Returns:
-
Vector3
: Vector3 world position where the player should spawn.
Gets the ID of the current checkpoint. Used to track progression through the level and determine respawn locations. Returns -1 if no checkpoint has been activated.
Returns:
-
int
: The current checkpoint ID or -1 if none set.
RPC method that sets the BrosReleased flag to true. Used to synchronize the game start state across all players, indicating that players can begin moving and playing.
Counts the number of remote machines connected to the game session. Iterates through all PIDs checking for non-local connections. Used for network game management and connection tracking.
Returns:
-
int
: The count of connected remote machines.
Sets a delay timer for a specific player, preventing immediate actions after certain events. Uses the configured playerDelayTime from the HeroController instance to set the delay duration.
Parameters:
- int playerNum: The player number to apply the delay to.
public static void RegisterHiddenExplosives(HiddenExplosives hiddenExplosive)
Registers a hidden explosive object for tracking. Creates the hiddenExplosives list if it doesn't exist and adds the explosive to it. Used to manage triggered explosives that are revealed during gameplay.
Parameters:
- HiddenExplosives hiddenExplosive: The HiddenExplosives instance to register.
public static void RemoveHiddenExplosives(HiddenExplosives hiddenExplosive)
Removes a hidden explosive from the tracking list. Called when an explosive is triggered or destroyed to clean up references.
Parameters:
- HiddenExplosives hiddenExplosive: The HiddenExplosives instance to remove.
Server-side RPC handler for checkpoint requests. Broadcasts the checkpoint update to all connected players to ensure everyone has the same checkpoint data. Only processed by the host/server.
Parameters:
- Vector2 checkPointPos: The world position of the checkpoint.
- int checkPointID: The unique ID of the checkpoint.
Resets the game over countdown timer if all players are dead. Checks each player's death state and if all are dead with remaining time, resets the loss timer and stops any active fade effects. Prevents premature game over transitions.
Sets a new checkpoint position and ID. Updates the local checkpoint data and sends an RPC to the server to synchronize the checkpoint across all players. Primary public interface for checkpoint management.
Parameters:
- Vector2 checkPointPos: The world position of the new checkpoint.
- int checkPointID: The unique ID of the checkpoint.
Internal method that actually updates the checkpoint data. Sets the checkpoint start position, ID, and resets the checkPointSet flag. Called via RPC to ensure all clients have synchronized checkpoint data.
Parameters:
- Vector2 checkPointPos: The world position of the checkpoint.
- int checkPointID: The unique ID of the checkpoint.
Gets or sets whether the bros (players) have been released to start playing. When set to true by the host, sends an RPC to notify all other players. Network-aware property that synchronizes game start state across multiplayer sessions.
Returns:
-
bool
: True if bros have been released; otherwise, false.
Gets or sets whether the game countdown has completed. Used to track the pre-game countdown state and determine when players can begin playing.
Returns:
-
bool
: True if the countdown is finished; otherwise, false.
Time in seconds to hold the camera position after the last hero dies. Prevents immediate camera transitions on death, giving players time to see what happened before respawn or game over.
Indicates whether network connection event handlers have been registered. Prevents duplicate registration of OnDisconnect handlers which could cause multiple executions of cleanup code.
Tracks the current index for cycling through join notification messages. Used to display varied messages when players join the game, preventing repetitive notifications.
Private backing field for the isCountdownFinished property. Tracks whether the pre-game countdown sequence has completed. Set to true when players can begin playing after the 3-2-1-GO countdown.
Indicates whether all expected players have joined the game session. Used to delay game start or enable certain features only after everyone is ready. Set by join detection logic.
Private backing field for the BrosReleased property. Indicates whether players have been released to start playing. Synchronized across network to ensure all players start simultaneously.
Indicates whether a checkpoint has been explicitly set this session. Used to differentiate between default spawn positions and player-activated checkpoints for spawn logic.
World position of the current checkpoint spawn location. Default is (128, 196) which represents the typical level start position. Updated when players activate new checkpoints during gameplay.
ID of the currently active checkpoint. Used to track level progression and determine respawn locations. Set to -1 when no checkpoint is active. Static to persist across scene transitions.
Timer for tracking explosive-related events. Used internally for managing timed explosive spawns, detonations, or cooldowns related to explosive game mechanics.
Tracks whether the screen has faded to black. Used during game over sequences, level transitions, or cutscenes to manage visual state and prevent duplicate fade operations.
Timer tracking time since level completion. Increments after level finish to manage post-completion sequences, delays before transitions, and ensure completion animations play fully.
Debug flag that makes all players permanently invulnerable. Used for testing, debugging, or special game modes where players cannot be damaged. Accessed via debug key commands.
Forces all players to spawn as a specific hero type when set. Used for testing, special game modes, or themed levels. Set to HeroType.None for normal hero selection behavior.
Indicates whether heroes have been released from the initial transport sequence. Used to track if the opening helicopter drop or transport animation has completed and players can begin normal gameplay.
Tracks whether the local player has dropped out during the current round. Used to manage rejoin behavior and prevent duplicate dropout processing. Reset at the start of each new round.
Maximum time allowed after all players die before game over. Set to 0.5 seconds by default. Gives a brief window for revival mechanics or last-second saves before triggering the loss condition.
Countdown timer for game over when all players are dead. Starts at 0.5 seconds and counts down to trigger loss condition. Can be reset if players gain lives or special conditions are met.
Stores the next hero type to be spawned. Used for hero selection queueing and ensuring the correct hero spawns after death or level start. Hidden in inspector as it's managed programmatically.
Default delay duration applied to players for various events. Set to 0.5 seconds. Used by PlayerDelay method to create consistent timing for player state transitions.
Array of spawn delays for each player in Suicide Horde mode. Negative values create staggered spawn times: -2, -2.25, -2.5, -2.75 seconds. Prevents all players spawning simultaneously at doors.
When true, delays game start until all joined players have spawned their characters. Ensures synchronized starts in multiplayer. Hidden in inspector as it's typically set programmatically based on game mode.
Coroutine that manages the game start sequence. Waits for all players to spawn, then either announces "GO!" immediately or starts a countdown based on GameModeController settings. Handles different spawn timing for various game modes.
Returns:
-
IEnumerator
: IEnumerator for coroutine execution.
Applies a speed boost to all living player characters for the specified duration. Enhances movement and action speed, typically used for power-ups or special game events that accelerate gameplay.
Parameters:
- float time: Duration in seconds for the hero speed boost.
Immediately cancels any active time manipulation effects from Time Bro. Restores normal time flow by clearing boost timers and resetting time scale if Time Bro effects were active.
Checks if a player is eligible to spawn or respawn. Returns true only if the player exists, has lives remaining, and is currently dead. Used internally by respawn logic to determine spawn eligibility.
Parameters:
- int playerNum: The player number to check spawn eligibility for.
Returns:
-
bool
: True if the player can spawn; otherwise, false.
Returns the game to the main menu. Performs cleanup operations including stopping Steam integration, clearing cutscene state, resetting time scale, and loading the MainMenu scene.
Activates high-five time dilation effect, slowing time to 50% speed for the specified duration. Creates a bullet-time effect that enhances the high-five moment between players.
Parameters:
- float time: Duration in seconds for the time dilation effect.
Checks if any player is near an activated checkpoint and returns the checkpoint data. Updates the position and airdrop flag references if a player is found near a checkpoint. Used for respawn location determination.
Parameters:
- out Vector2 pos: Reference parameter that receives the checkpoint position if found.
- out bool spawnViaAirdrop: Reference parameter that indicates if spawn should be via airdrop.
Returns:
-
bool
: True if a player is near an activated checkpoint; otherwise, false.
Handles network disconnection events. Drops out all local players, displays a disconnection error notification to the user for 5 seconds, and prepares the game state for returning to the menu or reconnecting.
Reduces the respawn delay timer by the specified time. Resets to 0.4 seconds if no heroes are dead, otherwise decrements the timer. Controls the pacing of automatic respawns.
Parameters:
- float t: Time in seconds to reduce from the respawn delay.
Executes complex respawn logic for a player based on game mode. Handles Campaign checkpoint respawns, DeathMatch spawn queue system, and SuicideHorde spawn doors. Checks lives, death status, and spawn conditions before respawning.
Parameters:
- int playerNum: The player number to run respawn logic for.
Sets the synchronized timestamp for when the round should begin. Used in multiplayer to ensure all players start at the same time by setting a future timestamp for coordinated round starts.
Parameters:
- float timestamp: The network time when the round should begin.
Initiates the game countdown sequence. Cancels any delayed announcements and starts the countdown coroutine through the Announcer system. Called to begin the pre-game countdown before releasing players.
Synchronizes the deathmatch respawn queue from the network host. Converts the array to a list for local spawn order management in deathmatch games.
Parameters:
- int[] _deathmatchSpawnQueue: Array of player numbers in spawn order.
Activates Time Bro's time manipulation ability, slowing time to 35% speed for the specified duration. More extreme time dilation than high-five, specific to the Time Bro character's special ability.
Parameters:
- float time: Duration in seconds for the time manipulation effect.
Applies Time Bro's time boost effect to all living heroes for the specified duration. Gives all players enhanced abilities similar to Time Bro's powers, used for special cooperative moments.
Parameters:
- float time: Duration in seconds for the Time Bro boost effect.
Tracks whether all players are currently dead. Used to trigger game over sequences, manage respawn timing, and control camera behavior when no living players remain.
Network timestamp for synchronized round start. Stores the exact time when all players should begin the round, ensuring multiplayer synchronization across different network latencies.
Minimum delay between automatic respawn attempts. Set to 0.4 seconds to prevent respawn spam and ensure death animations complete before new spawn attempts begin.
Delay in seconds before player input is processed after spawning. Set to 0.25 seconds by default. Prevents accidental inputs during spawn animations and ensures players have time to orient themselves.
Tracks whether the current round has officially started. Set to true when the synchronized start time is reached or countdown completes. Controls game flow state transitions.
Indicates whether the round begin timestamp has been set. Prevents multiple timestamp assignments and ensures the round starts at the designated time across all clients.
Timeout duration for waiting for all players to join or spawn. Prevents infinite waiting if a player fails to connect or load. Game proceeds when timeout expires regardless of missing players.
RPC method that adds a temporary follow target for a specific player's camera. Used for cutscenes or special camera focus events where the camera needs to track something other than the player character temporarily.
Parameters:
- int playerNum: The player number whose camera should follow the target.
- Transform target: The transform for the camera to follow.
protected static void AddToExtents(Vector3 pos, ref float minX, ref float maxX, ref float minY, ref float maxY)
Adds a position to the camera view extents calculation. Updates the minimum and maximum X/Y bounds by reference to include the given position. Used internally for calculating camera bounds that encompass all relevant targets.
Parameters:
- Vector3 pos: The position to include in the extents.
- out float minX: Reference to minimum X bound, updated if pos.x is smaller.
- out float maxX: Reference to maximum X bound, updated if pos.x is larger.
- out float minY: Reference to minimum Y bound, updated if pos.y is smaller.
- out float maxY: Reference to maximum Y bound, updated if pos.y is larger.
public static bool CanFollow(Vector3 otherPosition, float minX, float maxX, float minY, float maxY, float requiredBuffer = 24f)
Determines if a position can be followed by the camera while keeping it within screen bounds. Calculates whether including this position would push the camera view beyond acceptable limits with the specified buffer.
Parameters:
- Vector3 otherPosition: The position to check for followability.
- float minX: Current minimum X bound of the camera.
- float maxX: Current maximum X bound of the camera.
- float minY: Current minimum Y bound of the camera.
- float maxY: Current maximum Y bound of the camera.
- float requiredBuffer: Buffer distance from screen edges (default 24).
Returns:
-
bool
: True if the position can be followed within bounds; otherwise, false.
Determines if the camera can look for repositioning opportunities. Returns false if controlled by trigger actions, in ExplosionRun mode, within reposition delay cooldown, or if any player has a temporary camera target. Sets a 0.6 second cooldown when conditions aren't met.
Returns:
-
bool
: True if camera repositioning is allowed; otherwise, false.
Calculates the optimal camera follow position based on all active players, extra targets, and game state. This complex method handles multiple scenarios including death cam, race mode, helicopter sequences, and ensures all important elements stay in view. Updates the position parameter by reference.
Parameters:
- out Vector3 pos: Reference parameter that receives the calculated follow position.
Returns:
-
bool
: True if a valid follow position was calculated; otherwise, false.
RPC method that removes the temporary follow target for a player's camera, returning it to normal player following behavior. Called when special camera events end.
Parameters:
- int playerNum: The player number to remove the temporary target from.
Removes a transform from the extra camera follow positions list. Called when an object no longer needs camera attention, such as when it's destroyed or becomes irrelevant.
Parameters:
- Transform trans: The transform to stop following.
Adds a transform to the list of extra camera follow positions if not already present. Used for dynamic camera targets like important game objects or NPCs that the camera should include in its view calculations.
Parameters:
- Transform trans: The transform to add to camera following.
Player number that the camera should prefer to follow. Set to -1 for no preference. Used to bias camera positioning toward specific players during gameplay or cutscenes.
Stores the last calculated camera follow position. Used for smooth camera interpolation and to track camera movement history. Updated each frame when calculating new follow positions.
Timestamp of the last camera follow target switch. Used to prevent rapid camera target changes and ensure smooth transitions between follow targets.
Timestamp of the last switch back to default camera following. Tracks when the camera returned from following special targets to prevent oscillation between targets.
Cooldown timer for camera repositioning attempts. Prevents rapid camera adjustments by enforcing a minimum delay between reposition checks. Set when repositioning is blocked to create smoother camera behavior.
Time elapsed since level completion. Used for post-level timing, delayed transitions, and ensuring completion sequences play out fully before moving to next level.
Tracks whether the camera was previously following extra targets beyond players. Used to detect state changes in camera following behavior and manage transitions between following players only versus including additional targets.
Disables the HUD display for all players. Loops through all player slots and calls DisableHud on each player instance. Used during cutscenes or special game states where HUD should be hidden.
Enables the HUD display for all players. Loops through all player slots and calls EnableHud on each player instance. Used to restore HUD visibility after cutscenes or special events.
Triggers a flashing effect on the player's avatar for the specified duration. Used to draw attention to status changes, damage, or special events. The avatar will flash for the given time period.
Parameters:
- int playerNum: The player number whose avatar should flash.
- float time: Duration in seconds for the flash effect.
- bool primaryAvatar: True to flash primary avatar; false for secondary.
Retrieves the avatar material associated with a specific hero type. Each hero can have a unique avatar material for special visual effects in the HUD. Returns null if no custom material exists for the hero type.
Parameters:
- HeroType heroType: The hero type to get avatar material for.
Returns:
-
Material
: The avatar Material for the hero type or null if not found.
Returns whether HUDs must be shown based on the global mustShowHUDS flag. Simple accessor for the HUD visibility state used by various game systems.
Returns:
-
bool
: True if HUDs must be shown; otherwise, false.
Sets the player's avatar to the angry expression state. Updates the HUD avatar display to show an aggressive face, typically during combat or special actions. Can target either primary or secondary avatar displays.
Parameters:
- int playerNum: The player number whose avatar to update.
- bool primaryAvatar: True to update primary avatar; false for secondary.
Triggers a downward bounce animation on the player's avatar. Creates a visual feedback effect where the avatar appears to compress or bounce downward, often used for impact or landing effects.
Parameters:
- int playerNum: The player number whose avatar should bounce down.
- bool primaryAvatar: True to bounce primary avatar; false for secondary.
Triggers an upward bounce animation on the player's avatar. Creates a visual feedback effect where the avatar appears to stretch or bounce upward, often used for jump or spring effects.
Parameters:
- int playerNum: The player number whose avatar should bounce up.
- bool primaryAvatar: True to bounce primary avatar; false for secondary.
Sets the player's avatar to the calm expression state. Updates the HUD avatar display to show the normal, non-angry face for the specified player. Can target either primary or secondary avatar displays.
Parameters:
- int playerNum: The player number whose avatar to update.
- bool primaryAvatar: True to update primary avatar; false for secondary.
Sets the player's avatar to the dead state. Updates the HUD to show the death animation or static dead frame, indicating the player has died. Can target either primary or secondary avatar displays.
Parameters:
- int playerNum: The player number whose avatar to mark as dead.
- bool primaryAvatar: True to update primary avatar; false for secondary.
Sets the player's avatar to display fire animation. Shows the avatar with flames, typically used when the player is on fire or using fire-based abilities. Can target either primary or secondary avatar displays.
Parameters:
- int playerNum: The player number whose avatar to set on fire.
- bool primaryAvatar: True to update primary avatar; false for secondary.
Sets a specific frame of the fire animation for the player's avatar. Allows precise control over which frame of the burning animation is displayed, useful for synchronized effects.
Parameters:
- int playerNum: The player number whose avatar fire frame to set.
- int frame: The specific animation frame number to display.
Internal method to set a specific animation frame for the player's avatar. Provides low-level control over avatar animation state for custom effects or specific animation requirements.
Parameters:
- int playerNum: The player number whose avatar frame to set.
- int avatarFrame: The specific frame number to display.
Sets a custom material for the player's avatar display. Allows special visual effects by replacing the avatar's rendering material, such as for power-ups or status effects.
Parameters:
- int playerNum: The player number whose avatar material to change.
- Material material: The Material to apply to the avatar.
Shows all player HUD displays if mustShowHUDS flag is true. Iterates through all players and calls Show() on each HUD component to make health, ammo, and lives visible.
Switches a sprite's material to match the specified hero type's avatar material. Retrieves the appropriate material and applies it to the sprite if available. Returns whether the switch was successful.
Parameters:
- SpriteSM sprite: The SpriteSM to update with new material.
- HeroType heroType: The hero type whose avatar material to use.
Returns:
-
bool
: True if material was found and applied; otherwise, false.
Material used as a placeholder avatar when no hero-specific avatar is available. Displayed in the HUD before a hero is selected or as a fallback for missing avatar materials.
Tracks the current avatar index for Double Bro Seven. Used to cycle through available avatar textures, providing visual variety for this character's HUD representation.
Color used for the info bar display during countdown and announcements. Default is black. Can be customized per level or game mode to match the visual theme.
Global flag controlling HUD visibility. When true, all player HUDs must be shown. Used to force HUD display during gameplay and hide during cutscenes or menus.
Array of avatar textures specifically for the Double Bro Seven character. Supports multiple avatar variations for this unique hero type that can cycle through different appearances.
Deserializes player data received during network join. Unpacks and updates the local arrays for playing status, controller IDs, and PIDs from the received stream data.
Parameters:
- UnityStream stream: The UnityStream containing serialized player data.
Unity deserialization callback that rebuilds the hero data dictionary from the serialized list. Handles duplicate keys by incrementing enum values to ensure data integrity. Part of the ISerializationCallbackReceiver interface.
Unity serialization callback that converts the internal hero data dictionary to a serializable list format. Part of the ISerializationCallbackReceiver interface implementation for saving game state.
Packs the HeroController's network state for synchronization. Includes checkpoint position, bros released status, round timestamps, and checkpoint ID. Overrides base class to add hero-specific state data.
Parameters:
- UnityStream stream: The UnityStream to pack state into.
Returns:
-
UnityStream
: The stream with packed state data.
Serializes essential player data for network join operations. Packs the playing status, controller IDs, and network PIDs into the stream for transmission to joining players.
Parameters:
- UnityStream stream: The UnityStream to serialize data into.
Unpacks network state data to synchronize the HeroController. Restores checkpoint position, bros released status, timestamps, and checkpoint ID from the stream. Ensures proper state synchronization across the network.
Parameters:
- UnityStream stream: The UnityStream containing packed state data.
Returns:
-
UnityStream
: The stream after unpacking.
Comprehensive debug GUI display showing detailed player and game state information. Displays camera positions, player data tables including controllers, PIDs, playing status, hero states, positions, bot brain settings, and following relationships. Includes interactive controls for bot brain configuration during debug sessions.
Finds a suitable remote player for bot brain following behavior. Prioritizes remote players over local ones, returning the first remote player found or the last local player if no remote players exist. Returns -1 if no suitable follow target is found.
Parameters:
- Player player: The player looking for someone to follow.
Returns:
-
int
: The player index to follow or -1 if none found.
Sets which hero type should always be chosen for testing purposes. Overrides normal hero selection to force a specific character for debugging and testing.
Parameters:
- HeroType alwaysChoose: The HeroType to always select during testing.
Processes debug keyboard inputs for development and testing. Handles force invulnerability (F8), force level finish (Ctrl+Shift+F9), HUD toggle (Ctrl+F12), and editor-only commands like speed boost and unlock clearing.
Forces all players to spawn as a specific hero type when set. Used for testing specific heroes or creating themed gameplay experiences. Set to HeroType.None for normal random/sequential hero selection.
Avatar material for the hero in the HeroDefinition. Used for HUD display to show the hero's face/portrait. Each hero has a unique avatar material for visual identification.
Reference to the hero character prefab in the HeroDefinition. Points to the TestVanDammeAnim asset that will be instantiated when this hero type is spawned.
Display name of the hero in the HeroDefinition data structure. Used for UI display, announcements, and hero selection screens. Part of the hero configuration system.
Gets all player numbers associated with a specific player ID. Iterates through all 4 possible player slots and returns a list of player numbers where the PID matches. Used for finding which player slots belong to a specific connected player.
Parameters:
- PID playerID: The player ID to search for.
Returns:
-
List<int>
: List of player numbers (0-3) that match the given player ID.
Static list of player numbers flagged to be dropped from the game. Players are added to this list via FlagPlayerToDrop and are actually dropped during the next Update cycle. This deferred dropping prevents issues with immediate disconnection.
The HeroDefinition data in the key-value pair structure. Contains the actual hero configuration including name, prefab reference, and avatar material for the associated HeroType.
Queue of player numbers waiting to spawn in deathmatch mode. When multiple players need to respawn and spawning is limited (e.g., helicopter capacity), this queue tracks the order. The host manages the queue and syncs it to other players via the SyncRespawnQueue RPC.
The HeroType enum value in the key-value pair structure. Maps the enum to its corresponding HeroDefinition data for serialization and configuration management.
Static list tracking which hero types have already been selected during the current game session. Used to prevent duplicate hero selection when spawning new characters, ensuring variety. The list is trimmed when it grows too large relative to active players.
Serializable list of hero setup data using the HeroSetupKeyPair inner class. This list is populated during OnBeforeSerialize from the internal _heroData dictionary and restored during OnAfterDeserialize. Used for Unity's serialization system to persist hero configuration data.
Tracks the order in which players died during the current game session. Used by the rescue system to determine which player should be revived when a rescue bro is collected. Earlier deaths get priority for revival. Synced across network.
public static List<HiddenExplosives> hiddenExplosives
Static list of all registered hidden explosives in the game. Hidden explosives register via RegisterHiddenExplosives and are removed via RemoveHiddenExplosives. List is cleared on Awake and OnDestroy. Used for managing special explosive objects.
List of all active rescue bros in the current level. Rescue bros register themselves on Start and are removed when freed or destroyed. Used for proximity checks when players attempt to rescue bros and for finding the nearest rescue bro to players.
Converts an array of HeroType enums to an array of integers for serialization. Uses Array.ConvertAll with a lambda to cast each HeroType to its integer value. Used when hero type data needs to be transmitted or stored as integers.
Parameters:
- HeroType[] heroArray: The array of HeroType enums to convert.
Returns:
-
int[]
: Array of integers representing the hero types.
Converts an array of integers back to an array of HeroType enums after deserialization. Uses Array.ConvertAll with a lambda to cast each integer to HeroType. Reverse operation of ConvertHeroArrayToIntArray for restoring hero type data.
Parameters:
- int[] intArray: The array of integers to convert.
Returns:
-
HeroType[]
: Array of HeroType enums restored from the integers.
Static list of additional transform positions for the camera to follow beyond player characters. Objects can register via TryFollow and unregister via StopFollowing. Camera system checks these positions when determining view bounds and focus area.