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
|
||||
oid sha256:46c1dbc7d35d69ea66831390e74563f3dc3dfbdcdc2c09fa0887195d6c231104
|
||||
size 460293
|
||||
oid sha256:5865096b570bd55d2eb3055389ccd4c7f9db407bb3f830746a5736a47d34253a
|
||||
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);
|
||||
for (UActorComponent* PlayersCamera : GetComponentsByTag(UCameraComponent::StaticClass(), FName("PlayersCamera")))
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("An actor component with PlayersCamera tag has been found"));
|
||||
GadgetManager->SpawnGadgets(Cast<USceneComponent>(PlayersCamera));
|
||||
GadgetManager->SpawnGadgetsOnBeginPlay(Cast<USceneComponent>(PlayersCamera));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -181,6 +180,8 @@ float AEndlessVendettaCharacter::TakeDamage(const float DamageAmount, FDamageEve
|
||||
|
||||
void AEndlessVendettaCharacter::ToggleRecon()
|
||||
{
|
||||
if (!GadgetManager->IsValidReconGadget()) return;
|
||||
|
||||
if (IsValid(PrimaryWeapon)) EquipPrimary();
|
||||
if (IsValid(SecondaryWeapon)) EquipSecondary();
|
||||
|
||||
@ -190,7 +191,7 @@ void AEndlessVendettaCharacter::ToggleRecon()
|
||||
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
|
||||
return;
|
||||
@ -201,6 +202,8 @@ void AEndlessVendettaCharacter::ToggleRecon()
|
||||
|
||||
void AEndlessVendettaCharacter::ToggleCombat()
|
||||
{
|
||||
if(!GadgetManager->IsValidCombatGadget()) return;
|
||||
|
||||
if (IsValid(PrimaryWeapon)) EquipPrimary();
|
||||
if (IsValid(SecondaryWeapon)) EquipSecondary();
|
||||
|
||||
@ -210,7 +213,7 @@ void AEndlessVendettaCharacter::ToggleCombat()
|
||||
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
|
||||
return;
|
||||
@ -235,8 +238,8 @@ void AEndlessVendettaCharacter::EquipPrimary()
|
||||
|
||||
if (IsValid(SecondaryWeapon)) EquipSecondary();
|
||||
|
||||
if (GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;
|
||||
if (GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;
|
||||
if (GadgetManager->IsValidReconGadget() && GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;
|
||||
if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;
|
||||
|
||||
|
||||
FActorSpawnParameters spawnParams;
|
||||
@ -267,8 +270,8 @@ void AEndlessVendettaCharacter::EquipSecondary()
|
||||
|
||||
if (IsValid(PrimaryWeapon)) EquipPrimary();
|
||||
|
||||
if (GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;
|
||||
if (GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;
|
||||
if (GadgetManager->IsValidReconGadget() && GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;
|
||||
if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;
|
||||
|
||||
|
||||
FActorSpawnParameters spawnParams;
|
||||
@ -417,3 +420,16 @@ bool AEndlessVendettaCharacter::GetHasRifle()
|
||||
{
|
||||
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)
|
||||
void CheckpointCompletedUI();
|
||||
|
||||
void UpdateGadgetType(TSubclassOf<AGadgetBase> NewGadgetClass);
|
||||
};
|
||||
|
@ -109,6 +109,16 @@ public:
|
||||
{
|
||||
return GadgetName;
|
||||
}
|
||||
|
||||
bool IsUnequippableInUse()
|
||||
{
|
||||
return UnequippableWhenInUse;
|
||||
}
|
||||
|
||||
bool IsInUse()
|
||||
{
|
||||
return GadgetInUse;
|
||||
}
|
||||
// Sets default values for this actor's properties
|
||||
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;
|
||||
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||
const FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true);
|
||||
|
||||
AActor* SpawnedActor = GetWorld()->SpawnActor<AActor>(ReconClass, GetActorLocation(), GetActorRotation(), SpawnParams);
|
||||
ReconGadget = Cast<AReconGadget>(SpawnedActor);
|
||||
SpawnedActor->AttachToComponent(PlayersCameraComponent, AttachmentRules);
|
||||
SpawnedActor->SetActorRelativeLocation(ReconGadget->GetUnequippedOffset());
|
||||
SpawnedActor->SetActorRelativeRotation(ReconGadget->GetGadgetSpawnRotation());
|
||||
AActor* SpawnedActor = GetWorld()->SpawnActor<AActor>(GadgetClass, GetActorLocation(), GetActorRotation(), SpawnParams);
|
||||
|
||||
if (SpawnedActor->IsA(AReconGadget::StaticClass())) ReconGadget = Cast<AReconGadget>(SpawnedActor);
|
||||
else if (SpawnedActor->IsA(ACombatGadget::StaticClass())) CombatGadget = Cast<ACombatGadget>(SpawnedActor);
|
||||
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 = GetWorld()->SpawnActor<AActor>(CombatClass, GetActorLocation(), GetActorRotation(), SpawnParams);
|
||||
CombatGadget = Cast<ACombatGadget>(SpawnedActor);
|
||||
SpawnedActor->AttachToComponent(PlayersCameraComponent, AttachmentRules);
|
||||
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;
|
||||
|
||||
public:
|
||||
void SpawnGadgets(USceneComponent* PlayersCameraComponent);
|
||||
void SpawnGadgetsOnBeginPlay(USceneComponent* PlayersCameraComponent);
|
||||
|
||||
void SpawnGadget(TSubclassOf<AGadgetBase> GadgetClass, USceneComponent* PlayersCameraComponent);
|
||||
|
||||
// Sets default values for this actor's properties
|
||||
AGadgetManager();
|
||||
@ -34,6 +36,16 @@ public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
bool IsValidReconGadget()
|
||||
{
|
||||
return IsValid(ReconGadget);
|
||||
}
|
||||
|
||||
bool IsValidCombatGadget()
|
||||
{
|
||||
return IsValid(CombatGadget);
|
||||
}
|
||||
|
||||
void EquipRecon()
|
||||
{
|
||||
ReconGadget->Equip();
|
||||
@ -66,4 +78,16 @@ public:
|
||||
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());
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -17,7 +17,8 @@ AGadgetTutorialStation::AGadgetTutorialStation()
|
||||
void AGadgetTutorialStation::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
|
||||
EndlessVendettaCharacter = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn());
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
@ -47,6 +48,9 @@ void AGadgetTutorialStation::Interact()
|
||||
GadgetMenu->NextGadgetDelegate.AddDynamic(this, &AGadgetTutorialStation::NextGadget);
|
||||
GadgetMenu->PreviousGadgetDelegate.AddDynamic(this, &AGadgetTutorialStation::PreviousGadget);
|
||||
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()
|
||||
@ -86,7 +90,8 @@ void AGadgetTutorialStation::SelectGadget()
|
||||
// Despawn current gadgetRange
|
||||
// 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()
|
||||
|
@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "EndlessVendetta/EndlessVendettaCharacter.h"
|
||||
#include "EndlessVendetta/GadgetSystem/GadgetBase.h"
|
||||
#include "EndlessVendetta/InteractionInterface.h"
|
||||
#include "EndlessVendetta/UserWidgets/GadgetMenu.h"
|
||||
@ -14,6 +15,8 @@ class ENDLESSVENDETTA_API AGadgetTutorialStation : public AActor, public IIntera
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
AEndlessVendettaCharacter* EndlessVendettaCharacter;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Gadgets")
|
||||
TArray<TSubclassOf<AGadgetBase>> GadgetsArray;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user