Bullet Magazines

The BulletMagazine is a clip-based magazine with support for manual and automatic reload. It extends the abstract Magazine base and is commonly used for ballistic weapons like rifles and pistols.

Summary

This component:

  • Uses a clip-based ammo system
  • Supports timed reload with events
  • Optionally resumes shooting if interrupted
  • Handles player reload input

Fields

FieldTypeDescription
_autoReloadboolIf true, the magazine reloads automatically when empty.
_reloadTimefloatDuration of the reload in seconds.
_waitRoutineCoroutineCoroutine handler for timed reloads. (Runtime only)

Inherited Fields

See Magazine for:

  • _clip, _clipSize, weapon
  • events.OnDepleted, events.OnStartReload, events.OnReloadComplete

Public Methods

MethodDescription
override void Reload()Starts the reload process, invoking events and managing timing.
override bool IsDepleted()Checks if the clip is empty and optionally auto-reloads.

Private Methods

MethodDescription
CompleteReload()Resets clip, resumes shooting if auto-reloading a full-auto weapon whose trigger is still held, and fires events.

Input Behavior

  • The magazine no longer reads input. The weapon’s Reload input calls Weapon.Reload(), which calls the magazine’s Reload().

Reload Flow

  1. Player presses reload key (or auto-reload is triggered).
  2. The weapon stops shooting and enters the Reloading state.
  3. Events:
    • OnStartReload is called immediately.
    • After _reloadTime, clip is refilled.
    • OnReloadComplete is called.
  4. With Auto Reload on a full-auto weapon, firing resumes if the trigger is still held.

Tip

You can bind SFX, VFX, or animations to OnStartReload and OnReloadComplete.

Warning

Don’t forget to disable reloading logic for energy-based weapons that use charging instead.

See Also