Merge remote-tracking branch 'origin/grip-attachment' into Main-Bounty-Update

# Conflicts:
#	EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Pistols/AnimatedPistol/BP_BasePistolWeapon_Animated.uasset
This commit is contained in:
Rafal Swierczek 2024-03-21 13:10:27 +00:00
commit d5f78c190d
22 changed files with 254 additions and 27 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,2 +0,0 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/Environment/Highlighting/HighlightingSourceSnapshotLocation/@EntryValue">C:\Users\Rafal\AppData\Local\JetBrains\Rider2023.3\resharper-host\temp\Rider\vAny\CoverageData\_EndlessVendetta.-1253833435\Snapshot\snapshot.utdcvr</s:String></wpf:ResourceDictionary>

View File

@ -13,6 +13,8 @@
#include <EndlessVendetta/EndlessVendettaGameMode.h> #include <EndlessVendetta/EndlessVendettaGameMode.h>
#include "EndlessVendetta/BountySystem/ControlsTraining/TargetDummy.h" #include "EndlessVendetta/BountySystem/ControlsTraining/TargetDummy.h"
#include "EndlessVendetta/Workbench&Attachments/ExtendedMagAttachmentClass.h"
#include "EndlessVendetta/Workbench&Attachments/GripAttachmentClass.h"
#include "EndlessVendetta/Workbench&Attachments/SilencerAttachmentClass.h" #include "EndlessVendetta/Workbench&Attachments/SilencerAttachmentClass.h"
@ -278,6 +280,7 @@ void ABaseWeaponClass::InteractPrompt()
WeaponStatsPopUp(); WeaponStatsPopUp();
} }
//Called in weaponworkbench WBP
void ABaseWeaponClass::SetupSilencerAttachment(UStaticMesh* SilencerMesh) void ABaseWeaponClass::SetupSilencerAttachment(UStaticMesh* SilencerMesh)
{ {
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("SETTING UP SILENCER ATTACHMENTS")); GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("SETTING UP SILENCER ATTACHMENTS"));
@ -290,11 +293,13 @@ void ABaseWeaponClass::SetupSilencerAttachment(UStaticMesh* SilencerMesh)
{ {
if (IsValid(WeaponSkeletonMesh)) if (IsValid(WeaponSkeletonMesh))
{ {
//this handles giving the weapon the required component class/code
SilencerAttachmentClass->AttachToComponent(WeaponSkeletonMesh, FAttachmentTransformRules::SnapToTargetIncludingScale, FName(TEXT("SilencerMeshSocket"))); SilencerAttachmentClass->AttachToComponent(WeaponSkeletonMesh, FAttachmentTransformRules::SnapToTargetIncludingScale, FName(TEXT("SilencerMeshSocket")));
UE_LOG(LogTemp, Display, TEXT("All Attachment is valid")); UE_LOG(LogTemp, Display, TEXT("All Attachment is valid"));
//this makes it showup in editor for better debugging //this makes it showup in editor for better debugging
SilencerAttachmentClass->CreationMethod = EComponentCreationMethod::Instance; SilencerAttachmentClass->CreationMethod = EComponentCreationMethod::Instance;
SilencerAttachmentClass->RegisterComponent(); SilencerAttachmentClass->RegisterComponent();
//below handles seeing the physical attachment you selected
UStaticMeshComponent* StaticMeshComp = NewObject<UStaticMeshComponent>(SilencerAttachmentClass, UStaticMeshComponent::StaticClass()); UStaticMeshComponent* StaticMeshComp = NewObject<UStaticMeshComponent>(SilencerAttachmentClass, UStaticMeshComponent::StaticClass());
if (IsValid(StaticMeshComp)) if (IsValid(StaticMeshComp))
{ {
@ -309,3 +314,78 @@ void ABaseWeaponClass::SetupSilencerAttachment(UStaticMesh* SilencerMesh)
} }
} }
} }
//Called in weaponworkbench WBP
void ABaseWeaponClass::SetupExtendedMagAttachment(UStaticMesh* ExtendedMagMesh)
{
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("SETTING UP EXTENDEDMAG ATTACHMENTS"));
FTransform EmptyTransform;
USceneComponent* ExtendedMagAttachmentClass = Cast<USceneComponent>(AddComponentByClass(UExtendedMagAttachmentClass::StaticClass(), false, EmptyTransform, false));
ExtendedMagAttachmentClass->ComponentTags.Add(FName("AttachmentType"));
USkeletalMeshComponent* WeaponSkeletonMesh = FindComponentByClass<USkeletalMeshComponent>();
if (IsValid(ExtendedMagAttachmentClass))
{
if (IsValid(WeaponSkeletonMesh))
{
//this handles giving the weapon the required component class/code
ExtendedMagAttachmentClass->AttachToComponent(WeaponSkeletonMesh, FAttachmentTransformRules::SnapToTargetIncludingScale, FName(TEXT("ExtendedMagSocket")));
UE_LOG(LogTemp, Display, TEXT("All Attachment is valid"));
//this makes it showup in editor for better debugging
ExtendedMagAttachmentClass->CreationMethod = EComponentCreationMethod::Instance;
ExtendedMagAttachmentClass->RegisterComponent();
//below handles seeing the physical attachment you selected
UStaticMeshComponent* StaticMeshComp = NewObject<UStaticMeshComponent>(ExtendedMagAttachmentClass, UStaticMeshComponent::StaticClass());
if (IsValid(StaticMeshComp))
{
StaticMeshComp->AttachToComponent(ExtendedMagAttachmentClass, FAttachmentTransformRules::SnapToTargetIncludingScale);
StaticMeshComp->SetStaticMesh(ExtendedMagMesh);
StaticMeshComp->SetRelativeRotation(FRotator(0, 180, 0));
StaticMeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
//Making it show in editor for debugging
StaticMeshComp->CreationMethod = EComponentCreationMethod::Instance;
StaticMeshComp->RegisterComponent();
}
}
}
}
//Called in weaponworkbench WBP
void ABaseWeaponClass::SetupGripAttachment(UStaticMesh* GripMesh)
{
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("SETTING UP GRIP ATTACHMENTS"));
FTransform EmptyTransform;
USceneComponent* GripAttachmentClass = Cast<USceneComponent>(AddComponentByClass(UGripAttachmentClass::StaticClass(), false, EmptyTransform, false));
GripAttachmentClass->ComponentTags.Add(FName("AttachmentType"));
USkeletalMeshComponent* WeaponSkeletonMesh = FindComponentByClass<USkeletalMeshComponent>();
if (IsValid(GripAttachmentClass))
{
if (IsValid(WeaponSkeletonMesh))
{
//this handles giving the weapon the required component class/code
GripAttachmentClass->AttachToComponent(WeaponSkeletonMesh, FAttachmentTransformRules::SnapToTargetIncludingScale, FName(TEXT("GripMeshSocket")));
UE_LOG(LogTemp, Display, TEXT("All Attachment is valid"));
//this makes it showup in editor for better debugging
GripAttachmentClass->CreationMethod = EComponentCreationMethod::Instance;
GripAttachmentClass->RegisterComponent();
//below handles seeing the physical attachment you selected
UStaticMeshComponent* StaticMeshComp = NewObject<UStaticMeshComponent>(GripAttachmentClass, UStaticMeshComponent::StaticClass());
if (IsValid(StaticMeshComp))
{
StaticMeshComp->AttachToComponent(GripAttachmentClass, FAttachmentTransformRules::SnapToTargetIncludingScale);
StaticMeshComp->SetStaticMesh(GripMesh);
StaticMeshComp->SetRelativeRotation(FRotator(0, 0, 0));
StaticMeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
//Making it show in editor for debugging
StaticMeshComp->CreationMethod = EComponentCreationMethod::Instance;
StaticMeshComp->RegisterComponent();
}
}
}
}
void ABaseWeaponClass::RemoveAllAttachments()
{
}

View File

@ -172,9 +172,20 @@ public:
//void GetOutHit(FHitResult OutHit); //void GetOutHit(FHitResult OutHit);
//ATTACHMENTS
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
void SetupSilencerAttachment(UStaticMesh* SilencerMesh); void SetupSilencerAttachment(UStaticMesh* SilencerMesh);
UFUNCTION(BlueprintCallable)
void SetupExtendedMagAttachment(UStaticMesh* ExtendedMagMesh);
UFUNCTION(BlueprintCallable)
void SetupGripAttachment(UStaticMesh* GripMesh);
UFUNCTION(BlueprintCallable)
void RemoveAllAttachments();
//
UFUNCTION(BlueprintImplementableEvent) UFUNCTION(BlueprintImplementableEvent)
void ShowReloadingWidget(); void ShowReloadingWidget();

View File

@ -0,0 +1,45 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "ExtendedMagAttachmentClass.h"
#include "EndlessVendetta/WeaponSystem/BaseWeaponClass.h"
// Sets default values for this component's properties
UExtendedMagAttachmentClass::UExtendedMagAttachmentClass()
{
// 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 UExtendedMagAttachmentClass::BeginPlay()
{
Super::BeginPlay();
BaseWeaponClass = Cast<ABaseWeaponClass>(this->GetAttachParentActor());
if (BaseWeaponClass)
{
IncreaseAmmoCount();
}
}
// Called every frame
void UExtendedMagAttachmentClass::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}
void UExtendedMagAttachmentClass::IncreaseAmmoCount()
{
if (!IsValid(BaseWeaponClass)) return;
UE_LOG(LogTemp, Warning, TEXT("AmmoCountIncrease activated"));
BaseWeaponClass->MagazineSize *= 2;
BaseWeaponClass->currentAmmoCount = BaseWeaponClass->MagazineSize;
}

View File

@ -0,0 +1,31 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/SceneComponent.h"
#include "ExtendedMagAttachmentClass.generated.h"
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class ENDLESSVENDETTA_API UExtendedMagAttachmentClass : public USceneComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UExtendedMagAttachmentClass();
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)
class ABaseWeaponClass* BaseWeaponClass;
void IncreaseAmmoCount();
};

View File

@ -0,0 +1,33 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "GripAttachmentClass.h"
// Sets default values for this component's properties
UGripAttachmentClass::UGripAttachmentClass()
{
// 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 UGripAttachmentClass::BeginPlay()
{
Super::BeginPlay();
// ...
}
// Called every frame
void UGripAttachmentClass::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}

View File

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