diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp index 6ebc5b94..b154ddd5 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp @@ -12,6 +12,8 @@ #include "EndlessVendetta/AI/EnemyCharacter.h" #include +#include "EndlessVendetta/Workbench&Attachments/SilencerAttachmentClass.h" + // Sets default values ABaseWeaponClass::ABaseWeaponClass() @@ -251,19 +253,14 @@ void ABaseWeaponClass::InteractPrompt() WeaponStatsPopUp(); } -// void ABaseWeaponClass::GetOutHit(FHitResult OutHit) -// { -// if(IsValid(this)) -// { -// endlessVendettaChar->PrimaryWeapon->Destroy(); -// } -// if (OutHit.GetActor()->ActorHasTag(FName("AssaultRifle"))) -// { -// endlessVendettaChar->EquipPrimary(); -// } -// AActor* HitActor = Cast(endlessVendettaChar->PrimaryWeaponClass); -// endlessVendettaChar->PrimaryWeapon = Cast(HitActor); -// } +void ABaseWeaponClass::SetupSilencerAttachment(UStaticMesh* SilencerMesh) +{ + FTransform emptytransform; + UActorComponent* SilencerComponent = AddComponentByClass(USilencerAttachmentClass::StaticClass(), true, emptytransform, false); + Cast(SilencerComponent)->AttachToComponent(RootComponent, FAttachmentTransformRules::SnapToTargetIncludingScale); + TArray SilencerMeshSocketArray (GetComponentsByTag(UStaticMeshComponent::StaticClass(), FName("SilencerMeshSocket"))); + Cast(SilencerMeshSocketArray[0])->SetStaticMesh(SilencerMesh); +} diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h index 2637e31f..455752b0 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h @@ -176,6 +176,9 @@ public: //void GetOutHit(FHitResult OutHit); + UFUNCTION(BlueprintCallable) + void SetupSilencerAttachment(UStaticMesh* SilencerMesh); + protected: UArrowComponent* GunStartArrow; bool bStopShooting = false;