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

FieldTypeDescription
_rechargeRatefloatHow many clip units are restored per second.
clipfloat (inherited)Current amount of ammo.
clipSizefloat (inherited)Maximum ammo capacity.

Public Methods

MethodDescription
override void Reload()Begins the recharge coroutine.
void CompleteReload()Manually calls OnReloadComplete if needed.

Private Methods

MethodDescription
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

EventTrigger
OnStartReloadWhen recharge begins (clip < full)
OnReloadCompleteWhen clip becomes full
OnDepletedWhen 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.

See Also