Merge branch 'weapon-workbench' into dev

# Conflicts:
#	EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset
#	EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_BaseWeapon.uasset
#	EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp
#	EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp
This commit is contained in:
Rafal Swierczek 2024-01-19 15:10:47 +00:00
commit 50f4b46549
21 changed files with 186 additions and 29 deletions

Binary file not shown.

Binary file not shown.

View File

@ -334,6 +334,7 @@ void AEndlessVendettaCharacter::ToggleCombat()
void AEndlessVendettaCharacter::EquipPrimary()
{
if (PlayerOnShip) return;
if (!IsValid(PrimaryWeaponClass)) return;
FActorSpawnParameters spawnParams;
spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true);
@ -385,6 +386,7 @@ void AEndlessVendettaCharacter::EquipPrimary()
void AEndlessVendettaCharacter::EquipSecondary()
{
if (!IsValid(SecondaryWeaponClass)) return;
if (PlayerOnShip) return;
FActorSpawnParameters spawnParams;
spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;

View File

@ -107,7 +107,9 @@ public:
float WalkSpeed;
float OriginalWalkSpeed;
UPROPERTY(BlueprintReadWrite)
AActor* PrimaryWeaponActor;
UPROPERTY(BlueprintReadWrite)
AActor* SecondaryWeaponActor;
bool bIsPrimaryWeaponCreated = false;
bool bIsSecondaryWeaponCreated = false;
@ -155,13 +157,15 @@ public:
UFUNCTION(BlueprintCallable, Category = Weapon)
bool GetHasRifle();
UPROPERTY(EditAnywhere, Category = "Weapons")
UPROPERTY(EditAnywhere, Category = "Weapons", BlueprintReadWrite)
TSubclassOf<ABaseWeaponClass> PrimaryWeaponClass;
UPROPERTY(EditAnywhere, Category = "Weapons")
UPROPERTY(EditAnywhere, Category = "Weapons", BlueprintReadWrite)
TSubclassOf<ABaseWeaponClass> SecondaryWeaponClass;
UPROPERTY(BlueprintReadWrite)
ABaseWeaponClass* PrimaryWeapon;
UPROPERTY(BlueprintReadWrite)
ABaseWeaponClass* SecondaryWeapon;
UFUNCTION(BlueprintCallable, Category = "Weapons")

View File

@ -13,6 +13,7 @@
#include <EndlessVendetta/EndlessVendettaGameMode.h>
#include "EndlessVendetta/BountySystem/ControlsTraining/TargetDummy.h"
#include "EndlessVendetta/Workbench&Attachments/SilencerAttachmentClass.h"
// Sets default values
@ -254,19 +255,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<ABaseWeaponClass>(endlessVendettaChar->PrimaryWeaponClass);
// endlessVendettaChar->PrimaryWeapon = Cast<ABaseWeaponClass>(HitActor);
// }
void ABaseWeaponClass::SetupSilencerAttachment(UStaticMesh* SilencerMesh)
{
FTransform emptytransform;
UActorComponent* SilencerComponent = AddComponentByClass(USilencerAttachmentClass::StaticClass(), true, emptytransform, false);
Cast<USilencerAttachmentClass>(SilencerComponent)->AttachToComponent(RootComponent, FAttachmentTransformRules::SnapToTargetIncludingScale);
TArray<UActorComponent*> SilencerMeshSocketArray (GetComponentsByTag(UStaticMeshComponent::StaticClass(), FName("SilencerMeshSocket")));
Cast<UStaticMeshComponent>(SilencerMeshSocketArray[0])->SetStaticMesh(SilencerMesh);
}

View File

@ -176,6 +176,9 @@ public:
//void GetOutHit(FHitResult OutHit);
UFUNCTION(BlueprintCallable)
void SetupSilencerAttachment(UStaticMesh* SilencerMesh);
protected:
UArrowComponent* GunStartArrow;
bool bStopShooting = false;

View File

@ -0,0 +1,35 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "SilencerAttachmentClass.h"
// Sets default values for this component's properties
USilencerAttachmentClass::USilencerAttachmentClass()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void USilencerAttachmentClass::BeginPlay()
{
Super::BeginPlay();
// ADD THE LOGIC HERE LATER AFTER DEMO TO ACTUALLY MAKE THE GUN "SILENT" EVEN THO WE HAVE NO AUDIO IN THE GAME.
}
// Called every frame
void USilencerAttachmentClass::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}

View File

@ -0,0 +1,29 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/SceneComponent.h"
#include "SilencerAttachmentClass.generated.h"
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class ENDLESSVENDETTA_API USilencerAttachmentClass : public USceneComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
USilencerAttachmentClass();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
UPROPERTY(EditAnywhere)
UStaticMeshComponent* SilencerMesh;
};

View File

@ -0,0 +1,38 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "WeaponWorkbenchClass.h"
// Sets default values
AWeaponWorkbenchClass::AWeaponWorkbenchClass()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AWeaponWorkbenchClass::BeginPlay()
{
Super::BeginPlay();
PlayerCharacterRef = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetCharacter());
}
// Called every frame
void AWeaponWorkbenchClass::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void AWeaponWorkbenchClass::Interact()
{
if (!PlayerCharacterRef->bHasRifle) return;
UE_LOG(LogTemp, Display, TEXT("Opening Workbench"));
WorkbenchUI();
}
void AWeaponWorkbenchClass::InteractPrompt()
{
//THIS IS PROMPT WHERE WILL BE PRESS F TO INTERACT OR WHATEVER
}

View File

@ -0,0 +1,35 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "EndlessVendetta/EndlessVendettaCharacter.h"
#include "EndlessVendetta/InteractionInterface.h"
#include "GameFramework/Actor.h"
#include "WeaponWorkbenchClass.generated.h"
UCLASS()
class ENDLESSVENDETTA_API AWeaponWorkbenchClass : public AActor, public IInteractionInterface
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AWeaponWorkbenchClass();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
void Interact() override;
void InteractPrompt() override;
UFUNCTION(BlueprintImplementableEvent)
void WorkbenchUI();
AEndlessVendettaCharacter* PlayerCharacterRef;
};