/// <summary> /// Whether or not a weapon can be picked up. /// <see cref="EntityModel.pickupWeapon"/> /// </summary> /// <param name="weaponAmmo">Weapon and ammo to be picked up.</param> public virtual bool CanPickupWeapon(WeaponAmmoTuple weaponAmmo) { if (this.inventory.Count >= this.maxAmountWeapons) { return(false); } return(!this.inventory.ContainsKey(weaponAmmo.weapon)); }
/// <summary> /// Handler for picking up a weapon with ammo. /// <see cref="EntityModel.pickupWeapon"/> /// </summary> public virtual void OnPickupWeapon(WeaponAmmoTuple weaponAmmo) { int curAmmo = 0; if (this.inventory.TryGetValue(weaponAmmo.weapon, out curAmmo)) { this.inventory[weaponAmmo.weapon] = curAmmo + weaponAmmo.ammo; } else { this.entity.model.onPickedupWeapon.Fire(weaponAmmo.weapon); this.inventory.Add(weaponAmmo.weapon, weaponAmmo.ammo); } }