Started Working on UI for Overload Module

This commit is contained in:
Rafal Swierczek 2023-10-06 19:58:51 +01:00
parent 588b2e5a91
commit 6bcc703974
10 changed files with 38 additions and 28 deletions

Binary file not shown.

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c546719195bfec717a1ea448ffd23e7eea15b3997b28a7bec6582c82fd6e0889
size 16032
oid sha256:f28aca2e17c3afa2dd55c79b5f66c1ea851dd8067e0712fbc9677ca614f8c927
size 16005

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7d61bb4d0a3f7c25b8901699a8047059fb83a255d89990a5b366410f51d23792
size 23259
oid sha256:599c54946bc53ff3d3ee06fc5c1e8322aa69d8a54380df1e8a63a41c5aefed46
size 22249

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1fa538706ad1bf961d40e82afa4e2ff2937e4377d353f0db4b46cd1599609d19
size 25427

Binary file not shown.

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f27623f7de4cd3ffafc332f52d32f9d58031dad0ba48c3954472553188926618
oid sha256:35b4a02d71c80d38b36dd3e41dcc099477704b99bd7e2785129503a80a20e67e
size 106253

Binary file not shown.

View File

@ -30,9 +30,11 @@ void AOverloadModule::CheckForPotentialHackTarget()
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);
if (!GetWorld()->LineTraceSingleByChannel(OutHit, LT_Start, LT_End, ECC_Camera) || !(OutHit.GetActor()->ActorHasTag(FName("Enemy")) && OutHit.GetActor()->ActorHasTag(FName("Dead"))))
//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();
@ -41,11 +43,13 @@ void AOverloadModule::CheckForPotentialHackTarget()
if (HackedEnemies.Contains(OutHit.GetActor()->GetUniqueID()))
{
UE_LOG(LogTemp, Warning, TEXT("Enemy has already been hacked!"));
PotentialHackTarget = nullptr;
DisplayAlreadyHacked();
return;
}
DrawDebugLine(GetWorld(), LT_Start, OutHit.ImpactPoint, FColor::Green, false, 0.2, 0, 1);
//DrawDebugLine(GetWorld(), LT_Start, OutHit.ImpactPoint, FColor::Green, false, 0.2, 0, 1);
PotentialHackTarget = OutHit.GetActor();
DisplayFoundPotentialTarget();
}
@ -58,6 +62,7 @@ void AOverloadModule::Activate()
Super::Activate();
HackedEnemies.Add(PotentialHackTarget->GetUniqueID());
ExplodeClosestAliveEnemy();
PlayHackingAnim(GadgetMaxUptime);
}
void AOverloadModule::FinishedUsing()
@ -67,10 +72,8 @@ void AOverloadModule::FinishedUsing()
void AOverloadModule::ExplodeClosestAliveEnemy()
{
FActorSpawnParameters SpawnParams;
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
AActor* SphereCollisionActor = GetWorld()->SpawnActor<AActor>(USphereComponent::StaticClass(), PlayerChar->GetActorLocation(), PlayerChar->GetActorRotation(), SpawnParams);
USphereComponent* SphereCollision = Cast<USphereComponent>(SphereCollisionActor);
FTransform EmptyTransform;
USphereComponent* SphereCollision = Cast<USphereComponent>(AddComponentByClass(USphereComponent::StaticClass(), false, EmptyTransform, false));
SphereCollision->SetHiddenInGame(false);
SphereCollision->SetSphereRadius(AreaOfEffectInMeters * 100, true);
@ -94,10 +97,9 @@ void AOverloadModule::ExplodeClosestAliveEnemy()
// Find the closest Enemy in radius
AActor* ClosestEnemy = EnemiesInRadius[0];
float Dist = FVector::Distance(PlayerChar->GetActorLocation(), ClosestEnemy->GetActorLocation());
UE_LOG(LogTemp, Warning, TEXT("Distacne To first Considered Enemy = %f"), Dist);
if (EnemiesInRadius.Num() < 2)
{
SpawnExplosiveOnActor(ClosestEnemy, SpawnParams);
SpawnExplosiveOnActor(ClosestEnemy);
return;
}
@ -111,12 +113,14 @@ void AOverloadModule::ExplodeClosestAliveEnemy()
}
}
SpawnExplosiveOnActor(ClosestEnemy, SpawnParams);
SpawnExplosiveOnActor(ClosestEnemy);
}
void AOverloadModule::SpawnExplosiveOnActor(AActor* ActortoExplode, FActorSpawnParameters SpawnParams)
void AOverloadModule::SpawnExplosiveOnActor(AActor* ActortoExplode)
{
FActorSpawnParameters SpawnParams;
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
GetWorld()->SpawnActor<AActor>(Explosive, ActortoExplode->GetActorLocation(), ActortoExplode->GetActorRotation(), SpawnParams);
}

View File

@ -37,14 +37,14 @@ class ENDLESSVENDETTA_API AOverloadModule : public ACombatGadget
void ExplodeClosestAliveEnemy();
void SpawnExplosiveOnActor(AActor* ActortoExplode, FActorSpawnParameters SpawnParams);
void SpawnExplosiveOnActor(AActor* ActortoExplode);
protected:
UPROPERTY(EditDefaultsOnly, Category = "Overload Module")
float AreaOfEffectInMeters = 15;
float AreaOfEffectInMeters = 20;
UPROPERTY(EditDefaultsOnly, Category = "Overload Module")
float DeadBodyCheckDistance = 300;
float DeadBodyCheckDistance = 250;
UPROPERTY(EditDefaultsOnly, Category = "Overload Module")
TSubclassOf<AExplosive> Explosive;
@ -61,4 +61,7 @@ protected:
UFUNCTION(BlueprintImplementableEvent, Category = "Overload Module")
void DisplayFailedToFindTarget();
UFUNCTION(BlueprintImplementableEvent, Category = "Overload Module")
void PlayHackingAnim(float Loadingtime);
};