Store `WeaponProperties` in `WeaponPickup`

This commit is contained in:
Louis Hobbs 2023-02-12 20:28:30 +00:00
parent 296074d97f
commit bc26d04f83
2 changed files with 17 additions and 0 deletions

View File

@ -57,6 +57,7 @@ void AWeaponPickup::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AAc
if (player && Weapon)
{
player->AddWeaponToInventory(Weapon);
player->WeaponInventory.Last()->SetWeaponProperties(*WeaponComponent->GetWeaponProperties());
this->Destroy();
WeaponComponent->Destroy();
@ -75,6 +76,16 @@ void AWeaponPickup::SetWeapon(TSubclassOf<class AWeapon> weapon)
SpawnWeapon();
}
FWeaponProperties* AWeaponPickup::GetWeaponProperties()
{
return &WeaponProperties;
}
void AWeaponPickup::SetWeaponProperties(FWeaponProperties FWeaponProperties)
{
WeaponComponent->SetWeaponProperties(FWeaponProperties);
}
void AWeaponPickup::SpawnWeapon()
{
FActorSpawnParameters SpawnParameters;

View File

@ -45,6 +45,8 @@ private:
UPROPERTY()
FVector WeaponStartingLocation;
FWeaponProperties WeaponProperties;
public:
// Sets default values for this actor's properties
AWeaponPickup();
@ -62,6 +64,10 @@ public:
void SetWeapon(TSubclassOf<class AWeapon> weapon);
FWeaponProperties* GetWeaponProperties();
void SetWeaponProperties(FWeaponProperties FWeaponProperties);
private:
void SpawnWeapon();