Player - alexneargarder/Broforce-Docs GitHub Wiki

Player

Table of Contents

Player Management

Methods

private void AddPerksToHUD()

Adds the player's current perks to their HUD display. Retrieves perks from PlayerInventory and displays them on the HUD interface for the player to see their active bonuses.


public virtual void Awake()

Initializes the player instance with network instantiation data. Sets up player number, network PID, controller ID, and creates the HUD if needed. Also initializes lives to 0 if the player dropped out this round (except for solo host who gets 1 life).


public void DisableBotBrain()

Disables AI control for this player by setting the UsingBotBrain flag to false. The player will return to normal input control after this is called. Note that this doesn't remove the BotBrain component, only disables its use.


public void EnableBotBrain()

Enables AI control for this player by adding and configuring a BotBrain component. Creates a new BotBrain component if one doesn't exist, assigns the current character to it, and sets the UsingBotBrain flag to true. This allows the player to be controlled by AI instead of player input.


protected override void OnDestroy()

Cleanup method called when the player object is destroyed. Properly disposes of the player's HUD by unparenting it and destroying the game object, then destroys any active character unit. This ensures proper cleanup of player-owned resources.


private void ResetPerkValuesOnLevelStart()

Resets per-level perk values at the start of each level. Calls into PlayerInventory to reset any perk effects that don't persist between levels.


public void SetBotbrainLeader(int playerNum)

Sets which player the bot should follow when using AI control. The bot brain will attempt to follow and support the character of the specified player number. This is used to coordinate AI teammates with human players.

Parameters:

  • int playerNum: The player number that this bot should follow. Use -1 for no specific leader.

private void SetupHud()

Creates and initializes the player's HUD interface. Instantiates the PlayerHUD prefab, sets it up with current lives and player number, then hides it initially until needed.


private void Start()

Performs initial player setup after instantiation. Verifies network connection, sets initial lives based on game mode, requests player data from server if not host, and sets up perks. Handles special cases for hardcore mode, deathmatch, and procedural generation modes.


Properties

public int BotBrainLeader { get; set; }

Gets or sets the player number that this bot should follow when using AI control. The bot brain will attempt to follow the character of the specified player number. -1 indicates no specific leader.


public int controllerNum { get; set; }

Gets the controller ID assigned to this player. Returns the controller ID from HeroController.playerControllerIDs based on this player's playerNum. Returns -1 if playerNum is invalid (less than 0).


public bool UsingBotBrain { get; set; }

Gets or sets whether this player is being controlled by AI. When true, the BotBrain component controls the player's character instead of player input. Used for AI-controlled teammates or testing.


Fields

public int playerNum = -1

The player's unique identifier number in the game session. Ranges from 0-3 for the four possible players. Used as an index into various player arrays like HeroController.players, PlayerInventory arrays, and for network identification. Initialized to -1 until properly set during Awake.


Lives & Respawn System

Methods

public void AddLife()

Adds one life to the player's life count. Only executes for the local player, incrementing Lives and triggering a free life animation on the HUD.


public void RemoveLife()

Removes a life from the player based on the current game mode rules. In hardcore mode, moves the hero from available to dead list and may force level restart. In ProcGen mode, decrements global lives and may trigger level failure. In campaign mode, also clears any active flex powers. Updates lives differently for each game mode.


public void SetLivesRPC(int _lives)

RPC method that sets the player's lives count and updates the HUD. Called by the Lives property setter to synchronize life count across all clients in multiplayer.

Parameters:

  • int _lives: The new lives count to set.

Properties

public int Lives { get; set; }

Gets or sets the player's remaining lives count. Handles different game modes: returns/sets hardcore lives for hardcore mode, procedural generation lives for procgen mode, or standard lives otherwise. When setting as the local player, also syncs the value via RPC to other players.


Fields

private int lives = 1

Private backing field for the Lives property storing the player's current life count. Initialized to 1 and modified through the Lives property setter which handles RPC synchronization. In standard gameplay this tracks the player's remaining lives, but the Lives property getter may return different values based on game mode (hardcore or procedural generation).


Input & Control

Methods

public void AddPlayerTarget(Transform target)

Sets a temporary target transform for this player to focus on. This target overrides normal camera behavior and can be used to direct player attention to specific objects or locations in the game world, such as during scripted sequences or tutorials.

Parameters:

  • Transform target: The transform to set as the temporary target.

public void GetInput(ref bool up, ref bool down, ref bool left, ref bool right, ref bool fire, ref bool buttonJump, ref bool special, ref bool highFive, ref bool buttonGesture, ref bool sprint)

Retrieves input state for all control actions from the appropriate source. If using bot brain, gets AI-generated input. If chat or pause menu is active (based on controller number), returns all false inputs. Otherwise reads input from the physical controller via InputReader. This centralizes all input handling for the player.

Parameters:

  • out bool up: Output parameter set to true if up direction is pressed.
  • out bool down: Output parameter set to true if down direction is pressed.
  • out bool left: Output parameter set to true if left direction is pressed.
  • out bool right: Output parameter set to true if right direction is pressed.
  • out bool fire: Output parameter set to true if fire button is pressed.
  • out bool buttonJump: Output parameter set to true if jump button is pressed.
  • out bool special: Output parameter set to true if special/grenade button is pressed.
  • out bool highFive: Output parameter set to true if high five button is pressed.
  • out bool buttonGesture: Output parameter set to true if gesture button is pressed.
  • out bool sprint: Output parameter set to true if sprint button is pressed.

public bool HasTemporaryTarget()

Checks whether this player currently has a temporary target set. Returns true if a temporary target transform is assigned, false otherwise. Used to determine if the camera should follow a special target instead of the player character.

Returns:

  • bool: True if the player has a temporary target set, false otherwise.

public bool IsRescuingBro()

Checks if the player is currently rescuing a specific bro. Returns true if rescuingThisBro field is not null, indicating an active rescue operation in progress.

Returns:

  • bool: True if actively rescuing a bro, false otherwise.

public void RemovePlayerTarget()

Clears the temporary target transform for this player. Returns camera focus to normal behavior, typically following the player's character. This is called when a scripted sequence ends or the target object is no longer relevant.


internal void SetRumble(float amount)

Sets the controller rumble intensity for force feedback. Updates the rumbleIntensity to the maximum of the current value and the provided amount, ensuring the strongest rumble effect is preserved. The rumble will fade out over time based on the update loop logic.

Parameters:

  • float amount: The rumble intensity to apply (0 to 1 range).

Properties

public bool awaitingHeroTypeFromServer { get; set; }

Gets or sets whether the player is waiting for the server to assign a hero type. When set to true, starts a 15-second timeout. Used during respawn/rescue operations to track server response state.


public bool RescueInProgress { get; set; }

Gets or sets whether this player is currently in the process of rescuing a bro. When set to true, starts a 15-second timeout. Used to track rescue operation state and prevent multiple simultaneous rescues.


Fields

private bool _awaitingHeroTypeFromServer

Private flag indicating the player is waiting for the server to assign a hero type during respawn. Set via the awaitingHeroTypeFromServer property which also manages the server timeout. Prevents multiple hero requests and tracks respawn state.


public bool changingBroFromTrigger

Flag indicating the player is swapping bros via a trigger (like swap bro crates). Checked in WorkOutSpawnScenario to return TriggerSwapBro spawn type, then immediately cleared. Used to maintain position when swapping heroes through game triggers rather than death.


private bool rescueInProgress

Private flag indicating whether this player is currently rescuing a bro. Set via the RescueInProgress property which also manages the server timeout. Prevents multiple simultaneous rescue attempts and tracks rescue state for spawn positioning.


public RescueBro rescuingThisBro

Reference to the RescueBro object currently being rescued by this player. Set when the player initiates a rescue operation via HeroController.RescueBro or HeroController.SpawnOnPlayer. Used to determine spawn position (RespawnAtRescueBro) and properly destroy the rescue cage when the hero spawns. Null when no rescue is in progress.


private float rumbleIntensity

Current controller vibration intensity (0 to 1 range) for force feedback effects. Set via SetRumble which takes the maximum of current and new values. Automatically decreases by 2 per second in Update loop until reaching 0. Passed to InputReader.SetRumble each frame to apply controller vibration if the player has rumble enabled in options.


public float serverResponseTimeout

Timeout counter for server operations in seconds. Set to 15 seconds when starting a rescue operation or requesting hero type from server. Counts down each frame and clears rescue/hero request flags if it reaches 0, preventing indefinite waiting for server responses.


UI & HUD Management

Methods

public void ActivateHUD()

Activates and shows the player's HUD if standard HUDs are enabled in the current game mode. Creates the HUD if needed and makes it visible on screen.


public void DisableHud()

Hides and deactivates the player's HUD elements. Calls Hide on the HUD, deactivates the HUD game object, and also deactivates the lives text display if it exists.


public void EnableHud()

Shows and activates the player's HUD elements if standard HUDs are enabled. Checks GameModeController.ShowStandardHUDS before making the HUD visible, activating the game object and lives text display.


public void FlashSpecialAmmo()

Triggers a flash effect on the special ammo/grenade icons in the HUD. Creates the HUD if it doesn't exist, then calls FlashSpecialIcons to provide visual feedback for special ammo changes.


public void SetAvatarDead(bool primaryAvatar)

Updates the HUD to show the player's avatar as dead. Calls the HUD's SetAvatarDead method to update the visual representation of the player's death state.

Parameters:

  • bool primaryAvatar: Whether this is the primary avatar that died.

public void SetAvatarSpecialFrame(float time)

Sets a special animation frame on the player's HUD avatar for a specified duration. Used for special visual effects or states on the HUD avatar display.

Parameters:

  • float time: The duration to display the special frame.

private void SetUpDeathMatchHUD(TestVanDammeAnim newUnit)

Creates and configures a death match HUD that follows the hero character. Hides the standard HUD, instantiates the death match HUD prefab, sets it up with player lives and number, and parents it to the hero transform at zero offset.

Parameters:

  • TestVanDammeAnim newUnit: The hero unit to attach the death match HUD to.

internal void ShowMinusPlum()

Displays a negative score indicator (plum) on the player's deathmatch HUD. Shows a visual feedback element indicating point loss, typically when the player dies or loses points in deathmatch game modes.


internal void ShowPlusPlum()

Displays a positive score indicator (plum) on the player's deathmatch HUD. Shows a visual feedback element indicating point gain, typically when the player scores a kill or earns points in deathmatch game modes.


public void StopAvatarSpecialFrame()

Stops any active special animation frame on the player's HUD avatar. Returns the avatar display to its normal state by calling StopUsingSpecialFrame on the HUD.


private void UnlockProcGenCamera()

Unlocks the procedural generation camera after a delay. Called via Invoke after spawning a hero in ProcGen mode when the player died inside a room. Note: ProcGenGameMode is an unfinished feature.


Fields

public CharacterUI characterUI

Reference to the CharacterUI component on this player game object. Retrieved during Awake and used for character-specific UI functionality. The specific usage of this component is not shown in the available code.


public HUDHeadGear deathMatchHUD

The instantiated HUDHeadGear instance for deathmatch modes. Follows the player's character transform and displays game mode specific information. Created from deathMatchHUDPrefab when playing deathmatch and parented to the hero transform.


public HUDHeadGear deathMatchHUDPrefab

Prefab reference for the deathmatch-specific HUD that appears above the player's character. Used in deathmatch game modes to show player-specific information like lives and grenades directly on the character rather than in screen corners.


public PlayerHUD hud

The instantiated PlayerHUD instance for this player. Displays lives count, grenade/special ammo count, avatar icon, and perk information. Created from playerHUDPrefab and managed throughout the player's lifetime. Can be null before setup or in certain game modes.


public PlayerHUD playerHUDPrefab

Prefab reference for the standard player HUD interface. Used as a template to instantiate the player's HUD display showing lives, grenades, and other UI elements. Instantiated in SetupHud method when needed.


Score & Statistics

Methods

public void ReportGib(Unit gibbedUnit)

Reports when this player gibs (completely destroys) an enemy for perk triggering. If the character is alive, triggers the OnEnemyGibbed perk event with player inventory items and gib data. Gibbing enemies often provides bonus effects or satisfies specific perk conditions.

Parameters:

  • KillData killData: Struct containing information about the gibbed unit including damage type.
  • DamageObject damageObject: The damage source object that caused the gib.

public void ReportGib(Unit gibbedUnit)

Simplified gib reporting method that takes only the gibbed unit. Currently has an empty implementation after checking if the character exists and is alive. This appears to be an incomplete overload for simpler gib tracking scenarios.

Parameters:

  • Unit gibbedUnit: The unit that was gibbed.

public void ReportKill(KillData killData, DamageObject damageObject)

Reports a kill made by this player's character for statistics and perk triggering. If the character is alive, triggers the OnMookKilled perk event with player inventory items and kill data, then notifies the character of the kill. This tracks combat performance and activates kill-based perks.

Parameters:

  • KillData killData: Struct containing information about the killed unit including damage type and whether it was gibbed.
  • DamageObject damageObject: The damage source object that caused the kill.

public void TriggerPerkEvent(PerkTriggerController.PerkEvent eventType, TestVanDammeAnim bro, CheckPoint checkPoint)

Triggers a perk event for this player with just the hero as context. Passes the event type, player's inventory items, and hero reference to the perk trigger controller. Used for hero-specific events like spawning, death, or ability usage.

Parameters:

  • PerkEvent eventType: The type of perk event to trigger.
  • TestVanDammeAnim bro: The hero character associated with this event.

public void TriggerPerkEvent(PerkTriggerController.PerkEvent eventType, TestVanDammeAnim bro, CheckPoint checkPoint)

Triggers a perk event for this player with hero and mook context. Passes the event type, player's inventory items, hero, and mook references to the perk trigger controller. Used for combat events involving specific enemy interactions.

Parameters:

  • PerkEvent eventType: The type of perk event to trigger.
  • TestVanDammeAnim bro: The hero character associated with this event.
  • Mook mook: The mook (enemy) involved in this event.

public void TriggerPerkEvent(PerkTriggerController.PerkEvent eventType, TestVanDammeAnim bro, CheckPoint checkPoint)

Triggers a perk event for this player with hero and checkpoint context. Passes the event type, player's inventory items, hero, and checkpoint references to the perk trigger controller. Used for checkpoint-related events like reaching or activating checkpoints.

Parameters:

  • PerkEvent eventType: The type of perk event to trigger.
  • TestVanDammeAnim bro: The hero character associated with this event.
  • CheckPoint checkPoint: The checkpoint involved in this event.

Properties

public Color PlayerColor { get; set; }

Gets the color assigned to this player based on their player number. Retrieves the color from HeroController.GetHeroColor for consistent player identification across UI elements.


public ValueOrchestrator ValueOrchestrator { get; set; }

Gets the ValueOrchestrator instance for this player from the global PlayerInventory. The ValueOrchestrator manages dynamic value modifications from perks, power-ups, and other sources, calculating final multipliers for various gameplay values like damage, speed, or health.


Game State & Flow

Methods

public void ClearTimeSinceDeath()

Resets the death timer to allow continued camera following. Sets timeSinceDeath to timeSinceDeathToFollow value, effectively extending the camera follow duration after death.


public bool Exists()

Checks if the player has an active character in the game world. Returns true only if the character reference is not null and the character's game object is active in the hierarchy.

Returns:

  • bool: True if the player has an active character, false otherwise.

public Vector3 GetCharacterPosition()

Gets the current position of the player's character. Returns the character's transform position if alive, otherwise returns the last known player follow position.

Returns:

  • Vector3: The character's current position or last known position if dead.

public Vector3 GetFollowPosition()

Gets the position the camera should follow for this player. Returns temporary target position if set, otherwise returns the smoothed character position. Updates death timer and follow position for living characters. Falls back to last known position after death.

Returns:

  • Vector3: The world position the camera should follow.

public bool HasFollowPosition()

Determines if this player should be followed by the camera. For local players, returns true if alive or within the death follow time window. For remote players, returns true if alive and instantiated. Tracks time since death to allow brief following after death.

Returns:

  • bool: True if the camera should follow this player, false otherwise.

public bool IsAlive()

Determines if the player is considered alive in the game. Returns true if the character exists and is alive, OR if the player is pending respawn/rescue (waiting states count as alive for game logic).

Returns:

  • bool: True if the player is alive or pending respawn, false otherwise.

public bool IsAliveAndSpawnedHero()

Checks if the player has a fully spawned and alive hero. More strict than IsAlive - requires the character to exist, be alive, AND have completed spawn position setup.

Returns:

  • bool: True if the hero is alive and fully spawned, false otherwise.

public bool IsInvulnerable()

Checks if the player's character is currently invulnerable. Returns the invulnerable state of the character if it exists, false otherwise.

Returns:

  • bool: True if the character is invulnerable, false otherwise.

public bool IsNearbyActivatedCheckPoint(ref bool spawnViaAirdrop)

Checks if the player's character is near an activated checkpoint and gets the checkpoint position. Delegates to Map.IsNearActivatedCheckPoint using the character's current position. Modifies the ref parameters with checkpoint data if found.

Parameters:

  • out Vector2 pos: Output parameter that receives the checkpoint position if one is found nearby.
  • out bool spawnViaAirdrop: Output parameter that indicates if the checkpoint requires air drop spawning.

Returns:

  • bool: True if near an activated checkpoint, false otherwise.

public bool IsNearbyActivatedCheckPoint(ref bool spawnViaAirdrop)

Checks if the player's character is near an activated checkpoint without retrieving position. Overload that only returns whether an air drop spawn is required, without the checkpoint position.

Parameters:

  • out bool spawnViaAirdrop: Output parameter that indicates if the checkpoint requires air drop spawning.

Returns:

  • bool: True if near an activated checkpoint, false otherwise.

public bool IsPendingRespawnOrResuingInProgress()

Checks if the player is in a pending state waiting for respawn or rescue. Returns true if either RescueInProgress or awaitingHeroTypeFromServer flags are set.

Returns:

  • bool: True if waiting for respawn or in rescue process, false otherwise.

public bool IsThisWay(float x, float y, int xDirection)

Checks if the player's character is in the specified direction from a given position. Special handling for Snake Broskin's grenade hologram position. Returns true if the character (or hologram) is in the direction indicated by xDirection from the given coordinates.

Parameters:

  • float x: The X coordinate to check from.
  • float y: The Y coordinate to check from.
  • int xDirection: The direction to check (-1 for left, 1 for right).

Returns:

  • bool: True if the character is in the specified direction, false otherwise.

protected override void LateUpdate()

Late update processing that occurs after all Update calls. Calls base class LateUpdate and then updates the smoothed follow position for camera tracking.


public override UnityStream PackState(UnityStream stream)

Serializes the player's state for network synchronization. Packs the current lives count, character reference, and firstDeployment flag into the stream, then calls the base class PackState. This method is used to sync player state across the network in multiplayer games. Note: Network functionality may not work reliably in mods.

Parameters:

  • UnityStream stream: The Unity network stream to write the state data to.

Returns:

  • UnityStream: The stream with the serialized player state.

public override UnityStream UnpackState(UnityStream stream)

Deserializes the player's state from network data. Reads lives count, character reference, and firstDeployment flag from the stream, enables the HUD with updated data, then calls the base class UnpackState. This method receives player state updates in multiplayer games. Note: Network functionality may not work reliably in mods.

Parameters:

  • UnityStream stream: The Unity network stream to read the state data from.

Returns:

  • UnityStream: The stream after reading the player state.

private void Update()

Main update loop for the player. Handles idle timeout detection (35 seconds), controller rumble, server response timeouts, fuel/grenade HUD updates, and bot brain management. Monitors player input to detect AFK players in multiplayer and manages various time-based states.


public void UpdateSmoothFollowPos()

Updates the smoothed follow position used for camera tracking. For local players, directly uses character position. For remote players, smoothly interpolates position unless the character has moved too far (200 units squared), in which case it snaps to the new position.


Fields

private const float AFKTimeLimit = 35f

Constant defining the idle time limit before a player is considered AFK (Away From Keyboard). Set to 35 seconds. When idleTimer reaches this value in multiplayer games, the player is automatically dropped out and an AFK message is displayed. This prevents inactive players from blocking game progress.


public bool charHasBeenInstantiated

Flag indicating whether the player's character has completed at least one update cycle. Set to true in Update when character exists and UpdateHasRunAtleastOnce is true. Used by remote players in HasFollowPosition to determine if the character is ready for camera following. Ensures character is fully initialized before certain operations.


public bool firstDeployment = true

Tracks whether this is the player's first spawn in the current level. Initialized to true and set to false after first spawn. Used to determine spawn behavior (transport vs checkpoint), suppress spawn sounds, and handle special first-spawn logic. Reset between levels.


private float idleTimer

Tracks how long the player has been idle (no input) in seconds. Incremented by unscaled delta time when the player has no input in multiplayer games with other alive players. Reset to 0 when any input is detected. When this reaches AFKTimeLimit (35 seconds), triggers automatic dropout and shows AFK message.


public float playerDelay

Timer field that counts down in the Update loop. Decremented by deltaTime each frame when greater than 0. The specific purpose is not clear from the available code, but appears to be a general-purpose delay timer for player actions.


public Transform playerTemporaryTarget

Optional transform that overrides normal camera following behavior. When set, the camera will follow this target instead of the player's character. Used for scripted sequences, cutscenes, or directing player attention to specific objects. Cleared with RemovePlayerTarget.


public Vector3 SmoothedFollowPosition = -Vector3.one

The interpolated position used for smooth camera following. For local players, directly matches character position. For remote players, smoothly interpolates toward the character position unless they teleport (move more than 200 units). Initialized to -Vector3.one and updated in UpdateSmoothFollowPos.


private float timeSinceDeath

Tracks elapsed time in seconds since the player's character died. Incremented in HasFollowPosition for local players after death. Reset to 0 when character is alive and updating. Used with timeSinceDeathToFollow to allow brief camera following after death before switching to other players. Can be reset via ClearTimeSinceDeath.


protected float timeSinceDeathToFollow = 1.5f

The duration in seconds to continue following a dead player's last position. Set to 1.5 seconds by default. After a player dies, the camera continues following their position for this duration before switching to other players. This provides visual continuity and lets players see the immediate aftermath of their death.


Character & Hero Control

Methods

public void AddFlexPower(PickupType pickup, bool forced = true)

Adds a flex power pickup to the player's inventory. Flex powers are temporary power-ups that grant special abilities like invulnerability, air jump, teleport, or golden light. If forced is true, overwrites any existing flex power. If forced is false, only adds if the player has no current flex power. This is an RPC method for network synchronization.

Parameters:

  • PickupType pickup: The type of flex power pickup to add (e.g., FlexInvulnerability, FlexAirJump, FlexTeleport, FlexGoldenLight).
  • bool forced: If true, replaces any existing flex power. If false, only adds if no flex power is currently active.

public void AssignCharacter(TestVanDammeAnim character)

Assigns a hero character to this player and clears pending state flags. Sets the character reference and resets awaitingHeroTypeFromServer and RescueInProgress flags to false.

Parameters:

  • TestVanDammeAnim character: The hero character to assign to this player.

public void BoostHero(float time)

Applies a speed boost to the player's hero character for the specified duration. If the player has an active character, calls the character's Boost method which increases movement speed temporarily. This is typically used for power-ups or special abilities that enhance hero mobility.

Parameters:

  • float time: The duration in seconds for which the speed boost should last.

public void ClearFlexPower()

Removes the player's current flex power. Calls PlayerInventory.HeroHasDied which clears the flex power from the global inventory. This is typically called when the player dies to ensure flex powers don't persist between lives in campaign mode.


public void DeRegisterMinion(Unit minion)

Removes a unit from this player's minion list. If the unit is currently registered as a minion, removes it from the tracking list. This is typically called when a minion dies or is no longer under the player's control.

Parameters:

  • Unit minion: The unit to remove from this player's minion list.

public void ForceRespawnWithFlexPower(PickupType pickup, bool respawnWithFlexPower = false)

Sets a flex power to be automatically applied when the player respawns. Stores the specified pickup type in _forceFlexPowerupSpawn field, which is checked during hero instantiation to grant the power immediately upon spawning. The respawnWithFlexPower parameter is not used in the current implementation.

Parameters:

  • PickupType pickup: The flex power pickup type to grant on respawn.
  • bool respawnWithFlexPower: Unused parameter in current implementation.

public PickupType GetFlexPower()

Gets the player's currently active flex power type. Retrieves the flex power from PlayerInventory for this player number.

Returns:

  • PickupType: The PickupType of the current flex power, or PickupType.None if no power is active.

public bool HasFlexPower()

Checks if the player currently has a specific type of flex power. Compares the player's current flex power in PlayerInventory against the specified type.

Parameters:

  • PickupType flexType: The flex power type to check for.

Returns:

  • bool: True if the player has the specified flex power type, false otherwise.

public bool HasFlexPower()

Checks if the player currently has any flex power active. Returns true if the player's flex power in PlayerInventory is not None.

Returns:

  • bool: True if the player has any flex power, false otherwise.

private TestVanDammeAnim InstantiateHero(HeroType heroTypeEnum, int PlayerNum, int ControllerNum)

Creates and initializes a new hero instance for the local player only. Instantiates the hero prefab via networking, sets up the hero with player data, calculates spawn position, configures death match HUD if needed, and applies any flex powers. Returns null for non-local players. Note: ProcGenGameMode references are for an unfinished feature.

Parameters:

  • HeroType heroTypeEnum: The type of hero to instantiate.
  • int PlayerNum: The player number who owns this hero.
  • int ControllerNum: The controller number assigned to this player.

Returns:

  • TestVanDammeAnim: The instantiated hero character, or null if not the local player.

public void RegisterMinion(Unit minion)

Registers a unit as a minion controlled by this player. Adds the unit to the player's minions list if not already present. Minions are AI-controlled units that fight alongside the player, such as rescued animals or summoned allies.

Parameters:

  • Unit minion: The unit to register as a minion of this player.

public void ReRequestHeroTypeFromMasterOnServerMigration()

Re-requests hero type information from the new master after server migration. Currently empty implementation - appears to be a stub for handling host migration scenarios.


public void RespawnBro(bool swappingBro = false)

Initiates the respawn process for the player's hero. Sets awaitingHeroTypeFromServer flag and requests a hero type from the master/host. The swappingBro parameter indicates if this is a hero swap rather than a death respawn. This is an RPC method that only executes for the local player.

Parameters:

  • bool swappingBro: If true, indicates this is a hero swap rather than a death respawn.

public void SetHeroType(HeroType heroTypeEnum)

Sets the current hero type and updates the HUD avatar display. Changes the HUD avatar and grenade material to match the specified hero type and sets the avatar to calm state.

Parameters:

  • HeroType heroTypeEnum: The hero type to set as current.

public void SetInvulnerable(float time)

Sets the hero character to be invulnerable for the specified duration. Calls the character's SetInvulnerable method with the fadeIn parameter set to true and the showSmoke parameter set to false. This provides temporary protection from damage, typically used after spawning or during special events.

Parameters:

  • float time: The duration in seconds for which the character should be invulnerable.

public void SetSpawnPositon(TestVanDammeAnim bro, Player.SpawnType spawnType, bool spawnViaAirDrop, Vector3 pos)

RPC method that sets the spawn position and state for a hero character. Applies the calculated position, enables parachute if spawning via air drop, plays spawn sounds for non-first deployments, and grants temporary invulnerability. Updates rescue and hero request flags to false.

Parameters:

  • TestVanDammeAnim bro: The hero character being spawned.
  • SpawnType spawnType: The type of spawn scenario being used.
  • bool spawnViaAirDrop: Whether the hero should spawn with a parachute.
  • Vector3 pos: The world position where the hero should spawn.

public void SpawnHero(HeroType nextHeroType)

Spawns a new hero of the specified type for this player. Recalls any existing living hero, handles cutscene loading for newly played heroes, unlocks heroes in campaign mode, and calls InstantiateHero to create the actual character. Updates player progress for unlocked heroes.

Parameters:

  • HeroType nextHeroType: The type of hero to spawn.

public void TimeBroBoostHero(float time)

Applies a TimeBro-specific boost effect to the player's hero character. If the player has an active character, calls the character's TimeBroBoost method which provides special time-manipulation abilities. This boost is specific to TimeBro's unique gameplay mechanics.

Parameters:

  • float time: The duration in seconds for which the TimeBro boost should last.

public void WorkOutSpawnPosition(TestVanDammeAnim bro)

Calculates and sets the spawn position for a hero based on the determined spawn scenario. Evaluates the spawn type, retrieves the appropriate position (checkpoint, cage, transport, etc.), and calls SetSpawnPositon via RPC to synchronize the position across all clients. Handles special cases like air drops and level editor reloads.

Parameters:

  • TestVanDammeAnim bro: The hero character to position for spawning.

private Player.SpawnType WorkOutSpawnScenario()

Determines the appropriate spawn scenario based on current game state and player conditions. Evaluates various factors including rescue status, game mode, checkpoint activation, and initial deployment to select the correct SpawnType. Returns Unknown type for explosion run mode without first deployment.

Returns:

  • SpawnType: The SpawnType enum value indicating how the player should spawn.

Properties

public TestVanDammeAnim character { get; set; }

Gets or sets the current hero character (TestVanDammeAnim) controlled by this player. This is the actual bro/character unit in the game world that the player controls. Setting this property also updates internal state tracking.


Fields

public TestVanDammeAnim _character

The current hero character (TestVanDammeAnim) instance controlled by this player. This is the actual bro unit in the game world. Can be null when the player is dead or waiting to spawn. Accessed through the character property which provides additional logic when setting.


private PickupType _forceFlexPowerupSpawn

Private field storing a flex power type to be automatically granted when the player spawns a new hero. Set by ForceRespawnWithFlexPower and checked during InstantiateHero to apply the power immediately after spawning. Reset to PickupType.None after use.


public HeroType heroType = HeroType.None

The HeroType enum value of the player's current hero. Used for HUD avatar display and tracking which bro the player is currently playing as. Set to HeroType.None when no hero is active. Updated when spawning a new hero via SetHeroType method.


public List<Unit> minions = new List<Unit>()

List of AI-controlled units that fight alongside this player. Includes rescued animals, summoned allies, or other units under the player's control. Units are added via RegisterMinion and removed via DeRegisterMinion. Used to track and manage AI companions.


public List<HeroType> recentlyUnlockedHeros = new List<HeroType>()

List of hero types that were recently unlocked but not yet used by the player. This field appears to be defined but not actively used in the current implementation. Likely intended for tracking newly unlocked bros for UI notifications or achievements.


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