ProjectileController - alexneargarder/Broforce-Docs GitHub Wiki

ProjectileController

Table of Contents

Unity Lifecycle & Setup

Methods

private void Awake()

Unity's Awake method that initializes mathematical lookup tables when the ProjectileController is first created.


Properties

public static ProjectileController instance { get; set; }

Gets the singleton instance of ProjectileController. Uses lazy initialization to find or create the instance when first accessed.


Fields

private static ProjectileController inst

Private static field that stores the singleton instance of ProjectileController.


Projectile Spawning

Methods

public static Grenade SpawnGrenadeLocally(Grenade grenadePrefab, MonoBehaviour firedBy, float x, float y, float radius, float force, float xI, float yI, int playerNum, int seed)

Spawns a grenade locally without network synchronization. Sets up the grenade with physics parameters and launches it.

Parameters:

  • Grenade grenadePrefab: The grenade prefab to instantiate.
  • MonoBehaviour firedBy: The MonoBehaviour that threw this grenade.
  • float x: The X position to spawn the grenade.
  • float y: The Y position to spawn the grenade.
  • float radius: The explosion radius of the grenade (passed to SetupGrenade but actual usage depends on grenade type).
  • float force: The explosion force of the grenade (passed to SetupGrenade but actual usage depends on grenade type).
  • float xI: The initial X velocity of the grenade.
  • float yI: The initial Y velocity of the grenade.
  • int playerNum: The player number who owns this grenade.
  • int seed: Random seed for deterministic grenade behavior.

Returns:

  • Grenade: The spawned Grenade instance.

public static Grenade SpawnGrenadeOverNetwork(Grenade grenadePrefab, MonoBehaviour firedBy, float x, float y, float radius, float force, float xI, float yI, int playerNum, float lifeM = 1f)

Spawns a grenade across the network for multiplayer synchronization. Creates the grenade and sends RPCs to set it up and launch it on all clients. Note: Network functionality may not work reliably in mods.

Parameters:

  • Grenade grenadePrefab: The grenade prefab to instantiate.
  • MonoBehaviour firedBy: The MonoBehaviour that threw this grenade.
  • float x: The X position to spawn the grenade.
  • float y: The Y position to spawn the grenade.
  • float radius: The explosion radius (usage depends on grenade type).
  • float force: The explosion force (usage depends on grenade type).
  • float xI: The initial X velocity of the grenade.
  • float yI: The initial Y velocity of the grenade.
  • int playerNum: The player number who owns this grenade.
  • float lifeM: Life multiplier for the grenade. Values less than 1 reduce the grenade's fuse time.

Returns:

  • Grenade: The spawned Grenade instance.

public static LaserBeam SpawnLaserBeamLocally(LaserBeam prefab, MonoBehaviour FiredBy, float x, float y, float z, float angle, float duration, float rotateSpeed, int playerNum)

Spawns a laser beam locally without network synchronization. Creates a laser beam with specified angle and rotation parameters.

Parameters:

  • LaserBeam prefab: The laser beam prefab to instantiate.
  • MonoBehaviour FiredBy: The MonoBehaviour that created this laser beam.
  • float x: The X position to spawn the laser beam.
  • float y: The Y position to spawn the laser beam.
  • float z: The Z position to spawn the laser beam.
  • float angle: The initial angle of the laser beam in degrees.
  • float duration: How long the laser beam should last in seconds.
  • float rotateSpeed: The rotation speed of the laser beam in degrees per second.
  • int playerNum: The player number who owns this laser beam.

Returns:

  • LaserBeam: The spawned LaserBeam instance.

public static LaserBeam SpawnLaserBeamOverNetwork(LaserBeam prefab, MonoBehaviour FiredBy, float x, float y, float z, float duration, Transform target, bool synced, int playerNum, bool executeImmediately)

Spawns a laser beam across the network for multiplayer synchronization. Can target a specific transform. Note: Network functionality may not work reliably in mods.

Parameters:

  • LaserBeam prefab: The laser beam prefab to instantiate.
  • MonoBehaviour FiredBy: The MonoBehaviour that created this laser beam.
  • float x: The X position to spawn the laser beam.
  • float y: The Y position to spawn the laser beam.
  • float z: The Z position to spawn the laser beam.
  • float duration: How long the laser beam should last in seconds.
  • Transform target: Optional transform for the laser to track/target.
  • bool synced: Whether to enable continuous network synchronization.
  • int playerNum: The player number who owns this laser beam.
  • bool executeImmediately: Whether to execute the network commands immediately.

Returns:

  • LaserBeam: The spawned LaserBeam instance.

public static Projectile SpawnProjectileLocally(Projectile prefab, MonoBehaviour FiredBy, float x, float y, float xI, float yI, bool synced, int playerNum, bool AddTemporaryPlayerTarget, bool executeImmediately, float _zOffset)

Spawns a projectile locally without network synchronization. This is the simplest overload for local projectile creation.

Parameters:

  • Projectile projectilePrefab: The projectile prefab to instantiate.
  • MonoBehaviour FiredBy: The MonoBehaviour that fired this projectile (usually the character or weapon).
  • float x: The X position to spawn the projectile.
  • float y: The Y position to spawn the projectile.
  • float xI: The initial X velocity of the projectile.
  • float yI: The initial Y velocity of the projectile.
  • int playerNum: The player number who owns this projectile.

Returns:

  • Projectile: The spawned Projectile instance.

public static Projectile SpawnProjectileLocally(Projectile prefab, MonoBehaviour FiredBy, float x, float y, float xI, float yI, bool synced, int playerNum, bool AddTemporaryPlayerTarget, bool executeImmediately, float _zOffset)

Spawns a projectile locally with additional z-offset control. The AddTemporaryPlayerTarget parameter appears to be unused in this overload.

Parameters:

  • Projectile prefab: The projectile prefab to instantiate.
  • MonoBehaviour FiredBy: The MonoBehaviour that fired this projectile.
  • float x: The X position to spawn the projectile.
  • float y: The Y position to spawn the projectile.
  • float xI: The initial X velocity of the projectile.
  • float yI: The initial Y velocity of the projectile.
  • int playerNum: The player number who owns this projectile.
  • bool AddTemporaryPlayerTarget: Unused parameter in this overload.
  • float _zOffset: The Z-axis offset for the projectile spawn position.

Returns:

  • Projectile: The spawned Projectile instance.

public static Projectile SpawnProjectileLocally(Projectile prefab, MonoBehaviour FiredBy, float x, float y, float xI, float yI, bool synced, int playerNum, bool AddTemporaryPlayerTarget, bool executeImmediately, float _zOffset)

Spawns a projectile locally with all available parameters. The synced, AddTemporaryPlayerTarget, and executeImmediately parameters appear to be unused in local spawning.

Parameters:

  • Projectile prefab: The projectile prefab to instantiate.
  • MonoBehaviour FiredBy: The MonoBehaviour that fired this projectile.
  • float x: The X position to spawn the projectile.
  • float y: The Y position to spawn the projectile.
  • float xI: The initial X velocity of the projectile.
  • float yI: The initial Y velocity of the projectile.
  • bool synced: Unused parameter in local spawning.
  • int playerNum: The player number who owns this projectile.
  • bool AddTemporaryPlayerTarget: Unused parameter in local spawning.
  • bool executeImmediately: Unused parameter in local spawning.
  • float _zOffset: The Z-axis offset for the projectile spawn position.

Returns:

  • Projectile: The spawned Projectile instance.

public static Projectile SpawnProjectileOverNetwork(Projectile prefab, MonoBehaviour FiredBy, float x, float y, float xI, float yI, bool synced, int playerNum, bool AddTemporaryPlayerTarget, bool executeImmediately, float _zOffset)

Spawns a projectile across the network for multiplayer synchronization. Creates the projectile and sends RPCs to synchronize its state across all players. Note: Network functionality may not work reliably in mods.

Parameters:

  • Projectile prefab: The projectile prefab to instantiate.
  • MonoBehaviour FiredBy: The MonoBehaviour that fired this projectile.
  • float x: The X position to spawn the projectile.
  • float y: The Y position to spawn the projectile.
  • float xI: The initial X velocity of the projectile.
  • float yI: The initial Y velocity of the projectile.
  • bool synced: Whether to enable continuous network synchronization for this projectile.
  • int playerNum: The player number who owns this projectile.
  • bool AddTemporaryPlayerTarget: Whether to add this projectile as a temporary target for the specified player.
  • bool executeImmediately: Whether to execute the network commands immediately or queue them.
  • float _zOffset: The Z-axis offset for the projectile spawn position.

Returns:

  • Projectile: The spawned Projectile instance.

public static void SummonPortalNetworked(WarlockPortal portalPrefab, int seenPlayerNum, Vector2 spawnPos, float delay)

Spawns a warlock portal across the network with a delay. Only creates the portal if spawnPos is not Vector2.zero. Note: Network functionality may not work reliably in mods.

Parameters:

  • WarlockPortal portalPrefab: The warlock portal prefab to instantiate.
  • int seenPlayerNum: The player number associated with this portal.
  • Vector2 spawnPos: The position to spawn the portal. Portal is not created if this is Vector2.zero.
  • float delay: Delay in seconds before the portal activates.

Projectile Return System

Methods

public static bool CheckReturnZone(float x, float y, ref int playerNum, ref ProjectileReturnZone returnZone, ref MonoBehaviour zoneFiredBy)

Checks if a position is within any registered return zone. If found, updates the projectile ownership and provides zone information. Return zones only affect projectiles from different players.

Parameters:

  • float x: The X position to check.
  • float y: The Y position to check.
  • out int playerNum: The current player number of the projectile. Updated to the zone's player number if a zone is found.
  • out ProjectileReturnZone returnZone: Output parameter that receives the ProjectileReturnZone if one is found at the position.
  • out MonoBehaviour zoneFiredBy: Output parameter that receives the MonoBehaviour that created the return zone.

Returns:

  • bool: True if a return zone was found at the position, false otherwise.

public static void RegisterReturnZone(ProjectileReturnZone zone)

Registers a projectile return zone with the controller. Return zones can capture and redirect projectiles that enter their area.

Parameters:

  • ProjectileReturnZone zone: The ProjectileReturnZone to register.

public static void RemoveReturnZone(ProjectileReturnZone zone)

Removes a previously registered projectile return zone from the controller.

Parameters:

  • ProjectileReturnZone zone: The ProjectileReturnZone to unregister.

Fields

public List<ProjectileReturnZone> returnZones = new List<ProjectileReturnZone>()

List of all currently active projectile return zones. These zones can capture and redirect projectiles that enter their radius.


Prefab Management

Methods

public static Grenade GetAirstrikeGrenadePrefab()

Gets the airstrike grenade prefab used for calling in aerial bombardments.

Returns:

  • Grenade: The airstrike Grenade prefab.

public static Grenade GetAlienPheromoneGrenadePrefab()

Gets the alien pheromone grenade prefab used for alien-related mechanics.

Returns:

  • Grenade: The alien pheromone Grenade prefab.

public static Grenade GetMechDropGrenadePrefab()

Gets the mech drop grenade prefab used for deploying mechs.

Returns:

  • Grenade: The mech drop Grenade prefab.

Fields

public Grenade airstrikeGrenade

The grenade prefab for airstrike special abilities. Used by character abilities and perks to call in aerial bombardment at marked locations. Can be spawned with stance-based trajectories (close-range: 30 velocity/70 angle, long-range: 200 velocity/150 angle) or immediately detonated for instant strikes. Shared with SpecialAbilitiesController for consistent access.


public Grenade alienPheromoneGrenade

The grenade prefab for alien pheromone biological warfare. Creates pheromone effects that influence alien enemy behavior when detonated. Available as pocketed special ammunition pickup. Uses stance-based throwing system (crouching: 30/70 for close range, standing: 200/150 for long range) and shares animation behavior with airstrike and mech drop abilities.


public List<Grenade> allGrenadePrefabs = new List<Grenade>()

Unity Inspector field containing references to all grenade prefabs in the game. Not referenced in code but likely populated via Unity Editor for cataloging, validation, or potential editor tooling purposes. Serves as a central registry of available grenade types.


public List<Projectile> allProjectilePrefabs = new List<Projectile>()

Unity Inspector field containing references to all projectile prefabs in the game. Not referenced in code but likely populated via Unity Editor for cataloging, validation, or potential editor tooling purposes. Initialized as empty list in code.


public MatildaTarget assasinationTargetPrefab

The assassination target prefab used by Matilda for marking elimination targets.


public Projectile brobocop

The projectile prefab specifically used by Brobocop character.


public RobrocopTargetingSystem broGummerSniperTargetPrefab

The specialized sniper targeting system prefab used by Bro Gummer.


public Projectile fireBallBombardment

The projectile prefab used for fireball bombardment attacks. Used in TimePressureBombardment for Rogueforce procedural generation mode to create environmental fire hazards. Spawned at random positions and immediately detonated to create explosive fiery bombardment effects.


public Projectile goldenLightProjectile

The golden light projectile prefab, likely used for special holy or light-based attacks by specific characters or abilities.


public Grenade mechDropGrenade

The grenade prefab for mech deployment special ability. Acts as a beacon that spawns a combat mech on detonation. Part of the pocketed special ammo system - players can collect and use this to deploy mechs using stance-based throwing mechanics identical to airstrikes. Uses custom animation sequence (row 5, frames 17-24) with deployment trigger at frame 4.


public Rocket remoteRocketPrefab

The prefab for remote-controlled rockets that can be guided by the player.


public Projectile shellBombardment

The projectile prefab used for artillery shell bombardment attacks.


public FollowingObject targetPrefab

A general-purpose following object prefab that can track targets.


public RobrocopTargetingSystem targetSystemPrefab

The targeting system prefab used by Robocop for locking onto enemies.


public RemoteTeleportTarget teleportTargetPrefab

The remote teleport target prefab used for marking teleportation destinations in teleportation-based abilities and mechanics.


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