protected override IEnumerator <float> _Reload(IClip clip, Func <int> getReserveAmmo, Action <int> callback) { while (true) { yield return(Timing.WaitForSeconds(reloadDurationPerPump)); if (getReserveAmmo() <= 0) { yield break; } int ammoUsed = clip.TryFillAmmo(Mathf.Min(getReserveAmmo(), ammoReloadedPerPump)); callback(ammoUsed); if (clip.IsFull()) { yield break; } } }
//onReloaded not to be confused with UnityEvent onReloadFinished. onReloaded is called internally protected override IEnumerator<float> _Reload(IClip clip, Func<int> ammoInReserve, System.Action<int> callback) { yield return Timing.WaitForSeconds(reloadDuration); int ammoUsed = clip.TryFillAmmo(ammoInReserve()); callback(ammoUsed); }