BroforceObject - alexneargarder/Broforce-Docs GitHub Wiki

BroforceObject

Table of Contents

Position & Physics

Methods

public virtual void SetPosition(Vector3 pos)

Sets the object's world position to the specified coordinates while preserving the current Z position. Updates the internal X and Y fields to match the new transform position.

Parameters:

  • Vector3 pos: The new position vector (only X and Y components are used, Z is preserved from current transform)

public virtual void SetSpeed(float xi, float yi)

Virtual method for setting the object's velocity. Base implementation is empty - derived classes should override to implement velocity changes.

Parameters:

  • float xi: The horizontal velocity component
  • float yi: The vertical velocity component

public void SetXY(Transform t)

Updates the internal X and Y coordinate fields directly without modifying the transform position. This method only updates the backing fields for the X and Y properties.

Parameters:

  • float x: The new X coordinate value to store
  • float y: The new Y coordinate value to store

public void SetXY(Transform t)

Convenience method that extracts the X and Y position from a transform and calls SetXY(float, float) to update the internal coordinate fields.

Parameters:

  • Transform t: The transform whose position will be used to set the X and Y coordinates

Properties

public float X { get; set; }

Gets or sets the object's X position coordinate. This property provides access to the private x field which stores the horizontal position.


public float Y { get; set; }

Gets or sets the object's Y position coordinate. This property provides access to the private y field which stores the vertical position.


Fields

private float x

Private backing field that stores the object's X coordinate position. Serialized for persistence and accessed through the X property.


public float xI

The object's horizontal velocity component. Used for physics calculations and movement updates in derived classes.


private float y

Private backing field that stores the object's Y coordinate position. Serialized for persistence and accessed through the Y property.


public float yI

The object's vertical velocity component. Used for physics calculations and movement updates in derived classes.


Environmental Interaction

Methods

public virtual void AttachMe(Transform t)

Attaches another GameObject to this object by adding it to the otherAttachments list. Used by the attachment system to track objects that are connected to this one.

Parameters:

  • Transform t: The transform of the GameObject to attach

public virtual void CrumbleBridge(float chance)

Virtual method that triggers a bridge crumbling event. The base implementation only invokes the OnCrumbleBridge event if handlers are subscribed. Derived classes can override to add specific crumbling behavior.

Parameters:

  • float chance: The probability or intensity of the crumbling effect (unused in base implementation)

public virtual void Disturb()

Triggers a disturbance event on this object. If the object has a chain anchor, it collapses the chain. Then invokes the OnDisturb event if any handlers are subscribed. Can be called via RPC for network synchronization.


public void HideOtherAttachments()

Hides all attached objects by sending them a "Collapse" message and deactivating their GameObjects. Iterates through the otherAttachments list and processes each non-null attachment.


Fields

public ChainAnchor chainAnchor

Reference to a ChainAnchor component that can connect this object to chains or ropes. When the object is disturbed, the chain anchor will collapse if present.


public bool collapsed

Flag indicating whether this object has collapsed or fallen. Used by environmental systems to track the state of destructible or physics-enabled objects.


public List<GameObject> otherAttachments = new List<GameObject>()

List of GameObjects that are attached to this object. Used by the attachment system to track and manage connected objects. Initialized as an empty list.


Character State & Effects

Methods

public virtual void ForgetPlayer(int playerNum, bool confuseMooks, bool amuseMooks)

Virtual method called when a player should be forgotten by this object. Base implementation is empty - derived classes override to implement AI behavior changes when players die or disconnect.

Parameters:

  • int playerNum: The player number (0-3) that should be forgotten
  • bool confuseMooks: If true, mooks should become confused instead of simply forgetting the player
  • bool amuseMooks: If true, mooks should laugh at the dead player instead of forgetting them

public virtual float GetHealthPercentage()

Calculates the object's health as a percentage of its maximum health. Returns a value between 0 and 1, clamped to prevent invalid percentages.

Returns:

  • float: The health percentage as a float between 0.0 (dead) and 1.0 (full health)

public virtual bool IsAlive()

Checks if the object is still alive based on its health value. Returns true if health is greater than 0, false otherwise.

Returns:

  • bool: True if the object has health remaining (health > 0), false if dead or destroyed

Fields

public bool destroyed

Flag indicating whether this object has been destroyed. Used to prevent multiple destruction calls and to track object lifecycle state.


public int health = 3

The object's current health points. Defaults to 3. When health reaches 0 or below, the object is considered dead as determined by IsAlive().


public int maxHealth = -1

The object's maximum health capacity used for calculating health percentage. Defaults to -1, which should be set by derived classes to an appropriate value.


public bool protectedFromDestruction

When true, prevents this object from being destroyed by normal damage or destruction calls. Used for invincible objects or during special game states.


Helper & Utility

Fields

public PredabroTarget predabroTarget

Reference to a PredabroTarget component used by the Predabro enemy type for targeting logic. Hidden in inspector as it's managed programmatically.


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