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

View File

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