Implemented Gadget Switching Workbench
This commit is contained in:
parent
6a14693826
commit
d705e61070
BIN
EndlessVendetta/Content/BountySystem/TutorialFacility/Checkpoints/CP_ParkourTutorial.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/BountySystem/TutorialFacility/Checkpoints/CP_ParkourTutorial.uasset
(Stored with Git LFS)
Binary file not shown.
Binary file not shown.
BIN
EndlessVendetta/Content/BountySystem/TutorialFacility/Checkpoints/GadgetTutorial/BP_Recon.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/BountySystem/TutorialFacility/Checkpoints/GadgetTutorial/BP_Recon.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:aca420300ee672cc466a648e1630d1fe57242f3f601751620e4d4336652b2a3f
|
||||||
|
size 23371
|
BIN
EndlessVendetta/Content/Gadgets/GM_GadgetManager.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/Gadgets/GM_GadgetManager.uasset
(Stored with Git LFS)
Binary file not shown.
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:46c1dbc7d35d69ea66831390e74563f3dc3dfbdcdc2c09fa0887195d6c231104
|
oid sha256:5865096b570bd55d2eb3055389ccd4c7f9db407bb3f830746a5736a47d34253a
|
||||||
size 460293
|
size 607074
|
||||||
|
BIN
EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/StarterContent/Props/MaterialSphere.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/StarterContent/Props/MaterialSphere.uasset
(Stored with Git LFS)
Binary file not shown.
@ -60,8 +60,7 @@ void AEndlessVendettaCharacter::BeginPlay()
|
|||||||
GadgetManagerActor->AttachToComponent(GetRootComponent(), AttachmentRules);
|
GadgetManagerActor->AttachToComponent(GetRootComponent(), AttachmentRules);
|
||||||
for (UActorComponent* PlayersCamera : GetComponentsByTag(UCameraComponent::StaticClass(), FName("PlayersCamera")))
|
for (UActorComponent* PlayersCamera : GetComponentsByTag(UCameraComponent::StaticClass(), FName("PlayersCamera")))
|
||||||
{
|
{
|
||||||
UE_LOG(LogTemp, Warning, TEXT("An actor component with PlayersCamera tag has been found"));
|
GadgetManager->SpawnGadgetsOnBeginPlay(Cast<USceneComponent>(PlayersCamera));
|
||||||
GadgetManager->SpawnGadgets(Cast<USceneComponent>(PlayersCamera));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,6 +180,8 @@ float AEndlessVendettaCharacter::TakeDamage(const float DamageAmount, FDamageEve
|
|||||||
|
|
||||||
void AEndlessVendettaCharacter::ToggleRecon()
|
void AEndlessVendettaCharacter::ToggleRecon()
|
||||||
{
|
{
|
||||||
|
if (!GadgetManager->IsValidReconGadget()) return;
|
||||||
|
|
||||||
if (IsValid(PrimaryWeapon)) EquipPrimary();
|
if (IsValid(PrimaryWeapon)) EquipPrimary();
|
||||||
if (IsValid(SecondaryWeapon)) EquipSecondary();
|
if (IsValid(SecondaryWeapon)) EquipSecondary();
|
||||||
|
|
||||||
@ -190,7 +191,7 @@ void AEndlessVendettaCharacter::ToggleRecon()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat())
|
if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat())
|
||||||
{
|
{
|
||||||
// Do nothing if combat is equipped and can't be unequipped at this moment
|
// Do nothing if combat is equipped and can't be unequipped at this moment
|
||||||
return;
|
return;
|
||||||
@ -201,6 +202,8 @@ void AEndlessVendettaCharacter::ToggleRecon()
|
|||||||
|
|
||||||
void AEndlessVendettaCharacter::ToggleCombat()
|
void AEndlessVendettaCharacter::ToggleCombat()
|
||||||
{
|
{
|
||||||
|
if(!GadgetManager->IsValidCombatGadget()) return;
|
||||||
|
|
||||||
if (IsValid(PrimaryWeapon)) EquipPrimary();
|
if (IsValid(PrimaryWeapon)) EquipPrimary();
|
||||||
if (IsValid(SecondaryWeapon)) EquipSecondary();
|
if (IsValid(SecondaryWeapon)) EquipSecondary();
|
||||||
|
|
||||||
@ -210,7 +213,7 @@ void AEndlessVendettaCharacter::ToggleCombat()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon())
|
if (GadgetManager->IsValidReconGadget() && GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon())
|
||||||
{
|
{
|
||||||
// Do nothing if recon is equipped and can't be unequipped at the moment
|
// Do nothing if recon is equipped and can't be unequipped at the moment
|
||||||
return;
|
return;
|
||||||
@ -235,8 +238,8 @@ void AEndlessVendettaCharacter::EquipPrimary()
|
|||||||
|
|
||||||
if (IsValid(SecondaryWeapon)) EquipSecondary();
|
if (IsValid(SecondaryWeapon)) EquipSecondary();
|
||||||
|
|
||||||
if (GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;
|
if (GadgetManager->IsValidReconGadget() && GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;
|
||||||
if (GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;
|
if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;
|
||||||
|
|
||||||
|
|
||||||
FActorSpawnParameters spawnParams;
|
FActorSpawnParameters spawnParams;
|
||||||
@ -267,8 +270,8 @@ void AEndlessVendettaCharacter::EquipSecondary()
|
|||||||
|
|
||||||
if (IsValid(PrimaryWeapon)) EquipPrimary();
|
if (IsValid(PrimaryWeapon)) EquipPrimary();
|
||||||
|
|
||||||
if (GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;
|
if (GadgetManager->IsValidReconGadget() && GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;
|
||||||
if (GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;
|
if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;
|
||||||
|
|
||||||
|
|
||||||
FActorSpawnParameters spawnParams;
|
FActorSpawnParameters spawnParams;
|
||||||
@ -417,3 +420,16 @@ bool AEndlessVendettaCharacter::GetHasRifle()
|
|||||||
{
|
{
|
||||||
return bHasRifle;
|
return bHasRifle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AEndlessVendettaCharacter::UpdateGadgetType(TSubclassOf<AGadgetBase> NewGadgetClass)
|
||||||
|
{
|
||||||
|
if (NewGadgetClass.GetDefaultObject()->IsA(AReconGadget::StaticClass()) && GadgetManager->CantReplaceReconGadget()) return;
|
||||||
|
if (NewGadgetClass.GetDefaultObject()->IsA(ACombatGadget::StaticClass()) && GadgetManager->CantReplaceCombatGadget()) return;
|
||||||
|
|
||||||
|
for (UActorComponent* PlayersCamera : GetComponentsByTag(UCameraComponent::StaticClass(), FName("PlayersCamera")))
|
||||||
|
{
|
||||||
|
GadgetManager->SpawnGadget(NewGadgetClass, Cast<UCameraComponent>(PlayersCamera));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -180,4 +180,6 @@ public:
|
|||||||
|
|
||||||
UFUNCTION(BlueprintImplementableEvent)
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
void CheckpointCompletedUI();
|
void CheckpointCompletedUI();
|
||||||
|
|
||||||
|
void UpdateGadgetType(TSubclassOf<AGadgetBase> NewGadgetClass);
|
||||||
};
|
};
|
||||||
|
@ -109,6 +109,16 @@ public:
|
|||||||
{
|
{
|
||||||
return GadgetName;
|
return GadgetName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsUnequippableInUse()
|
||||||
|
{
|
||||||
|
return UnequippableWhenInUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsInUse()
|
||||||
|
{
|
||||||
|
return GadgetInUse;
|
||||||
|
}
|
||||||
// Sets default values for this actor's properties
|
// Sets default values for this actor's properties
|
||||||
AGadgetBase();
|
AGadgetBase();
|
||||||
|
|
||||||
|
@ -25,23 +25,27 @@ void AGadgetManager::Tick(float DeltaTime)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AGadgetManager::SpawnGadgets(USceneComponent* PlayersCameraComponent)
|
void AGadgetManager::SpawnGadgetsOnBeginPlay(USceneComponent* PlayersCameraComponent)
|
||||||
{
|
{
|
||||||
if (!IsValid(ReconClass) || !IsValid(CombatClass)) UE_LOG(LogTemp, Fatal, TEXT("Recon or Combat class hasn't been set"));
|
if (IsValid(ReconClass)) SpawnGadget(ReconClass, PlayersCameraComponent);
|
||||||
|
if (IsValid(CombatClass)) SpawnGadget(CombatClass, PlayersCameraComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AGadgetManager::SpawnGadget(TSubclassOf<AGadgetBase> GadgetClass, USceneComponent* PlayersCameraComponent)
|
||||||
|
{
|
||||||
FActorSpawnParameters SpawnParams;
|
FActorSpawnParameters SpawnParams;
|
||||||
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||||
const FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true);
|
const FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true);
|
||||||
|
|
||||||
AActor* SpawnedActor = GetWorld()->SpawnActor<AActor>(ReconClass, GetActorLocation(), GetActorRotation(), SpawnParams);
|
AActor* SpawnedActor = GetWorld()->SpawnActor<AActor>(GadgetClass, GetActorLocation(), GetActorRotation(), SpawnParams);
|
||||||
ReconGadget = Cast<AReconGadget>(SpawnedActor);
|
|
||||||
SpawnedActor->AttachToComponent(PlayersCameraComponent, AttachmentRules);
|
|
||||||
SpawnedActor->SetActorRelativeLocation(ReconGadget->GetUnequippedOffset());
|
|
||||||
SpawnedActor->SetActorRelativeRotation(ReconGadget->GetGadgetSpawnRotation());
|
|
||||||
|
|
||||||
SpawnedActor = GetWorld()->SpawnActor<AActor>(CombatClass, GetActorLocation(), GetActorRotation(), SpawnParams);
|
if (SpawnedActor->IsA(AReconGadget::StaticClass())) ReconGadget = Cast<AReconGadget>(SpawnedActor);
|
||||||
CombatGadget = Cast<ACombatGadget>(SpawnedActor);
|
else if (SpawnedActor->IsA(ACombatGadget::StaticClass())) CombatGadget = Cast<ACombatGadget>(SpawnedActor);
|
||||||
SpawnedActor->AttachToComponent(PlayersCameraComponent, AttachmentRules);
|
else UE_LOG(LogTemp, Fatal, TEXT("Passed sub class of gadget base is neither a combat or recon gadget, check the gadget class you're passing through or contact Rafal"));
|
||||||
SpawnedActor->SetActorRelativeLocation(CombatGadget->GetUnequippedOffset());
|
|
||||||
SpawnedActor->SetActorRelativeRotation(CombatGadget->GetGadgetSpawnRotation());
|
AGadgetBase* BaseGadget = Cast<AGadgetBase>(SpawnedActor);
|
||||||
|
BaseGadget->AttachToComponent(PlayersCameraComponent, AttachmentRules);
|
||||||
|
BaseGadget->SetActorRelativeLocation(BaseGadget->GetUnequippedOffset());
|
||||||
|
BaseGadget->SetActorRelativeRotation(BaseGadget->GetGadgetSpawnRotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,9 @@ protected:
|
|||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void SpawnGadgets(USceneComponent* PlayersCameraComponent);
|
void SpawnGadgetsOnBeginPlay(USceneComponent* PlayersCameraComponent);
|
||||||
|
|
||||||
|
void SpawnGadget(TSubclassOf<AGadgetBase> GadgetClass, USceneComponent* PlayersCameraComponent);
|
||||||
|
|
||||||
// Sets default values for this actor's properties
|
// Sets default values for this actor's properties
|
||||||
AGadgetManager();
|
AGadgetManager();
|
||||||
@ -34,6 +36,16 @@ public:
|
|||||||
// Called every frame
|
// Called every frame
|
||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
|
bool IsValidReconGadget()
|
||||||
|
{
|
||||||
|
return IsValid(ReconGadget);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsValidCombatGadget()
|
||||||
|
{
|
||||||
|
return IsValid(CombatGadget);
|
||||||
|
}
|
||||||
|
|
||||||
void EquipRecon()
|
void EquipRecon()
|
||||||
{
|
{
|
||||||
ReconGadget->Equip();
|
ReconGadget->Equip();
|
||||||
@ -66,4 +78,16 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CantReplaceReconGadget()
|
||||||
|
{
|
||||||
|
// Cant be replaced if it exists, and is either in use whilst being unequippable in use, or equipped and cant be unequipped
|
||||||
|
return IsValidReconGadget() && (ReconGadget->IsInUse() && ReconGadget->IsUnequippableInUse() || IsReconEquipped() && !TryToUnequipRecon());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CantReplaceCombatGadget()
|
||||||
|
{
|
||||||
|
// Cant be replaced if it exists, and is either in use whilst being unequippable in use, or equipped and cant be unequipped
|
||||||
|
return IsValidCombatGadget() && (CombatGadget->IsInUse() && CombatGadget->IsUnequippableInUse() || IsCombatEquipped() && !TryToUnequipCombat());
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -18,6 +18,7 @@ void AGadgetTutorialStation::BeginPlay()
|
|||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
EndlessVendettaCharacter = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every frame
|
// Called every frame
|
||||||
@ -47,6 +48,9 @@ void AGadgetTutorialStation::Interact()
|
|||||||
GadgetMenu->NextGadgetDelegate.AddDynamic(this, &AGadgetTutorialStation::NextGadget);
|
GadgetMenu->NextGadgetDelegate.AddDynamic(this, &AGadgetTutorialStation::NextGadget);
|
||||||
GadgetMenu->PreviousGadgetDelegate.AddDynamic(this, &AGadgetTutorialStation::PreviousGadget);
|
GadgetMenu->PreviousGadgetDelegate.AddDynamic(this, &AGadgetTutorialStation::PreviousGadget);
|
||||||
GadgetMenu->SelectGadgetDelegate.AddDynamic(this, &AGadgetTutorialStation::SelectGadget);
|
GadgetMenu->SelectGadgetDelegate.AddDynamic(this, &AGadgetTutorialStation::SelectGadget);
|
||||||
|
|
||||||
|
// Runs Update Display Gadget at the end which overrides the default stand in gadget info
|
||||||
|
NextGadget();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AGadgetTutorialStation::InteractPrompt()
|
void AGadgetTutorialStation::InteractPrompt()
|
||||||
@ -86,7 +90,8 @@ void AGadgetTutorialStation::SelectGadget()
|
|||||||
// Despawn current gadgetRange
|
// Despawn current gadgetRange
|
||||||
// Spawn in the correct gadget range for the gadget
|
// Spawn in the correct gadget range for the gadget
|
||||||
|
|
||||||
UE_LOG(LogTemp, Warning, TEXT("Gadget Selected: %s"), *GadgetsArray[GadgetIndex]->GetDefaultObject<AGadgetBase>()->GetGadgetName());
|
EndlessVendettaCharacter->UpdateGadgetType(GadgetsArray[GadgetIndex]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AGadgetTutorialStation::CloseWidget()
|
void AGadgetTutorialStation::CloseWidget()
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
#include "EndlessVendetta/EndlessVendettaCharacter.h"
|
||||||
#include "EndlessVendetta/GadgetSystem/GadgetBase.h"
|
#include "EndlessVendetta/GadgetSystem/GadgetBase.h"
|
||||||
#include "EndlessVendetta/InteractionInterface.h"
|
#include "EndlessVendetta/InteractionInterface.h"
|
||||||
#include "EndlessVendetta/UserWidgets/GadgetMenu.h"
|
#include "EndlessVendetta/UserWidgets/GadgetMenu.h"
|
||||||
@ -14,6 +15,8 @@ class ENDLESSVENDETTA_API AGadgetTutorialStation : public AActor, public IIntera
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
AEndlessVendettaCharacter* EndlessVendettaCharacter;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, Category = "Gadgets")
|
UPROPERTY(EditDefaultsOnly, Category = "Gadgets")
|
||||||
TArray<TSubclassOf<AGadgetBase>> GadgetsArray;
|
TArray<TSubclassOf<AGadgetBase>> GadgetsArray;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user