CheckPoint - alexneargarder/Broforce-Docs GitHub Wiki

CheckPoint

Table of Contents

Unity Lifecycle & Setup

Methods

protected virtual void Awake()

Registers this checkpoint with the Map system and initializes position coordinates. Called when the checkpoint GameObject is first created.


protected override void OnDestroy()

Removes the steel replacement flag from ground blocks below and adjacent to the checkpoint position. This reverses the ground reinforcement applied during setup, using raycasts to find the affected blocks.


protected virtual void Start()

Hides the flag GameObject initially and disables the flag renderer for invisible checkpoints. Called after Awake on the first frame when the checkpoint becomes active.


protected virtual void Update()

Handles one-time setup when not in edit mode, reinforces nearby ground blocks, detects blocking units, and manages the deactivation delay timer. For non-invisible checkpoints, this method raycast-checks blocks directly below the checkpoint and its adjacent positions, marking them to be replaced with steel blocks if they collapse (excluding cage and sandbag blocks).


Fields

protected bool isSetup

Tracks whether the one-time setup in Update() has been completed. Prevents repeated setup operations and ground reinforcement checks after initial configuration.


Checkpoint Activation & State

Methods

public virtual void ActivateInternal()

Activates the checkpoint, raising the flag, playing sound effects, setting it as the current spawn point, and triggering end-level sequences for final checkpoints. Notifies statistics controller of checkpoint capture and handles special behavior for Hell theme levels (portal) vs normal levels (helicopter).


public void DelayDeactivate(float time)

Sets a timer to automatically deactivate the checkpoint after the specified delay. Used for temporary checkpoint states or special game modes.

Parameters:

  • float time: Time in seconds before the checkpoint deactivates

public bool IsBlockedByUnit()

Checks if an evil unit is preventing checkpoint activation by being alive and within 96 units distance. Final checkpoints detect blocking units during setup to determine end-level trigger behavior.

Returns:

  • bool: True if a living evil unit is within blocking range, false otherwise

public virtual void ReactivateInternal()

Sets this checkpoint as the current spawn point without triggering activation effects. Used to restore checkpoint state when loading saved games or synchronizing multiplayer state.


Fields

public bool activated

Current activation state of the checkpoint. When true, the flag is raised and this serves as a valid spawn point. Synchronized across network for multiplayer games.


protected Unit blockingUnit

Reference to the nearest evil unit found during setup. Used to determine if checkpoint activation should be blocked and whether this is a final checkpoint that triggers level completion.


protected float deactivateDelay

Countdown timer in seconds for automatic deactivation. When greater than zero, decrements each frame and deactivates the checkpoint when reaching zero.


public FlagFlap flag

Reference to the FlagFlap component that handles the visual flag raising animation. The flag GameObject is initially inactive and shown when the checkpoint activates.


protected bool isFinal

Marks this as the level's final checkpoint. When activated, triggers level completion sequence (helicopter extraction or hell portal depending on theme). Set during setup if evil units are nearby.


Configuration & Properties

Fields

public bool airDropCheckPoint

Determines if players respawn via airdrop parachute animation when spawning at this checkpoint. Map system checks this flag when determining spawn method for revived players.


public float airDropExtraHeight = 128f

Additional height offset in units added to airdrop spawn position when airDropCheckPoint is true. Default value of 128 units provides clearance for parachute deployment animation.


public int checkPointID = -1

Unique identifier assigned by Map.RegisterCheckPoint() based on registration order. Used to track which checkpoint is currently active and for save/load functionality. Default value of -1 indicates unregistered.


public bool invisibleCheckPoint

When true, all renderers are disabled making the checkpoint completely invisible to players. Invisible checkpoints skip ground reinforcement and blocking unit detection during setup.


Audio System

Fields

public AudioClip flagRaiseAudioClip

Custom audio clip played when the checkpoint activates and raises its flag. If null, no additional sound is played beyond the standard spatial sound component.


public float yeahVolume = 0.5f

Volume level for celebration sound effects. Default 0.5f provides balanced audio. Currently unused in the implementation but available for modders to implement custom sounds.


Networking & State Synchronization

Methods

public override UnityStream PackState(UnityStream stream)

Serializes the checkpoint's activation state for network synchronization. Only the activated boolean is transmitted to keep bandwidth usage minimal.

Parameters:

  • UnityStream stream: Stream to write the serialized state data

Returns:

  • UnityStream: The stream after serialization for method chaining

public override UnityStream UnpackState(UnityStream stream)

Deserializes checkpoint state from network data, restoring activation status and triggering visual updates. For activated final checkpoints, also restores the helicopter/portal state.

Parameters:

  • UnityStream stream: Stream containing the serialized state data

Returns:

  • UnityStream: The stream after deserialization for method chaining