![]() |
Bullet Dynamics v1.0.0
|
Component that works with Weapon to set it's Weapon.IsShootingEnabled flag to false when the magazine is empty.
Support reloading with Reload method.
More...
Public Member Functions | |
| virtual void | Reload (float reloadDuration) |
Sets the Weapon.IsShootingEnabled to false, and calls Reload after reloadDuration . It will raise ReloadStarted event. ReloadFinished event is raised after the reload has finished. | |
| virtual void | Reload () |
Resets the bullet count to the magazine size. It will raise ReloadFinished event. This method does not raise ReloadStarted event since the reload is instant. | |
| virtual void | CancelReload () |
| Canceles the reload, activates the weapon shooting, and raises ReloadCanceled event. | |
| virtual void | SetNumberOfBulletsInMagazine (int numberOfBullets) |
| Sets the current number of bullets inside the magazine. | |
Public Attributes | |
| UnityEvent< int > | BulletCountChanged |
| Event that is raised when the bullet count changes in this WeaponMagazine. | |
| UnityEvent | ReloadStarted |
| Event that is raised when the reload starts. | |
| UnityEvent | ReloadFinished |
| Event that is raised when the reload finished. | |
| UnityEvent | ReloadCanceled |
| Event that is raised when the reload was canceled. | |
Protected Member Functions | |
| virtual void | Awake () |
| virtual void | Start () |
| virtual void | OnEnable () |
| virtual void | OnDisable () |
| virtual IEnumerator | ReloadCoroutine (float duration) |
| Coroutine that delays the ability to shoot by setting _fireRateDelayActive to false until the _fireRate delay doesn't pass. | |
| virtual void | OnWeaponShoot (Bullet firedBullet) |
Handler for the Weapon.OnShoot event. It will reduce the number of bullets inside the magazine by 1. | |
| void | StartReloadCoroutine (float duration) |
| Starts the ReloadCoroutine in a safe way (by stopping current coroutine). | |
| void | StopReloadCoroutine () |
| Stops the ReloadCoroutine. | |
Protected Attributes | |
| Weapon | _weapon |
| Coroutine | _reloadCoroutine |
Properties | |
| int | MagazineSize [get] |
| Returns the amount of bullets this magazine can hold. | |
| int | BulletsInMagazine [get] |
| Returns the current amount of bullets inside this magazine. | |
Component that works with Weapon to set it's Weapon.IsShootingEnabled flag to false when the magazine is empty.
Support reloading with Reload method.
Definition at line 13 of file WeaponMagazine.cs.
|
protectedvirtual |
Definition at line 48 of file WeaponMagazine.cs.
|
virtual |
Canceles the reload, activates the weapon shooting, and raises ReloadCanceled event.
Definition at line 95 of file WeaponMagazine.cs.
|
protectedvirtual |
Definition at line 63 of file WeaponMagazine.cs.
|
protectedvirtual |
Definition at line 58 of file WeaponMagazine.cs.
|
protectedvirtual |
Handler for the Weapon.OnShoot event.
It will reduce the number of bullets inside the magazine by 1.
Definition at line 130 of file WeaponMagazine.cs.
|
virtual |
Resets the bullet count to the magazine size.
It will raise ReloadFinished event.
This method does not raise ReloadStarted event since the reload is instant.
Definition at line 86 of file WeaponMagazine.cs.
|
virtual |
Sets the Weapon.IsShootingEnabled to false, and calls Reload after reloadDuration .
It will raise ReloadStarted event.
ReloadFinished event is raised after the reload has finished.
| reloadDuration | Delay between this call and the actual reload of the magazine. |
Definition at line 75 of file WeaponMagazine.cs.
|
protectedvirtual |
Coroutine that delays the ability to shoot by setting _fireRateDelayActive to false until the _fireRate delay doesn't pass.
Definition at line 117 of file WeaponMagazine.cs.
|
virtual |
Sets the current number of bullets inside the magazine.
| numberOfBullets | Number of bullets that will be inside the magazine. |
Definition at line 106 of file WeaponMagazine.cs.
|
protectedvirtual |
Definition at line 53 of file WeaponMagazine.cs.
|
protected |
Starts the ReloadCoroutine in a safe way (by stopping current coroutine).
Definition at line 139 of file WeaponMagazine.cs.
|
protected |
Stops the ReloadCoroutine.
Definition at line 148 of file WeaponMagazine.cs.
|
protected |
Definition at line 19 of file WeaponMagazine.cs.
|
protected |
Definition at line 17 of file WeaponMagazine.cs.
| UnityEvent<int> BulletDynamics.Weapons.WeaponMagazine.BulletCountChanged |
Event that is raised when the bullet count changes in this WeaponMagazine.
Definition at line 34 of file WeaponMagazine.cs.
| UnityEvent BulletDynamics.Weapons.WeaponMagazine.ReloadCanceled |
Event that is raised when the reload was canceled.
Definition at line 46 of file WeaponMagazine.cs.
| UnityEvent BulletDynamics.Weapons.WeaponMagazine.ReloadFinished |
Event that is raised when the reload finished.
Definition at line 42 of file WeaponMagazine.cs.
| UnityEvent BulletDynamics.Weapons.WeaponMagazine.ReloadStarted |
Event that is raised when the reload starts.
Definition at line 38 of file WeaponMagazine.cs.
|
get |
Returns the current amount of bullets inside this magazine.
Definition at line 29 of file WeaponMagazine.cs.
|
get |
Returns the amount of bullets this magazine can hold.
Definition at line 24 of file WeaponMagazine.cs.