Bullet Dynamics v1.0.0
Loading...
Searching...
No Matches
BulletDynamics.Weapons.Weapon Class Reference


Component that allows the object to shoot the Bullets using Shoot method.
It supports fire rate setting which limits the Shoot method until the FireRate delay has been met. More...

Public Member Functions

virtual void Shoot ()
 
Method that will create a new Bullet and shoot it from the OutputPoint.
It will raise the OnShoot action after the bullet has been created.
 
virtual void SetIsShootingEnabled (bool isEnabled)
 Sets the flag that blocks the Shoot method if the flag is set to false.
 
virtual void SetFireRate (float newFireRate)
 Sets the newFireRate to the weapon.
 

Public Attributes

UnityEvent< BulletOnShoot
 Event that is raised when this weapon has shot a Bullet.
 

Protected Member Functions

virtual IEnumerator FireRateLimitCoroutine ()
 Coroutine that delays the ability to shoot by setting _fireRateDelayActive to false until the _fireRate delay doesn't pass.
 
void StartFireRateLimitCoroutine ()
 Starts the FireRateLimitCoroutine in a safe way (by stopping current coroutine).
 
void StopFireRateLimitCoroutine ()
 Stops the FireRateLimitCoroutine.
 

Protected Attributes

float _fireRate = 10f
 
Transform _outputPoint = default
 
BulletData _bulletData = default
 
bool _fireRateDelayActive = true
 
bool _isShootingEnabled = true
 
Coroutine _fireRateLimitCoroutine = null
 

Properties

virtual float FireRate [get]
 Fire rate of this weapon (Bullets per second).
 
virtual Transform OutputPoint [get]
 Output point from which the Bullet will be instantiated when the Shoot is called.
 
virtual BulletData BulletData [get]
 Data of the Bullet that is used by this Weapon.
 
virtual bool IsShootingEnabled [get]
 Flag that blocks the Shoot method from firing a bullet if it is set to false.
 

Detailed Description


Component that allows the object to shoot the Bullets using Shoot method.
It supports fire rate setting which limits the Shoot method until the FireRate delay has been met.

Definition at line 12 of file Weapon.cs.

Member Function Documentation

◆ FireRateLimitCoroutine()

virtual IEnumerator BulletDynamics.Weapons.Weapon.FireRateLimitCoroutine ( )
protectedvirtual

Coroutine that delays the ability to shoot by setting _fireRateDelayActive to false until the _fireRate delay doesn't pass.

Returns

Definition at line 98 of file Weapon.cs.

◆ SetFireRate()

virtual void BulletDynamics.Weapons.Weapon.SetFireRate ( float newFireRate)
virtual

Sets the newFireRate to the weapon.

Parameters
newFireRateFire rate that will be set.

Definition at line 89 of file Weapon.cs.

◆ SetIsShootingEnabled()

virtual void BulletDynamics.Weapons.Weapon.SetIsShootingEnabled ( bool isEnabled)
virtual

Sets the flag that blocks the Shoot method if the flag is set to false.

Parameters
isEnabledSet to true if the shooting should be enabled, false if not.

Definition at line 80 of file Weapon.cs.

◆ Shoot()

virtual void BulletDynamics.Weapons.Weapon.Shoot ( )
virtual


Method that will create a new Bullet and shoot it from the OutputPoint.
It will raise the OnShoot action after the bullet has been created.

Definition at line 58 of file Weapon.cs.

◆ StartFireRateLimitCoroutine()

void BulletDynamics.Weapons.Weapon.StartFireRateLimitCoroutine ( )
protected

Starts the FireRateLimitCoroutine in a safe way (by stopping current coroutine).

Definition at line 109 of file Weapon.cs.

◆ StopFireRateLimitCoroutine()

void BulletDynamics.Weapons.Weapon.StopFireRateLimitCoroutine ( )
protected

Stops the FireRateLimitCoroutine.

Definition at line 118 of file Weapon.cs.

Member Data Documentation

◆ _bulletData

BulletData BulletDynamics.Weapons.Weapon._bulletData = default
protected

Definition at line 18 of file Weapon.cs.

◆ _fireRate

float BulletDynamics.Weapons.Weapon._fireRate = 10f
protected

Definition at line 15 of file Weapon.cs.

◆ _fireRateDelayActive

bool BulletDynamics.Weapons.Weapon._fireRateDelayActive = true
protected

Definition at line 20 of file Weapon.cs.

◆ _fireRateLimitCoroutine

Coroutine BulletDynamics.Weapons.Weapon._fireRateLimitCoroutine = null
protected

Definition at line 22 of file Weapon.cs.

◆ _isShootingEnabled

bool BulletDynamics.Weapons.Weapon._isShootingEnabled = true
protected

Definition at line 21 of file Weapon.cs.

◆ _outputPoint

Transform BulletDynamics.Weapons.Weapon._outputPoint = default
protected

Definition at line 17 of file Weapon.cs.

◆ OnShoot

UnityEvent<Bullet> BulletDynamics.Weapons.Weapon.OnShoot

Event that is raised when this weapon has shot a Bullet.

Definition at line 47 of file Weapon.cs.

Property Documentation

◆ BulletData

virtual BulletData BulletDynamics.Weapons.Weapon.BulletData
get

Data of the Bullet that is used by this Weapon.

Definition at line 37 of file Weapon.cs.

◆ FireRate

virtual float BulletDynamics.Weapons.Weapon.FireRate
get

Fire rate of this weapon (Bullets per second).

Definition at line 27 of file Weapon.cs.

◆ IsShootingEnabled

virtual bool BulletDynamics.Weapons.Weapon.IsShootingEnabled
get

Flag that blocks the Shoot method from firing a bullet if it is set to false.

Definition at line 42 of file Weapon.cs.

◆ OutputPoint

virtual Transform BulletDynamics.Weapons.Weapon.OutputPoint
get

Output point from which the Bullet will be instantiated when the Shoot is called.

Definition at line 32 of file Weapon.cs.