/// <summary> /// /// </summary> /// <param name="weapon"></param> /// <param name="spawnPickable"></param> /// <param name="index"></param> /// <returns></returns> public bool ClearWeapon(WeaponEquippable weapon, bool spawnPickable = true, int index = -1) { if (index == -1) { for (var i = 0; i < _weapons.Length; ++i) { if (_weapons[i] == weapon) { index = i; } } Debug.Assert(index >= 0); } var switchWeapon = _currentEquippable is WeaponEquippable; Destroy(weapon.gameObject); if (spawnPickable && weapon.weaponDescriptor != spawner.defaultWeapon) { GameplayStatics.SpawnWeaponPickable(weapon.weaponDescriptor, transform.position); } _weapons[index] = null; if (switchWeapon) { _currentEquippable = null; SwitchWeapon(); } return(true); }
/// <summary> /// /// </summary> /// <param name="dropDefault"></param> public void DropAllWeapons(bool dropDefault = false) { foreach (var weapon in weapons) { if (weapon != null && weapon.weaponDescriptor != null) { if (!dropDefault && weapon.weaponDescriptor == spawner.defaultWeapon) { continue; } weapon.OnUnequip(); GameplayStatics.SpawnWeaponPickable(weapon.weaponDescriptor, transform.position); } } }