TopDown Engine  v4.2
MoreMountains.TopDownEngine.WeaponAmmo Class Reference
Inheritance diagram for MoreMountains.TopDownEngine.WeaponAmmo:
MoreMountains.TopDownEngine.TopDownMonoBehaviour MoreMountains.Tools.MMEventListener< MMInventoryEvent > MoreMountains.Tools.MMEventListener< MMGameEvent > MoreMountains.Tools.MMMonoBehaviour

Public Member Functions

virtual bool EnoughAmmoToFire ()
 Returns true if this weapon has enough ammo to fire, false otherwise More...
 
virtual void FillWeaponWithAmmo ()
 Fills the weapon with ammo More...
 
virtual void EmptyMagazine ()
 Empties the weapon's magazine and puts the ammo back in the inventory More...
 
virtual void OnMMEvent (MMStateChangeEvent< MoreMountains.TopDownEngine.Weapon.WeaponStates > weaponEvent)
 When getting weapon events, we either consume ammo or refill it More...
 
virtual void OnMMEvent (MMInventoryEvent inventoryEvent)
 Grabs inventory events and refreshes ammo if needed More...
 
virtual void OnMMEvent (MMGameEvent gameEvent)
 Grabs inventory events and refreshes ammo if needed More...
 
- Public Member Functions inherited from MoreMountains.Tools.MMEventListener< MMInventoryEvent >
void OnMMEvent (T eventType)
 
- Public Member Functions inherited from MoreMountains.Tools.MMEventListener< MMGameEvent >
void OnMMEvent (T eventType)
 

Public Attributes

string AmmoID
 the ID of this ammo, to be matched on the ammo display if you use one More...
 
string AmmoInventoryName = "MainInventory"
 the name of the inventory where the system should look for ammo More...
 
int MaxAmmo = 100
 the theoretical maximum of ammo More...
 
bool ShouldLoadOnStart = true
 if this is true, everytime you equip this weapon, it'll auto fill with ammo More...
 
bool ShouldEmptyOnSave = true
 if this is true, everytime you equip this weapon, it'll auto fill with ammo More...
 
int CurrentAmmoAvailable
 the current amount of ammo available in the inventory More...
 

Protected Member Functions

virtual void Start ()
 On start, we grab the ammo inventory if we can find it More...
 
virtual void LoadOnStart ()
 Loads our weapon with ammo More...
 
virtual void RefreshCurrentAmmoAvailable ()
 Updates the CurrentAmmoAvailable counter More...
 
virtual void ConsumeAmmo ()
 Consumes ammo based on the amount of ammo to consume per shot More...
 
IEnumerator DelayedRefreshCurrentAmmoAvailable ()
 
void OnDestroy ()
 
virtual void OnEnable ()
 On enable, we start listening for MMGameEvents. You may want to extend that to listen to other types of events. More...
 
virtual void OnDisable ()
 On disable, we stop listening for MMGameEvents. You may want to extend that to stop listening to other types of events. More...
 

Protected Attributes

Weapon _weapon
 
InventoryItem _ammoItem
 
bool _emptied = false
 

Properties

virtual Inventory AmmoInventory [get, set]
 the inventory where ammo for this weapon is stored More...
 

Member Function Documentation

◆ ConsumeAmmo()

virtual void MoreMountains.TopDownEngine.WeaponAmmo.ConsumeAmmo ( )
protectedvirtual

Consumes ammo based on the amount of ammo to consume per shot

◆ DelayedRefreshCurrentAmmoAvailable()

IEnumerator MoreMountains.TopDownEngine.WeaponAmmo.DelayedRefreshCurrentAmmoAvailable ( )
protected

◆ EmptyMagazine()

virtual void MoreMountains.TopDownEngine.WeaponAmmo.EmptyMagazine ( )
virtual

Empties the weapon's magazine and puts the ammo back in the inventory

◆ EnoughAmmoToFire()

virtual bool MoreMountains.TopDownEngine.WeaponAmmo.EnoughAmmoToFire ( )
virtual

Returns true if this weapon has enough ammo to fire, false otherwise

Returns

◆ FillWeaponWithAmmo()

virtual void MoreMountains.TopDownEngine.WeaponAmmo.FillWeaponWithAmmo ( )
virtual

Fills the weapon with ammo

◆ LoadOnStart()

virtual void MoreMountains.TopDownEngine.WeaponAmmo.LoadOnStart ( )
protectedvirtual

Loads our weapon with ammo

◆ OnDestroy()

void MoreMountains.TopDownEngine.WeaponAmmo.OnDestroy ( )
protected

◆ OnDisable()

virtual void MoreMountains.TopDownEngine.WeaponAmmo.OnDisable ( )
protectedvirtual

On disable, we stop listening for MMGameEvents. You may want to extend that to stop listening to other types of events.

◆ OnEnable()

virtual void MoreMountains.TopDownEngine.WeaponAmmo.OnEnable ( )
protectedvirtual

On enable, we start listening for MMGameEvents. You may want to extend that to listen to other types of events.

◆ OnMMEvent() [1/3]

virtual void MoreMountains.TopDownEngine.WeaponAmmo.OnMMEvent ( MMGameEvent  gameEvent)
virtual

Grabs inventory events and refreshes ammo if needed

Parameters
inventoryEvent

◆ OnMMEvent() [2/3]

virtual void MoreMountains.TopDownEngine.WeaponAmmo.OnMMEvent ( MMInventoryEvent  inventoryEvent)
virtual

Grabs inventory events and refreshes ammo if needed

Parameters
inventoryEvent

◆ OnMMEvent() [3/3]

virtual void MoreMountains.TopDownEngine.WeaponAmmo.OnMMEvent ( MMStateChangeEvent< MoreMountains.TopDownEngine.Weapon.WeaponStates weaponEvent)
virtual

When getting weapon events, we either consume ammo or refill it

Parameters
weaponEvent

◆ RefreshCurrentAmmoAvailable()

virtual void MoreMountains.TopDownEngine.WeaponAmmo.RefreshCurrentAmmoAvailable ( )
protectedvirtual

Updates the CurrentAmmoAvailable counter

◆ Start()

virtual void MoreMountains.TopDownEngine.WeaponAmmo.Start ( )
protectedvirtual

On start, we grab the ammo inventory if we can find it

Member Data Documentation

◆ _ammoItem

InventoryItem MoreMountains.TopDownEngine.WeaponAmmo._ammoItem
protected

◆ _emptied

bool MoreMountains.TopDownEngine.WeaponAmmo._emptied = false
protected

◆ _weapon

Weapon MoreMountains.TopDownEngine.WeaponAmmo._weapon
protected

◆ AmmoID

string MoreMountains.TopDownEngine.WeaponAmmo.AmmoID

the ID of this ammo, to be matched on the ammo display if you use one

◆ AmmoInventoryName

string MoreMountains.TopDownEngine.WeaponAmmo.AmmoInventoryName = "MainInventory"

the name of the inventory where the system should look for ammo

◆ CurrentAmmoAvailable

int MoreMountains.TopDownEngine.WeaponAmmo.CurrentAmmoAvailable

the current amount of ammo available in the inventory

◆ MaxAmmo

int MoreMountains.TopDownEngine.WeaponAmmo.MaxAmmo = 100

the theoretical maximum of ammo

◆ ShouldEmptyOnSave

bool MoreMountains.TopDownEngine.WeaponAmmo.ShouldEmptyOnSave = true

if this is true, everytime you equip this weapon, it'll auto fill with ammo

◆ ShouldLoadOnStart

bool MoreMountains.TopDownEngine.WeaponAmmo.ShouldLoadOnStart = true

if this is true, everytime you equip this weapon, it'll auto fill with ammo

Property Documentation

◆ AmmoInventory

virtual Inventory MoreMountains.TopDownEngine.WeaponAmmo.AmmoInventory
getset

the inventory where ammo for this weapon is stored


The documentation for this class was generated from the following file: