Merge branch 'WeaponPickupSystem' into TutorialBounty

# Conflicts:
#	EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_BaseWeapon.uasset
#	EndlessVendetta/Content/LevelPrototyping/Scenes/TutorialHit.umap
This commit is contained in:
Rafal Swierczek 2023-10-23 10:45:10 +01:00
commit ddfb44b2e7
15 changed files with 120 additions and 22 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fb7eb23a18c0ad9f5cf37ae72d45bac1d1b1d90fac9281cfa3e3233b9b6a3d44
size 42950
oid sha256:2ffa922873f3999c8ef2d7ff492cedee047c6e06cc8b56c6ee9aaeab08d8fbad
size 42684

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a45878c4f97b973894f65722a55015a06cb6acc25e913c9d4045fd4532176701
size 192580

Binary file not shown.

View File

@ -266,6 +266,11 @@ void ABountyDirector::Interact()
PC_Display->LoadOS();
}
void ABountyDirector::InteractPrompt()
{
}
void ABountyDirector::DestroyBountyDirectorPCWidget()
{
if (IsValid(PC_DisplayWidget)) PC_DisplayWidget->RemoveFromParent();

View File

@ -54,6 +54,8 @@ class ENDLESSVENDETTA_API ABountyDirector : public AActor, public IInteractionIn
// Opens up Bounty Director PC Interface
void Interact() override;
// Prompts player to interact
void InteractPrompt() override;
protected:
int Favours = 20;

View File

@ -69,6 +69,23 @@ void AEndlessVendettaCharacter::BeginPlay()
void AEndlessVendettaCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
WeaponPickUpSystem();
}
void AEndlessVendettaCharacter::WeaponPickUpSystem()
{
FHitResult OutHit;
FCollisionQueryParams QueryParams = FCollisionQueryParams::DefaultQueryParam;
QueryParams.AddIgnoredActor(this);
FVector LT_Start = FirstPersonCameraComponent->GetComponentLocation();
FVector LT_End = LT_Start + (FirstPersonCameraComponent->GetForwardVector() * InteractionRange);
if (!GetWorld()->LineTraceSingleByChannel(OutHit, LT_Start, LT_End, ECC_Camera, QueryParams)) return;
AActor* HitActor = OutHit.GetActor();
IInteractionInterface* InteractableActor = Cast<IInteractionInterface>(HitActor);
if (InteractableActor) InteractableActor->InteractPrompt();
}
//////////////////////////////////////////////////////////////////////////// Input
@ -121,9 +138,17 @@ void AEndlessVendettaCharacter::Interact()
QueryParams.AddIgnoredActor(this);
FVector LT_Start = FirstPersonCameraComponent->GetComponentLocation();
FVector LT_End = LT_Start + (FirstPersonCameraComponent->GetForwardVector() * InteractionRange);
if(IsValid(PrimaryWeapon))
{
QueryParams.AddIgnoredActor(PrimaryWeapon);
}
if(IsValid(SecondaryWeapon))
{
QueryParams.AddIgnoredActor(SecondaryWeapon);
}
if (!GetWorld()->LineTraceSingleByChannel(OutHit, LT_Start, LT_End, ECC_Camera, QueryParams)) return;
AActor* HitActor = OutHit.GetActor();
UE_LOG(LogTemp, Warning, TEXT("Hit actor: %s"), *HitActor->GetName());
IInteractionInterface* InteractableActor = Cast<IInteractionInterface>(HitActor);
if (InteractableActor) InteractableActor->Interact();
}
@ -151,6 +176,7 @@ float AEndlessVendettaCharacter::TakeDamage(const float DamageAmount, FDamageEve
return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
}
void AEndlessVendettaCharacter::ToggleRecon()
{
if (IsValid(PrimaryWeapon)) EquipPrimary();
@ -251,6 +277,17 @@ void AEndlessVendettaCharacter::EquipSecondary()
SecondaryWeapon = Cast<ABaseWeaponClass>(SecondaryWeaponActor);
}
void AEndlessVendettaCharacter::WeaponSwitcher(AActor* Outhit)
{
if (IsValid(PrimaryWeapon))
{
EquipPrimary();
}
PrimaryWeaponClass = Outhit->GetClass();
Outhit->Destroy();
EquipPrimary();
}
//Calls the fire function in the baseWeaponClass
void AEndlessVendettaCharacter::FireCaller()
{

View File

@ -148,9 +148,6 @@ protected:
void ToggleRecon();
void ToggleCombat();
void EquipPrimary();
void EquipSecondary();
UPROPERTY(EditDefaultsOnly, Category = "Interaction")
float InteractionRange = 250;
void Interact();
@ -173,4 +170,11 @@ public:
UFUNCTION(BlueprintCallable, Category = "Damage Control")
virtual float TakeDamage(float DamageAmount, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) override;
void WeaponPickUpSystem();
void EquipPrimary();
void EquipSecondary();
void WeaponSwitcher(AActor* Outhit);
};

View File

@ -23,4 +23,7 @@ class ENDLESSVENDETTA_API IInteractionInterface
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
virtual void Interact(){}
virtual void InteractPrompt() {}
};

View File

@ -230,4 +230,32 @@ void ABaseWeaponClass::WeaponReload()
}
}
void ABaseWeaponClass::Interact()
{
if(!IsValid(this)) return;
GLog->Log("Interact Called");
endlessVendettaChar->WeaponSwitcher(this);
}
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<ABaseWeaponClass>(endlessVendettaChar->PrimaryWeaponClass);
// endlessVendettaChar->PrimaryWeapon = Cast<ABaseWeaponClass>(HitActor);
// }

View File

@ -6,13 +6,14 @@
#include "WeaponItemClass.h"
#include "Components/ArrowComponent.h"
#include "Kismet/KismetMathLibrary.h"
#include "EndlessVendetta/InteractionInterface.h"
#include "BaseWeaponClass.generated.h"
class AEndlessVendettaCharacter;
class UCapsuleComponent;
UCLASS()
class ENDLESSVENDETTA_API ABaseWeaponClass : public AActor
class ENDLESSVENDETTA_API ABaseWeaponClass : public AActor, public IInteractionInterface
{
GENERATED_BODY()
@ -53,19 +54,23 @@ public:
// Called every frame
virtual void Tick(float DeltaTime) override;
void ReloadTimer();
UPROPERTY(EditAnywhere)
FName WeaponName;
UPROPERTY(EditAnywhere)
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString WeaponName;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int WeaponDamage;
UPROPERTY(EditAnywhere)
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString WeaponDescription;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float FireRate;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int MagazineSize;
UPROPERTY(EditAnywhere)
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float TimeToReload = 3.f;
//how many bullets until the recoil stops going up
@ -156,6 +161,14 @@ public:
UPROPERTY(EditAnywhere)
int bulletCountShoot; //Gets how many bullets shot per
void Interact() override;
void InteractPrompt() override;
UFUNCTION(BlueprintImplementableEvent)
void WeaponStatsPopUp();
//void GetOutHit(FHitResult OutHit);
protected:
UArrowComponent* GunStartArrow;