Unit - alexneargarder/Broforce-Docs GitHub Wiki

Unit

Table of Contents

Unity Lifecycle & Setup

Methods

protected override void Awake()

Unity's Awake method that initializes the unit by caching AI components. Searches for PolymorphicAI components both on the unit itself and recursively through its parent/child hierarchy.


Combat & Damage

Methods

public virtual void BurnInternal(int damage, int direction)

Handles internal burn damage to the unit. Base implementation is empty. Override in derived classes to implement burn damage effects and animations.

Parameters:

  • int damage: The amount of burn damage to apply.
  • int direction: The direction of the burn effect (-1 for left, 1 for right).

public virtual void CreateGibEffects(DamageType damageType, float xI, float yI)

Creates visual gib effects when the unit is destroyed. Base implementation is empty. Override in derived classes to spawn gib particles and effects.

Parameters:

  • DamageType damageType: The type of damage that caused the gibbing.
  • float xI: The horizontal force for gib particles.
  • float yI: The vertical force for gib particles.

public virtual void Damage(int damage, DamageType damageType, float xI, float yI, int direction, MonoBehaviour damageSender, float hitX, float hitY)

Handles damage dealt to the unit. Base implementation is empty. Override in derived classes to implement damage processing, health reduction, and death handling.

Parameters:

  • int damage: The amount of damage to deal.
  • DamageType damageType: The type of damage being dealt.
  • float xI: The X impulse force from the damage.
  • float yI: The Y impulse force from the damage.
  • int direction: The direction the damage came from (-1 for left, 1 for right).
  • MonoBehaviour damageSender: The MonoBehaviour that caused the damage.
  • float hitX: The X coordinate where the damage hit.
  • float hitY: The Y coordinate where the damage hit.

public virtual void Death(float xI, float yI, DamageObject damage)

Handles the unit's death, hiding attachments and setting the action state to Dead. Sends death notification via RPC if the unit is owned by the local player or is not a hero. Special handling for MookArmouredGuy with SelfEsteem damage.

Parameters:

  • float xI: The horizontal force applied at death.
  • float yI: The vertical force applied at death.
  • DamageObject damage: The damage object containing information about what killed the unit.

public void DeathRPC(float xI, float yI, float _x, float _y)

Remote procedure call for synchronizing death across the network. Sets the unit's position and triggers the Death method if the unit isn't already dead.

Parameters:

  • float xI: The horizontal force applied at death.
  • float yI: The vertical force applied at death.
  • float _x: The X position where death occurred.
  • float _y: The Y position where death occurred.

protected virtual void Gib(DamageType damageType, float xI, float yI)

Protected method for gibbing the unit into pieces. Base implementation is empty. Override in derived classes to implement gibbing mechanics.

Parameters:

  • DamageType damageType: The type of damage that caused the gibbing.
  • float xI: The horizontal force of the gibbing.
  • float yI: The vertical force of the gibbing.

public virtual void GibNow(DamageType damageType, float xI, float yI)

Immediately gibs (explodes into pieces) the unit. Public wrapper that calls the protected Gib method.

Parameters:

  • DamageType damageType: The type of damage that caused the gibbing.
  • float xI: The horizontal force of the gibbing.
  • float yI: The vertical force of the gibbing.

public virtual void HeadShot(int damage, DamageType damageType, float xI, float yI, int direction, float xHit, float yHit, MonoBehaviour damageSender)

Handles headshot damage to the unit. Simply delegates to the regular Damage method with the same parameters. Override in derived classes to implement special headshot behavior.

Parameters:

  • int damage: The amount of damage to deal.
  • DamageType damageType: The type of damage being dealt.
  • float xI: The X impulse force from the damage.
  • float yI: The Y impulse force from the damage.
  • int direction: The direction the damage came from (-1 for left, 1 for right).
  • float xHit: The X coordinate where the headshot hit.
  • float yHit: The Y coordinate where the headshot hit.
  • MonoBehaviour damageSender: The MonoBehaviour that caused the damage.

public virtual void Impale(Transform impaleTransform, Vector3 direction, int damage, float xI, float yI, float xOffset, float yOffset)

Impales the unit on an object, attaching it to the specified transform. Base implementation is empty. Override in derived classes to implement impalement mechanics.

Parameters:

  • Transform impaleTransform: The transform to attach the impaled unit to.
  • Vector3 direction: The direction vector of the impalement.
  • int damage: The damage dealt by the impalement.
  • float xI: The horizontal velocity imparted by the impalement.
  • float yI: The vertical velocity imparted by the impalement.
  • float xOffset: The horizontal offset from the impale transform.
  • float yOffset: The vertical offset from the impale transform.

public virtual void Knock(DamageType damageType, float xI, float yI, bool forceTumble)

Applies knockback force to the unit. Base implementation is empty. Override in derived classes to implement knockback physics and animations.

Parameters:

  • DamageType damageType: The type of damage causing the knockback.
  • float xI: The X knockback force.
  • float yI: The Y knockback force.
  • bool forceTumble: Whether to force the unit into a tumbling state.

public virtual void KnockSimple(DamageObject damageObject)

Simplified knockback method that processes knockback from a DamageObject. Base implementation is empty. Override in derived classes to extract knockback parameters from the damage object.

Parameters:

  • DamageObject damageObject: The damage object containing knockback information.

public virtual void QuietDeath()

Kills the unit quietly without visual or audio effects. Sets health to 0, action state to Dead, and sends RPC notification if not already sent.


public void QuietDeathRPC(float _x, float _y)

Remote procedure call for synchronizing quiet death across the network. Sets the unit's position and triggers QuietDeath if the unit isn't already dead.

Parameters:

  • float _x: The X position where death occurred.
  • float _y: The Y position where death occurred.

public virtual void ReduceDeathTimer(int playerNum, float newTime)

Reduces the unit's death timer, potentially used for revival mechanics. Base implementation is empty. Override in derived classes to implement death timer reduction.

Parameters:

  • int playerNum: The player number requesting the timer reduction.
  • float newTime: The new death timer value.

protected virtual void SetDeathType(DamageType damageType, int health)

Determines the death animation type based on damage type and remaining health. If health is below -10, sets to Gibbed (or Explode for Unholy/Explosion damage). Otherwise selects appropriate death type: Fire damage causes fire death, explosions cause bullet death, melee/knife causes knife death, falls cause fall death, etc.

Parameters:

  • DamageType damageType: The type of damage that killed the unit.
  • int health: The unit's health at time of death.

public virtual void SetVelocity(DamageType damageType, float xI, float xIBlast, float yIBlast)

Sets the unit's velocity from damage or explosion effects. Base implementation is empty. Override in derived classes to apply velocity changes.

Parameters:

  • DamageType damageType: The type of damage causing the velocity change.
  • float xI: The base X velocity.
  • float xIBlast: The additional X blast velocity.
  • float yIBlast: The Y blast velocity.

public virtual void SilentDeath()

Alias for QuietDeath that kills the unit without visual or audio effects. Simply calls QuietDeath internally.


public virtual void Unimpale(int damage, DamageType damageType, float xI, float yI, MonoBehaviour firedBy)

Removes the unit from an impaled state and applies damage. Reduces the knockback velocity by 20% and applies damage at the unit's position with an 8 unit vertical offset.

Parameters:

  • int damage: The damage to apply when unimpaling.
  • DamageType damageType: The type of damage to apply.
  • float xI: The horizontal knockback force.
  • float yI: The vertical knockback force.
  • MonoBehaviour firedBy: The MonoBehaviour that caused the unimpalement.

Fields

protected bool _diedFromOOB

Protected flag indicating whether this unit died from going out of bounds. Set during death processing to track boundary-related deaths.


protected float burnCounter

Protected timer that tracks when to apply the next burn damage tick. Counts down between damage applications.


protected int burnDamage

Protected value specifying the amount of damage dealt per burn tick. Applied periodically while the unit is burning.


public float burnTime

The total duration in seconds that the unit will burn when set on fire. Hidden in Unity Inspector. Controls how long burn damage is applied.


public bool deathNotificationSent

Public flag tracking whether death has been synchronized across the network. Prevents duplicate death RPCs in multiplayer.


protected float deathTime

Protected timestamp recording when the unit died. Used for death animation timing and cleanup scheduling.


protected DeathType deathType

Protected enum storing how this unit died (Bullet, Explode, Fire, etc.). Used to select appropriate death animations and effects. Set by SetDeathType method.


protected bool hasNotifiedDeathType

Protected flag indicating whether the death type has been reported for achievements or statistics. Ensures deaths are only counted once.


protected bool hasReportedKill

Protected flag tracking whether kill credit has been given to the player who killed this unit. Prevents duplicate kill scoring.


protected float plasmaCounter

Protected timer that tracks when to apply the next plasma damage tick. Counts down between damage applications.


protected int plasmaDamage

Protected value specifying the amount of damage dealt per plasma damage tick. Applied periodically while affected by plasma.


public Projectile projectile

Reference to a projectile this unit has caught or is holding. Used by units that can catch and redirect projectiles. Null when not holding anything.


protected float shockCounter

Protected timer that tracks when to apply the next shock damage tick. Counts down between damage applications.


protected int shockDamage

Protected value specifying the amount of damage dealt per electrical shock tick. Applied periodically while being shocked.


public int timesKickedByVanDammeSinceLanding

Tracks the number of consecutive kicks received from Van Damme (JCVD) characters since the unit last touched the ground. Used for multi-kick combo tracking and special animations. Hidden in Unity Inspector.


Special Abilities

Methods

public virtual bool CatchFriendlyBullets()

Determines whether this unit can catch and neutralize friendly projectiles. Base implementation returns false. Override in units with bullet-catching abilities.

Returns:

  • bool: True if the unit can catch friendly bullets, false otherwise.

public virtual int GetSpecialAmmo()

Returns the current amount of special ammunition for this unit. Base implementation returns 0. Override in units with special weapons to return actual ammo count.

Returns:

  • int: The amount of special ammunition available.

public virtual bool IsFlexing()

Checks whether the unit is currently performing a flex animation or pose. Base implementation returns false. Override in units with flex animations to return actual state.

Returns:

  • bool: True if flexing, false otherwise.

public virtual bool IsInStealthMode()

Checks whether the unit is currently in stealth mode. Base implementation returns false. Override in stealth-capable units to return actual stealth state.

Returns:

  • bool: True if in stealth mode, false otherwise.

public virtual bool PlayingSummoningAnimation()

Checks whether the unit is currently playing any part of a summoning animation. Base implementation returns false. Override in summoning units to return actual animation state.

Returns:

  • bool: True if playing any summoning animation, false otherwise.

public virtual bool PlayingSummoningAnimationIntro()

Checks whether the unit is currently playing the intro portion of a summoning animation. Base implementation returns false. Override in summoning units to track animation state.

Returns:

  • bool: True if playing summoning intro animation, false otherwise.

public virtual bool ShowFuelGauge()

Determines whether this unit should display a fuel gauge in the UI. Base implementation returns false. Override in fuel-consuming units to enable fuel gauge display.

Returns:

  • bool: True if fuel gauge should be shown, false otherwise.

public virtual void StartSummoningAnimation()

Begins playing a summoning animation sequence. Base implementation is empty. Override in units with summoning abilities to trigger the animation.


public virtual void StopSummoningAnimation()

Stops the currently playing summoning animation. Base implementation is empty. Override in units with summoning abilities to handle animation cleanup.


public virtual bool UsingJetpack()

Checks whether the unit is currently using a jetpack. Base implementation returns false. Override in jetpack-equipped units to return actual jetpack usage state.

Returns:

  • bool: True if using jetpack, false otherwise.

Position & Physics

Methods

public virtual void BackSomersault(bool forceTumble)

Performs a backward somersault animation or movement. Base implementation is empty. Override in acrobatic units to implement backflip mechanics.

Parameters:

  • bool forceTumble: Whether to force the unit into a tumbling state.

public virtual bool CanDisableOffGround()

Determines whether this unit can be disabled when not touching the ground. Base implementation always returns false. Override in derived classes to allow air disabling.

Returns:

  • bool: True if the unit can be disabled while airborne, false otherwise.

public virtual void ForceFaceDirection(int direction)

Forces the unit to face a specific direction by flipping its transform scale. Negative values face left (X scale -1), positive values face right (X scale 1), and zero does nothing.

Parameters:

  • int direction: The direction to face (-1 for left, 1 for right, 0 for no change).

public virtual void FrontSomersault()

Performs a forward somersault animation or movement. Base implementation is empty. Override in acrobatic units to implement frontflip mechanics.


public virtual bool IsInQuicksand()

Checks whether the unit is currently in quicksand. Base implementation always returns false. Override in derived classes to implement quicksand detection.

Returns:

  • bool: True if the unit is in quicksand, false otherwise.

public virtual bool IsNearGround(float maxOffset)

Checks whether the unit is within a specified distance from the ground. Base implementation always returns true regardless of the offset parameter. Override in derived classes for actual distance checking.

Parameters:

  • float maxOffset: The maximum distance from ground to check.

Returns:

  • bool: True if within maxOffset distance from ground, false otherwise.

public virtual bool IsOnGround()

Checks whether the unit is currently on the ground. Base implementation always returns true. Override in derived classes to implement ground detection logic.

Returns:

  • bool: True if the unit is on ground, false otherwise.

public virtual void SetPosition()

Updates the unit's world position using the X and Y coordinates with Z offset adjustments. If the unit is submerged in a blood pool, adds an additional 8 units to the Z offset to create a visual depth effect.


public virtual void SetPositionAndVelocity(float X, float Y, float xi, float yi)

Sets both the position and velocity of the unit in one operation. Base implementation is empty. Override in derived classes to handle synchronized position and velocity updates.

Parameters:

  • float X: The X coordinate to set.
  • float Y: The Y coordinate to set.
  • float xi: The X velocity to set.
  • float yi: The Y velocity to set.

public override void SetSpeed(float xi, float yi)

Sets the unit's horizontal and vertical velocity components. Overrides the base implementation to directly assign both velocity values.

Parameters:

  • float xi: The horizontal velocity to set.
  • float yi: The vertical velocity to set.

Properties

public virtual bool IsParachuteActive { get; set; }

Gets or sets whether the unit's parachute is currently active. Base implementation always returns true for the getter and does nothing for the setter. Override in derived classes to implement actual parachute logic.


public Collider TheCollider { get; set; }

Gets the cached Collider component for this unit. Lazy-loads and caches the component on first access for efficient physics interactions.


Fields

public ZipLine attachedToZipline

Reference to the ZipLine object this unit is currently attached to. Null when not on a zipline. Set by AttachToZipline method.


private Collider collider_

Private cached reference to the unit's Collider component. Used by the TheCollider property to avoid repeated GetComponent calls.


public int collumn

The grid column position of this unit. Used for grid-based positioning systems in certain game modes or enemy formations. Note: Field name is misspelled.


public float headHeight = 15f

The height of the unit's head hitbox for headshot detection in game units. Defaults to 15 units. Hidden in Unity Inspector.


public float height = 8f

The height of the unit's collision bounds in game units. Defaults to 8 units. Used for physics collision detection and spatial calculations.


protected DirectionEnum lastWallAttachDirection

Protected storage of the previous wall attachment direction. Used to detect direction changes during wall climbing transitions.


protected PredabroRope rope

Protected reference to a PredabroRope object for general rope interactions. Different from strungUpBy which specifically handles trap suspension. Used for climbing or other rope mechanics.


public int row

The grid row position of this unit. Used for grid-based positioning systems in certain game modes or enemy formations.


public bool slidingOnZipline

Flag indicating whether the unit is actively sliding along a zipline. True during zipline traversal, false when stationary or not on zipline.


public PredabroRope strungUpBy

Reference to the PredabroRope that has trapped and suspended this unit. Used by Predator-style rope trap mechanics. Null when not trapped.


public float strungUpX

The X coordinate where this unit is suspended when caught in a rope trap. Used with Predator-style rope trap mechanics. Hidden in Unity Inspector.


public float strungUpY

The Y coordinate where this unit is suspended when caught in a rope trap. Paired with strungUpX for complete position storage during rope suspension. Hidden in Unity Inspector.


public bool suspendFromRope

Flag indicating whether this unit should be suspended from a rope trap. Controls whether the SuspendFromRope method will create a rope trap for this unit.


protected float t = 0.1f

Protected time value used for frame-independent calculations. Defaults to 0.1f. When set to 0, the T property returns clamped delta time instead of this value.


public DirectionEnum wallAttachDirection

The current direction this unit is attached to a wall. Uses DirectionEnum (Up, Down, Left, Right, Any) to track wall climbing orientation.


public float width = 8f

The width of the unit's collision bounds in game units. Defaults to 8 units. Used for physics collision detection and spatial calculations.


public float zOffset

The Z-axis offset for this unit's position. Used for depth sorting and visual layering. Modified when submerged in blood pools or for special effects.


Character State & Effects

Properties

public ActionState actionState { get; set; }

Gets or sets the current action state of the unit, such as Dead or other states that define what the unit is currently doing.


public bool CanDisembowel { get; set; }

Gets whether this unit can be disemboweled for gruesome death animations. Returns true if the canDisembowel field is set. Special handling for MookRiotShield units which also checks if their shield is not present.


public bool CanHear { get; set; }

Gets or sets whether this unit can detect sounds and noise from other units. Only returns true if both the internal canHear flag is true AND the GameObject is active in the hierarchy. Used for AI awareness and detection systems.


public virtual bool CanHearFriendlies { get; set; }

Gets whether this unit can hear sounds from friendly units. Base implementation always returns false, but can be overridden in derived classes to allow friendly unit detection.


public int frame { get; set; }

Gets or sets the current animation frame number for this unit. Used to track which frame of animation is currently being displayed.


public virtual bool invulnerable { get; set; }

Gets or sets whether the unit is invulnerable to damage. Returns true if the Invulnerable field is set, the GameObject is inactive, or if force invulnerability is enabled and the unit is a hero. Setting this property directly modifies the Invulnerable field.


public float T { get; set; }

Gets the frame-independent time value used for animations and movement calculations. If the internal time field is 0, returns the current delta time clamped to a maximum of 0.03334f (30 FPS). Otherwise returns the stored time value.


Fields

public ActionState _actionState

Public backing field for the actionState property. Stores the current action state (e.g., Dead, Idle) of the unit. Part of the main state machine system.


protected int _frame

Protected backing field for the frame property. Stores the current animation frame number for this unit.


public BloodColor bloodColor

The color of blood particles emitted when this unit takes damage. Enum values include Red (default), Green (alien), Oil (mechanical), Ash (fire), and Blue_Flash (special).


public bool canDisembowel

Flag determining whether this unit can be disemboweled for gruesome death animations. Used by the CanDisembowel property which adds special handling for shielded units.


public bool flash

Controls whether the unit should flash white when taking damage. Used for visual feedback to indicate the unit has been hit.


private bool Invulnerable

Private backing field for the invulnerable property. Controls whether the unit can take damage. Used in conjunction with other invulnerability conditions.


public bool isHellEnemy

Flag marking this unit as a Hell-themed enemy. Affects enemy behavior, scoring systems, and potentially damage resistances or special abilities.


protected bool isZombie

Protected flag indicating whether this unit is an undead/zombie type. Affects AI behavior and potentially damage resistance or animation sets.


public Unit skinnedPrefab

Reference to an alternate "skinned" version of this unit prefab. Used to spawn a flayed variant when the unit dies from specific damage types or conditions.


public bool useImpaledFrames

Determines whether the unit should use special impaled animation frames when impaled on spikes or other objects. Enables death-specific animations.


Input & Control

Methods

public virtual bool AnyInput()

Checks whether the unit is receiving any input from a controller or AI. Base implementation always returns false. Override in derived classes to detect input.

Returns:

  • bool: True if any input is detected, false otherwise.

public virtual bool IsPressingDown()

Checks whether the unit is pressing the down input direction. Base implementation returns false. Override in controllable units to check actual input state.

Returns:

  • bool: True if pressing down, false otherwise.

public virtual bool IsPressingLeftOrRight()

Checks whether the unit is pressing left or right directional input. Base implementation returns false. Override in controllable units to check actual horizontal input state.

Returns:

  • bool: True if pressing left or right, false otherwise.

Environmental Interaction

Methods

public virtual void AttachToZipline(ZipLine zipLine)

Attaches the unit to a zipline for traversal. Sets the attachedToZipline field to the provided zipline reference.

Parameters:

  • ZipLine zipLine: The zipline to attach to.

protected virtual bool IsSubmergedInPool()

Checks whether the unit is currently standing in a blood pool. Returns true if the block the unit is standing on has a blood pool above it.

Returns:

  • bool: True if submerged in a blood pool, false otherwise.

public virtual void RollOnto(int direction)

Handles the unit being rolled onto by another object. Base implementation is empty. Override in derived classes to implement crushing or rolling interactions.

Parameters:

  • int direction: The direction of the rolling object (-1 for left, 1 for right).

public void SuspendFromRope()

Suspends the unit from a rope by instantiating a PredabroRope object from the Map's prefab and setting it up with this unit.


Fields

protected Spikes barbedWireWithin

Protected reference to barbed wire (Spikes object) that the unit is currently in contact with. Used for environmental damage and movement restriction from barbed wire hazards.


public Block blockCurrentlyStandingOn

Reference to the terrain Block that this unit is currently standing on. Used for ground detection and environmental hazard checks like blood pools.


protected bool submergedInPool

Protected flag tracking whether the unit is currently standing in a blood pool. Set based on the block the unit is standing on having a blood pool above it.


public float submergedOffset = 8f

The Z-axis offset applied when the unit is submerged in a blood pool. Defaults to 8 units. Creates a visual depth effect by adjusting the unit's rendering layer.


Status Effects

Methods

public virtual void Blind()

Applies a blind status effect to the unit for the specified duration. Base implementation is empty. Override in derived classes to implement vision impairment effects.

Parameters:

  • float time: The duration of the blind effect in seconds.

public virtual void Blind()

Applies a blind status effect to the unit with a default duration. Base implementation is empty. Override in derived classes to implement vision impairment effects.


public virtual bool CanFreeze()

Checks whether this unit can be affected by freeze effects. Base implementation returns false, providing freeze immunity by default. Override to allow freezing.

Returns:

  • bool: True if the unit can be frozen, false otherwise.

public virtual void Dance(float time)

Forces the unit to dance for the specified duration as a crowd control effect. Base implementation is empty. Override in derived classes to implement dancing animations and behavior.

Parameters:

  • float time: The duration of the dance effect in seconds.

public virtual void Freeze(float time)

Applies a freeze status effect to the unit for the specified duration. Base implementation is empty. Override in derived classes to implement freezing mechanics and visuals.

Parameters:

  • float time: The duration of the freeze effect in seconds.

public virtual bool IsBlind()

Checks whether the unit is currently affected by a blind status effect. Base implementation always returns false. Override in derived classes to return actual blind state.

Returns:

  • bool: True if the unit is blinded, false otherwise.

public virtual bool IsIncapacitated()

Checks whether the unit is currently incapacitated and unable to act. Base implementation always returns false. Override in derived classes to implement incapacitation logic.

Returns:

  • bool: True if incapacitated, false otherwise.

public virtual void Panic(int direction, float time, bool forgetPlayer)

Causes the unit to panic, affecting its AI behavior. Base implementation is empty. Override in derived classes to implement panic behavior.

Parameters:

  • bool forgetPlayer: Whether the unit should forget its current target player.

public virtual void Panic(int direction, float time, bool forgetPlayer)

Causes the unit to panic for a specified duration. Base implementation is empty. Override in derived classes to implement timed panic behavior.

Parameters:

  • float time: The duration of the panic effect in seconds.
  • bool forgetPlayer: Whether the unit should forget its current target player.

public virtual void Panic(int direction, float time, bool forgetPlayer)

Causes the unit to panic in a specific direction for a specified duration. Base implementation is empty. Override in derived classes to implement directional panic behavior.

Parameters:

  • int direction: The direction to panic in (-1 for left, 1 for right).
  • float time: The duration of the panic effect in seconds.
  • bool forgetPlayer: Whether the unit should forget its current target player.

public virtual void RecoverFromInsemination()

Allows the unit to recover from alien insemination status. Base implementation is empty. Override in units that can be inseminated to implement recovery logic.


public virtual void Stun()

Applies a stun status effect to the unit for the specified duration, preventing actions. Base implementation is empty. Override in derived classes to implement stun behavior.

Parameters:

  • float time: The duration of the stun effect in seconds.

public virtual void Stun()

Applies a stun status effect to the unit with a default duration. Base implementation is empty. Override in derived classes to implement stun behavior.


public virtual void TearGas(float time)

Applies a tear gas status effect to the unit for the specified duration. Base implementation is empty. Override in derived classes to implement tear gas effects like impaired vision and movement.

Parameters:

  • float time: The duration of the tear gas effect in seconds.

public virtual void Terrify()

Applies a terrify effect to the unit, likely more intense than panic. Base implementation is empty. Override in derived classes to implement terror behavior.


Unit Management

Methods

public virtual bool Activate()

Activates the unit, enabling its functionality. Base implementation always returns true indicating success. Override to implement activation logic.

Returns:

  • bool: True if activation was successful, false otherwise.

public virtual bool CanBeThrown()

Determines whether this unit can be thrown by other units. Returns the inverse of IsHeavy() - units that are not heavy can be thrown.

Returns:

  • bool: True if the unit can be thrown, false if too heavy.

public virtual bool CanHeadShot()

Determines whether this unit can receive headshot damage. Base implementation returns true. Override to disable headshot vulnerability for specific units.

Returns:

  • bool: True if the unit can be headshot, false otherwise.

public virtual bool CanPilotUnit(int newPlayerNum)

Determines whether this unit can pilot another unit (such as vehicles or mechs). Base implementation returns false. Override in units capable of piloting to implement eligibility checks.

Parameters:

  • int newPlayerNum: The player number attempting to pilot.

Returns:

  • bool: True if this unit can pilot other units, false otherwise.

public virtual void CheckDestroyed()

Checks whether the unit should be destroyed or removed from the game. Base implementation is empty. Override in derived classes to implement destruction conditions.


public virtual bool Deactivate()

Deactivates the unit, disabling its functionality. Base implementation always returns true indicating success. Override to implement deactivation logic.

Returns:

  • bool: True if deactivation was successful, false otherwise.

public virtual void DestroyCharacter()

Destroys this unit's game object, removing it from the game. Can be overridden to implement custom destruction behavior or cleanup.


public virtual void DischargePilotingUnit(float x, float y, float xI, float yI, bool stunUnit)

Ejects the pilot from this unit at the specified position and velocity. Base implementation is empty. Override in pilotable units to implement pilot ejection mechanics.

Parameters:

  • float x: The X position where the pilot should be ejected.
  • float y: The Y position where the pilot should be ejected.
  • float xI: The horizontal velocity to apply to the ejected pilot.
  • float yI: The vertical velocity to apply to the ejected pilot.
  • bool stunUnit: Whether to stun the pilot upon ejection.

public virtual float GetFuel()

Returns the current fuel level of the unit. Base implementation returns 0. Override in fuel-consuming units like vehicles or jetpack units to return actual fuel amount.

Returns:

  • float: The current fuel level as a float value.

public virtual bool GetFuelWarning()

Checks whether the unit's fuel is low enough to display a warning. Base implementation returns false. Override in fuel-consuming units to implement low fuel detection.

Returns:

  • bool: True if fuel is critically low, false otherwise.

public virtual MookType GetMookType()

Returns the type of mook (enemy) this unit represents. Base implementation returns MookType.None. Override in enemy units to return specific mook type.

Returns:

  • MookType: The MookType enum value for this unit.

public virtual Unit GetPilottedUnit()

Returns the unit currently being piloted by this unit. Base implementation returns null. Override in pilot-capable units to return the actual piloted unit reference.

Returns:

  • Unit: The piloted unit, or null if not piloting anything.

public virtual bool IsDecapitated()

Checks whether the unit has been decapitated (head removed). Base implementation returns false. Override in units that can be decapitated to track headless state.

Returns:

  • bool: True if decapitated, false otherwise.

public virtual bool IsEvil()

Determines whether this unit is an evil/enemy character. Base implementation returns false. Override in enemy units to return true.

Returns:

  • bool: True if the unit is evil, false otherwise.

public virtual bool IsHeavy()

Determines whether this unit is too heavy for certain interactions like throwing. Base implementation returns false. Override in heavy units to return true.

Returns:

  • bool: True if the unit is heavy, false otherwise.

public virtual void OpenParachute()

Opens the unit's parachute for controlled descent. Base implementation is empty. Override in derived classes to implement parachute deployment.


public virtual void PilotUnit(Unit pilotUnit)

Initiates the piloting of this unit by another unit. Only processes if the piloting unit belongs to the local player and sends RPC to synchronize the piloting state across all players.

Parameters:

  • Unit pilotUnit: The unit that will pilot this unit.

public virtual void PilotUnitRPC(Unit newPilotUnit)

Remote procedure call handler for synchronizing pilot unit changes across the network. Base implementation is empty. Override in pilotable units to handle the pilot assignment.

Parameters:

  • Unit newPilotUnit: The new pilot unit to assign.

public virtual bool Revive(int playerNum, bool isUnderPlayerControl, TestVanDammeAnim reviveSource)

Attempts to revive this unit from death or incapacitation. Base implementation returns false. Override in revivable units to implement revival mechanics.

Parameters:

  • int playerNum: The player number who will control the revived unit.
  • bool isUnderPlayerControl: Whether the revived unit will be under player control.
  • TestVanDammeAnim reviveSource: The unit performing the revival.

Returns:

  • bool: True if revival was successful, false otherwise.

public virtual void ReviveRPC(int playerNum, bool isUnderPlayerControl, TestVanDammeAnim reviveSource)

Remote procedure call for synchronizing unit revival across the network. Calls the local Revive method with the provided parameters.

Parameters:

  • int playerNum: The player number who will control the revived unit.
  • bool isUnderPlayerControl: Whether the revived unit will be under player control.
  • TestVanDammeAnim reviveSource: The unit performing the revival.

public virtual void SetCanParachute(bool canParachute)

Enables the unit's ability to use a parachute. Calls SetCanParachute(true) internally.


public virtual void SetCanParachute(bool canParachute)

Sets whether the unit can use a parachute. Base implementation is empty. Override in derived classes to implement parachute capability toggling.

Parameters:

  • bool canParachute: True to enable parachute capability, false to disable.

public virtual void SetFriendlyExplosion()

Marks explosions created by this unit as friendly, preventing them from damaging allies. Base implementation is empty. Override to implement friendly fire prevention.


public virtual void SetImmuneToOutOfBounds()

Makes the unit immune to out-of-bounds death. Base implementation is empty. Override to implement immunity to boundary-based destruction.


public virtual void StartPilotingUnit(Unit pilottedUnit)

Called when this unit begins piloting another unit. Base implementation is empty. Override in units that can pilot to implement pilot initialization logic.

Parameters:

  • Unit pilottedUnit: The unit that this unit is starting to pilot.

public virtual bool TryConnectHighFive()

Attempts to connect a high-five with another unit. Base implementation always returns false. Override in player units to enable high-five connections.

Returns:

  • bool: True if high-five was successful, false otherwise.

public virtual Vector3 WhereDidIDie()

Returns the position where this unit died. Base implementation returns the current transform position. Override to return a stored death location if needed.

Returns:

  • Vector3: The 3D position where the unit died.

Properties

public bool IsNotReplicantHero { get; set; }

Gets whether this unit is not a replicated hero from another player. Returns true if the unit belongs to the local player or if it's not a hero unit. Used for network replication logic.


Fields

public bool beingControlledByTriggerAction

Flag indicating this unit is under scripted control from a trigger action. When true, normal AI behavior is suspended.


public CharacterAction controllingTriggerAction

Reference to the CharacterAction that is currently controlling this unit through scripted sequences. Null when under normal AI control.


AI Awareness

Methods

public virtual void Alert(float alertX, float alertY)

Alerts the unit to activity at specific coordinates, raising its awareness level. Base implementation is empty. Override in derived classes to implement alert behavior.

Parameters:

  • float alertX: The X coordinate of the alert source.
  • float alertY: The Y coordinate of the alert source.

public virtual void Attract(float xTarget, float yTarget)

Attracts the unit's attention to specific coordinates, affecting AI targeting and movement. Base implementation is empty. Override in derived classes to implement attraction behavior.

Parameters:

  • float xTarget: The X coordinate to be attracted to.
  • float yTarget: The Y coordinate to be attracted to.

public virtual void FetchObject(Transform fetchObject)

Allows the unit to fetch or pick up an object. Base implementation is empty. Override in derived classes to implement object fetching behavior.

Parameters:

  • Transform fetchObject: The transform of the object to fetch.

public virtual void ForgetPlayer(int deadPlayerNum)

Removes a dead player from the unit's memory and targeting system. Base implementation is empty. Override in derived classes to implement AI memory management.

Parameters:

  • int deadPlayerNum: The player number to forget.

public virtual void FullyAlert(float x, float y, int playerNum)

Fully alerts the unit to a specific player's presence at given coordinates, maximizing awareness. Base implementation is empty. Override in derived classes to implement full alert behavior.

Parameters:

  • float x: The X coordinate of the player.
  • float y: The Y coordinate of the player.
  • int playerNum: The player number that triggered the full alert.

public virtual void HearSound(float alertX, float alertY)

Allows the unit to respond to sounds at specific coordinates. Base implementation is empty. Override in derived classes to implement sound-based AI awareness.

Parameters:

  • float alertX: The X coordinate of the sound source.
  • float alertY: The Y coordinate of the sound source.

public virtual void RunWarning(float t, float explosionTime)

Provides warning to the unit about an incoming explosion. Base implementation is empty. Override in derived classes to implement evasion or protective behavior.

Parameters:

  • float t: The current time or progress value.
  • float explosionTime: The time until the explosion occurs.

public virtual void SetTargetPlayerNum(int pN, Vector3 TargetPosition)

Sets the target player number and position for AI targeting. Base implementation is empty. Override in AI-controlled units to implement targeting behavior.

Parameters:

  • int pN: The player number to target.
  • Vector3 TargetPosition: The 3D position of the target.

Fields

public bool canHear = true

Master toggle for the unit's hearing ability. Defaults to true. When false, the unit ignores all sound-based alerts regardless of range.


public float hearingRangeX = 300f

The horizontal range in game units within which this unit can hear sounds and become alerted. Defaults to 300 units. Used by the AI detection system.


public float hearingRangeY = 200f

The vertical range in game units within which this unit can hear sounds and become alerted. Defaults to 200 units. Used by the AI detection system.


Helper & Utility

Fields

public bool showDebugInfoForThisEnemy = true

Controls whether debug information is displayed for this specific unit. Defaults to true. Useful for debugging individual unit behavior.


Alien Infection System

Methods

public virtual bool CanInseminate(float xI, float yI)

Checks whether this unit can be inseminated by an alien facehugger at the given velocity. Base implementation returns false. Override in units that can be infected to implement eligibility checks.

Parameters:

  • float xI: The horizontal velocity of the insemination attempt.
  • float yI: The vertical velocity of the insemination attempt.

Returns:

  • bool: True if the unit can be inseminated, false otherwise.

public virtual bool Inseminate(AlienFaceHugger unit, float xForce, float yForce)

Attempts to inseminate this unit with an alien facehugger. Base implementation returns false. Override in units that can be infected to implement insemination mechanics.

Parameters:

  • AlienFaceHugger unit: The AlienFaceHugger attempting to inseminate.
  • float xForce: The horizontal force applied during insemination.
  • float yForce: The vertical force applied during insemination.

Returns:

  • bool: True if insemination was successful, false otherwise.

Acid Coverage System

Methods

public virtual bool HasBeenCoveredInAcid()

Checks whether the unit has been covered in acid and has the acid status effect. Base implementation returns false. Override in units that can be affected by acid.

Returns:

  • bool: True if covered in acid, false otherwise.

public virtual void RemoveAcid()

Removes the acid status effect from the unit. Base implementation is empty. Override in units that can be affected by acid to implement acid removal logic.