From c042d6f3afcfb3f18c24ef31e7bc935a3428929d Mon Sep 17 00:00:00 2001 From: PHILIP WHITE Date: Sun, 12 May 2024 17:29:45 +0100 Subject: [PATCH] Bugfix Need Reload UI Persisting on Overlay State Change --- .../EndlessVendetta/EndlessVendettaCharacter.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp index 2c109e5f..7931ae17 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp @@ -490,6 +490,7 @@ void AEndlessVendettaCharacter::EquipPrimary() //PrimaryWeapon->AttachToComponent(FirstPersonArms, AttachmentRules, FName("UnEquipGunSocket")); PrimaryWeapon->SetActorHiddenInGame(true); PrimaryWeapon->SetActorEnableCollision(false); + PrimaryWeapon->HideNeedReloadUI(); this->GetFirstPersonCameraComponent()->SetFieldOfView(90); UE_LOG(LogTemp, Warning, TEXT("Primary Weapon Is Hidden: %hhd"), PrimaryWeapon->IsHidden()); PrimaryWeapon = nullptr; @@ -544,6 +545,10 @@ void AEndlessVendettaCharacter::EquipPrimary() PrimaryWeapon = Cast(PrimaryWeaponActor); PrimaryWeapon->SetActorHiddenInGame(false); PrimaryWeapon->SetActorEnableCollision(false); + if (PrimaryWeapon->currentAmmoCount <= 0) + { + PrimaryWeapon->ShowNeedReloadUI(); + } //GetWorldTimerManager().ClearTimer(PrimaryWeapon->reloadTimerHandle); bIsCurrentlyHoldingWeapon = true; bHasRifle = true; @@ -568,6 +573,7 @@ void AEndlessVendettaCharacter::EquipSecondary() SecondaryWeapon->SetActorHiddenInGame(true); SecondaryWeapon->SetActorEnableCollision(false); this->GetFirstPersonCameraComponent()->SetFieldOfView(90); + SecondaryWeapon->HideNeedReloadUI(); UE_LOG(LogTemp, Warning, TEXT("Secondary Weapon Is Hidden: %hhd"), SecondaryWeapon->IsHidden()); //the nullptr makes it so we can unequip and requip the same weapon SecondaryWeapon = nullptr; @@ -611,6 +617,10 @@ void AEndlessVendettaCharacter::EquipSecondary() SecondaryWeaponActor = HeldWeapon->GetChildActor(); SecondaryWeapon = Cast(SecondaryWeaponActor); SecondaryWeapon->SetActorHiddenInGame(false); + if (SecondaryWeapon->currentAmmoCount <= 0) + { + SecondaryWeapon->ShowNeedReloadUI(); + } bIsCurrentlyHoldingWeapon = true; SetOverlayState(EOverlayState::Pistol); GetWorldTimerManager().ClearTimer(SecondaryWeapon->reloadTimerHandle);