Add logic for removing weapons from inventory
This commit is contained in:
parent
7c44598084
commit
a3456fce0f
|
@ -376,14 +376,34 @@ void APlayerCharacter::AddWeaponToInventory(TSubclassOf<class AWeapon> weapon)
|
|||
|
||||
void APlayerCharacter::RemoveWeaponFromInventory(int i)
|
||||
{
|
||||
// TODO: Add more checking here
|
||||
WeaponInventory[i]->Destroy();
|
||||
WeaponInventory.RemoveAt(i);
|
||||
|
||||
if (WeaponInventory.Num() == 0)
|
||||
{
|
||||
CurrentInventorySlot = -1;
|
||||
}
|
||||
else if (int index = WeaponInventory.Find(CurrentWeapon) == INDEX_NONE)
|
||||
{
|
||||
SetCurrentWeapon(WeaponInventory[CurrentInventorySlot % WeaponInventory.Num()]);
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentInventorySlot = index;
|
||||
}
|
||||
}
|
||||
|
||||
void APlayerCharacter::RemoveWeaponFromInventory(AWeapon* weapon)
|
||||
{
|
||||
if (int index = WeaponInventory.Find(weapon) != INDEX_NONE)
|
||||
{
|
||||
RemoveWeaponFromInventory(index);
|
||||
}
|
||||
}
|
||||
|
||||
void APlayerCharacter::RemoveCurrentWeaponFromInventory()
|
||||
{
|
||||
// TODO: Add more checking here
|
||||
RemoveWeaponFromInventory(CurrentWeapon);
|
||||
}
|
||||
|
||||
void APlayerCharacter::OnFire()
|
||||
|
|
|
@ -137,6 +137,8 @@ public:
|
|||
|
||||
void RemoveWeaponFromInventory(int i);
|
||||
|
||||
void RemoveWeaponFromInventory(AWeapon* weapon);
|
||||
|
||||
void RemoveCurrentWeaponFromInventory();
|
||||
|
||||
void OnFire();
|
||||
|
|
Loading…
Reference in New Issue