Add logic to throw weapon once weapon ammo is depleted

This commit is contained in:
baz 2023-09-23 21:10:15 +01:00
parent 7f4de48fb0
commit 12db67439f
1 changed files with 10 additions and 7 deletions

View File

@ -219,6 +219,12 @@ void APlayerCharacter::BeginFireCallback(const FInputActionInstance& Instance)
return; return;
} }
if (CurrentWeapon->GetAmmoCount() == 0)
{
ThrowWeaponCallback();
return;
}
IsFiring = true; IsFiring = true;
OnFire(); OnFire();
@ -478,7 +484,7 @@ void APlayerCharacter::EndAimDownSightsCallback(const FInputActionInstance& Inst
void APlayerCharacter::OnFire() void APlayerCharacter::OnFire()
{ {
if (!IsFiring) if (!IsFiring || CurrentWeapon->GetAmmoCount() == 0)
{ {
return; return;
} }
@ -497,11 +503,6 @@ void APlayerCharacter::OnFire()
CurrentWeapon->SetCurrentWeaponStatus(Cooldown); CurrentWeapon->SetCurrentWeaponStatus(Cooldown);
if (CurrentWeapon->GetAmmoCount() == 0)
{
RemoveCurrentWeaponFromInventory();
}
Super::OnFire(); Super::OnFire();
} }
@ -592,6 +593,8 @@ void APlayerCharacter::ThrowWeaponCallback()
Throwable->SetWeaponSkeletalMesh(GetCurrentWeapon()->GetSkeletalMesh()); Throwable->SetWeaponSkeletalMesh(GetCurrentWeapon()->GetSkeletalMesh());
} }
RemoveCurrentWeaponFromInventory();
} }
void APlayerCharacter::ThrowExplosiveCallback() void APlayerCharacter::ThrowExplosiveCallback()