Rechargeable Magazine
The RechargeableMagazine
is an energy-style magazine that regenerates ammo over time instead of using manual reload input. It’s ideal for energy guns, plasma rifles, or futuristic beam weapons.
Summary
This component:
- Regenerates ammo passively
- Triggers reload start and complete events
- Works well with weapons that overheat or recharge between bursts
Fields
Field | Type | Description |
---|---|---|
_rechargeRate | float | How many clip units are restored per second. |
clip | float (inherited) | Current amount of ammo. |
clipSize | float (inherited) | Maximum ammo capacity. |
Public Methods
Method | Description |
---|---|
override void Reload() | Begins the recharge coroutine. |
void CompleteReload() | Manually calls OnReloadComplete if needed. |
Private Methods
Method | Description |
---|---|
void CheckReload() | Triggers OnStartReload if the clip isn’t full. |
IEnumerator ReloadRoutine() | Regenerates ammo over time until full or disabled. |
Behavior
- The script listens for
barrel._OnEndShooting
to check if a recharge should be triggered. - Ammo restores at a fixed rate using
WaitForSeconds
. - When the clip is full,
OnReloadComplete
is invoked. - Works only when the weapon is in a
Resting
state.
Events
Event | Trigger |
---|---|
OnStartReload | When recharge begins (clip < full) |
OnReloadComplete | When clip becomes full |
OnDepleted | When clip reaches zero |
Use Case Example
- Plasma rifle with steady regen
- Beam cannon with slow, continuous energy return
- Weapons without a reload key but require downtime
Note
This component does not require player input and works automatically.
Tip
You can customize recharge VFX using OnStartReload
and OnReloadComplete
.