Implemented Ring Module Class Functionality
This commit is contained in:
parent
9d36fa7846
commit
2a9e30108d
BIN
EndlessVendetta/Content/Gadgets/CombatGadgets/OverloadModule/CG_OverloadModule.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/Gadgets/CombatGadgets/OverloadModule/CG_OverloadModule.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:2bc44125551b89f13cdffde72a42c09685d26b6bbaa3ce8d28858ab14d83c0dc
|
oid sha256:77cadba64fcbb3018eab09695343339696bd1a1fbcfb39ee13aca7d57c7b4bab
|
||||||
size 108254
|
size 108254
|
||||||
|
BIN
EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/StarterContent/Particles/P_Ambient_Dust.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/StarterContent/Particles/P_Ambient_Dust.uasset
(Stored with Git LFS)
Binary file not shown.
@ -43,7 +43,6 @@ void AOverloadModule::CheckForPotentialHackTarget()
|
|||||||
|
|
||||||
if (HackedEnemies.Contains(OutHit.GetActor()->GetUniqueID()))
|
if (HackedEnemies.Contains(OutHit.GetActor()->GetUniqueID()))
|
||||||
{
|
{
|
||||||
UE_LOG(LogTemp, Warning, TEXT("Enemy has already been hacked!"));
|
|
||||||
PotentialHackTarget = nullptr;
|
PotentialHackTarget = nullptr;
|
||||||
DisplayAlreadyHacked();
|
DisplayAlreadyHacked();
|
||||||
return;
|
return;
|
||||||
@ -77,8 +76,7 @@ void AOverloadModule::ExplodeClosestAliveEnemy()
|
|||||||
{
|
{
|
||||||
FTransform EmptyTransform;
|
FTransform EmptyTransform;
|
||||||
USphereComponent* SphereCollision = Cast<USphereComponent>(AddComponentByClass(USphereComponent::StaticClass(), false, EmptyTransform, false));
|
USphereComponent* SphereCollision = Cast<USphereComponent>(AddComponentByClass(USphereComponent::StaticClass(), false, EmptyTransform, false));
|
||||||
|
|
||||||
SphereCollision->SetHiddenInGame(false);
|
|
||||||
SphereCollision->SetSphereRadius(AreaOfEffectInMeters * 100, true);
|
SphereCollision->SetSphereRadius(AreaOfEffectInMeters * 100, true);
|
||||||
|
|
||||||
TArray<AActor*> OverlappingActors;
|
TArray<AActor*> OverlappingActors;
|
||||||
|
@ -0,0 +1,99 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "RingModule.h"
|
||||||
|
|
||||||
|
#include "Components/SphereComponent.h"
|
||||||
|
#include "GameFramework/Character.h"
|
||||||
|
|
||||||
|
void ARingModule::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
this->SetActorTickInterval(0.2);
|
||||||
|
PlayerChar = GetWorld()->GetFirstPlayerController()->GetCharacter();
|
||||||
|
PlayerCam = Cast<UCameraComponent>(PlayerChar->GetComponentByClass(UCameraComponent::StaticClass()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ARingModule::Tick(float DeltaSeconds)
|
||||||
|
{
|
||||||
|
Super::Tick(DeltaSeconds);
|
||||||
|
|
||||||
|
if (GadgetCantBeUsed()) return;
|
||||||
|
CheckForPotentialHackTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ARingModule::CheckForPotentialHackTarget()
|
||||||
|
{
|
||||||
|
FHitResult OutHit;
|
||||||
|
FVector LT_Start = PlayerCam->GetComponentLocation();
|
||||||
|
FVector LT_End = PlayerCam->GetComponentLocation() + (PlayerCam->GetForwardVector() * DeadBodyCheckDistance);
|
||||||
|
|
||||||
|
//DrawDebugLine(GetWorld(), LT_Start, LT_End, FColor::Red, false, 0.2, 0, 1);
|
||||||
|
|
||||||
|
FCollisionQueryParams QueryParams = FCollisionQueryParams::DefaultQueryParam;
|
||||||
|
QueryParams.AddIgnoredActor(PlayerChar);
|
||||||
|
if (!GetWorld()->LineTraceSingleByChannel(OutHit, LT_Start, LT_End, ECC_Camera, QueryParams) || !(OutHit.GetActor()->ActorHasTag(FName("Enemy")) && OutHit.GetActor()->ActorHasTag(FName("Dead"))))
|
||||||
|
{
|
||||||
|
PotentialHackTarget = nullptr;
|
||||||
|
DisplayNeedADeadEnemy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HackedEnemies.Contains(OutHit.GetActor()->GetUniqueID()))
|
||||||
|
{
|
||||||
|
PotentialHackTarget = nullptr;
|
||||||
|
DisplayAlreadyHacked();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//DrawDebugLine(GetWorld(), LT_Start, OutHit.ImpactPoint, FColor::Green, false, 0.2, 0, 1);
|
||||||
|
PotentialHackTarget = OutHit.GetActor();
|
||||||
|
DisplayFoundPotentialTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ARingModule::Activate()
|
||||||
|
{
|
||||||
|
if (GadgetCantBeUsed() || !IsValid(PotentialHackTarget)) return;
|
||||||
|
|
||||||
|
Super::Activate();
|
||||||
|
HackedEnemies.Add(PotentialHackTarget->GetUniqueID());
|
||||||
|
PlayHackingAnim(GadgetMaxUptime);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ARingModule::FinishedUsing()
|
||||||
|
{
|
||||||
|
SpawnRingingPhoneForAllNearbyEnemies() ? DisplayHackingSuccess() : DisplayHackingFailure();
|
||||||
|
Super::FinishedUsing();
|
||||||
|
PlayRechargingAnim(CooldownTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ARingModule::SpawnRingingPhoneForAllNearbyEnemies()
|
||||||
|
{
|
||||||
|
FTransform EmptyTransform;
|
||||||
|
USphereComponent* SphereCollision = Cast<USphereComponent>(AddComponentByClass(USphereComponent::StaticClass(), false, EmptyTransform, false));
|
||||||
|
SphereCollision->SetSphereRadius(AreaOfEffectInMeters * 100, true);
|
||||||
|
|
||||||
|
TArray<AActor*> OverlappingActors;
|
||||||
|
TArray<AActor*> EnemiesInRadius;
|
||||||
|
|
||||||
|
SphereCollision->GetOverlappingActors(OverlappingActors, ACharacter::StaticClass());
|
||||||
|
for (AActor* OverlappingActor : OverlappingActors)
|
||||||
|
{
|
||||||
|
if (OverlappingActor->ActorHasTag(FName("Enemy")) && !OverlappingActor->ActorHasTag(FName("Dead"))) EnemiesInRadius.Add(OverlappingActor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EnemiesInRadius.IsEmpty())
|
||||||
|
{
|
||||||
|
SphereCollision->DestroyComponent();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (AActor* Enemy : EnemiesInRadius)
|
||||||
|
{
|
||||||
|
//Dont Forget to spawn in phone ringing
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("%s's phone is ringing!!!"), *Enemy->GetName());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "EndlessVendetta/GadgetSystem/ReconGadget.h"
|
||||||
|
#include "Camera/CameraComponent.h"
|
||||||
|
#include "RingModule.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class ENDLESSVENDETTA_API ARingModule : public AReconGadget
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
ACharacter* PlayerChar;
|
||||||
|
|
||||||
|
UCameraComponent* PlayerCam;
|
||||||
|
|
||||||
|
AActor* PotentialHackTarget;
|
||||||
|
|
||||||
|
// An Array of previously hacked enemies, stops player from hacking the same Dead Enemy
|
||||||
|
TArray<uint32> HackedEnemies;
|
||||||
|
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
virtual void Tick(float DeltaSeconds) override;
|
||||||
|
|
||||||
|
virtual void Activate() override;
|
||||||
|
|
||||||
|
virtual void FinishedUsing() override;
|
||||||
|
|
||||||
|
void CheckForPotentialHackTarget();
|
||||||
|
|
||||||
|
// Returns false if there are no nearby enemies
|
||||||
|
bool SpawnRingingPhoneForAllNearbyEnemies();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
UPROPERTY(EditDefaultsOnly, Category = "Overload Module")
|
||||||
|
float AreaOfEffectInMeters = 20;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, Category = "Overload Module")
|
||||||
|
float DeadBodyCheckDistance = 250;
|
||||||
|
|
||||||
|
// --------------- Display Functions ---------------
|
||||||
|
UFUNCTION(BlueprintImplementableEvent, Category = "Overload Module")
|
||||||
|
void DisplayAlreadyHacked();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintImplementableEvent, Category = "Overload Module")
|
||||||
|
void DisplayNeedADeadEnemy();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintImplementableEvent, Category = "Overload Module")
|
||||||
|
void DisplayFoundPotentialTarget();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintImplementableEvent, Category = "Overload Module")
|
||||||
|
void PlayHackingAnim(float Loadingtime);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintImplementableEvent, Category = "Overload Module")
|
||||||
|
void DisplayHackingFailure();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintImplementableEvent, Category = "Overload Module")
|
||||||
|
void DisplayHackingSuccess();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintImplementableEvent, Category = "Overload Module")
|
||||||
|
void PlayRechargingAnim(float RechargingTime);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user