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
| Field | Type | Description |
|---|---|---|
_autoReload | bool | If true, the magazine reloads automatically when empty. |
_reloadTime | float | Duration of the reload in seconds. |
_waitRoutine | Coroutine | Coroutine handler for timed reloads. (Runtime only) |
Inherited Fields
See Magazine for:
_clip,_clipSize,weaponevents.OnDepleted,events.OnStartReload,events.OnReloadComplete
Public Methods
| Method | Description |
|---|---|
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
| Method | Description |
|---|---|
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
Reloadinput callsWeapon.Reload(), which calls the magazine’sReload().
Reload Flow
- Player presses reload key (or auto-reload is triggered).
- The weapon stops shooting and enters the
Reloadingstate. - Events:
OnStartReloadis called immediately.- After
_reloadTime, clip is refilled. OnReloadCompleteis called.
- 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.