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. |
reloadable | bool | If false, disables manual reloading. |
_controls | WeaponControls | Input bindings for reload input. (Runtime only) |
_waitRoutine | Coroutine | Coroutine handler for timed reloads. (Runtime only) |
Inherited Fields
See Magazine
for:
clip
,clipSize
OnDepleted
,OnStartReload
,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(bool wasShooting) | Resets clip, optionally resumes shooting, and fires events. |
Input Behavior
- Listens to the
Reload
input from theWeaponControls
input map. - Only active if
reloadable == true
.
Reload Flow
- Player presses reload key (or auto-reload is triggered).
- Events:
OnStartReload
is called immediately.- After
reloadTime
, clip is refilled. OnReloadComplete
is called.
- If the weapon was shooting when reload started, it resumes firing automatically.
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.