Added ExtendedMag code to give more ammo to the weapon

This commit is contained in:
MH261677 2024-03-19 16:10:01 +00:00
parent 2542404a4f
commit 826cadbbcb
3 changed files with 22 additions and 5 deletions

View File

@ -3,6 +3,8 @@
#include "ExtendedMagAttachmentClass.h"
#include "EndlessVendetta/WeaponSystem/BaseWeaponClass.h"
// Sets default values for this component's properties
UExtendedMagAttachmentClass::UExtendedMagAttachmentClass()
@ -19,9 +21,11 @@ UExtendedMagAttachmentClass::UExtendedMagAttachmentClass()
void UExtendedMagAttachmentClass::BeginPlay()
{
Super::BeginPlay();
// ...
BaseWeaponClass = Cast<ABaseWeaponClass>(this->GetAttachParentActor());
if (BaseWeaponClass)
{
IncreaseAmmoCount();
}
}
@ -31,3 +35,11 @@ void UExtendedMagAttachmentClass::TickComponent(float DeltaTime, ELevelTick Tick
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}
void UExtendedMagAttachmentClass::IncreaseAmmoCount()
{
if (!IsValid(BaseWeaponClass)) return;
UE_LOG(LogTemp, Warning, TEXT("AmmoCountIncrease activated"));
BaseWeaponClass->MagazineSize *= 2;
BaseWeaponClass->currentAmmoCount = BaseWeaponClass->MagazineSize;
}

View File

@ -23,4 +23,9 @@ protected:
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
UPROPERTY(EditAnywhere)
class ABaseWeaponClass* BaseWeaponClass;
void IncreaseAmmoCount();
};