Merge branch 'BugFixes' into dev

This commit is contained in:
RAFAL SWIERCZEK 2023-11-30 11:15:02 +00:00
commit 8e5fd68b83
11 changed files with 21 additions and 125 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,7 +6,7 @@
#include "CollisionDebugDrawingPublic.h" #include "CollisionDebugDrawingPublic.h"
#include "Kismet/KismetMathLibrary.h" #include "Kismet/KismetMathLibrary.h"
#include "Camera/CameraComponent.h" #include "Camera/CameraComponent.h"
#include "VisionLinkEnemyLOSTest.h" #include "EndlessVendetta/EndlessVendettaCharacter.h"
#include "GameFramework/Character.h" #include "GameFramework/Character.h"
void AVisionLink::BeginPlay() void AVisionLink::BeginPlay()
@ -47,9 +47,16 @@ void AVisionLink::SendOutPingPulse()
GetWorld()->GetTimerManager().SetTimer(PulseHandle, this, &AVisionLink::SendOutPingPulse, TimeInbetweenPingPulses, false); GetWorld()->GetTimerManager().SetTimer(PulseHandle, this, &AVisionLink::SendOutPingPulse, TimeInbetweenPingPulses, false);
PlayPingPulseAnim(TimeInbetweenPingPulses); PlayPingPulseAnim(TimeInbetweenPingPulses);
UCameraComponent* PlayerCamComp = Cast<UCameraComponent>(GetWorld()->GetFirstPlayerController()->GetCharacter()->GetComponentByClass(UCameraComponent::StaticClass())); ACharacter* PlayersCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter();
UCameraComponent* PlayerCamComp = Cast<UCameraComponent>(PlayersCharacter->GetComponentByClass(UCameraComponent::StaticClass()));
// Ignored Actors
TArray<AActor*> ActorsToIgnore; TArray<AActor*> ActorsToIgnore;
ActorsToIgnore.Add(GetWorld()->GetFirstPlayerController()->GetCharacter()); AEndlessVendettaCharacter* EV_Character = Cast<AEndlessVendettaCharacter>(PlayersCharacter);
if ( IsValid(EV_Character) && IsValid(EV_Character->PrimaryWeaponActor)) ActorsToIgnore.Add(EV_Character->PrimaryWeaponActor);
if ( IsValid(EV_Character) && IsValid(EV_Character->SecondaryWeaponActor)) ActorsToIgnore.Add(EV_Character->SecondaryWeaponActor);
ActorsToIgnore.Add(PlayersCharacter);
TestLOS(PlayerCamComp->GetComponentTransform(), ActorsToIgnore); TestLOS(PlayerCamComp->GetComponentTransform(), ActorsToIgnore);
} }
@ -75,7 +82,7 @@ void AVisionLink::TestLOS(FTransform StartingPos, TArray<AActor*> &ActorsToIgnor
if (!GetWorld()->LineTraceSingleByChannel(outHit, StartingPos.GetLocation(), LT_EndPoint, ECC_Camera, QueryParams)) continue; if (!GetWorld()->LineTraceSingleByChannel(outHit, StartingPos.GetLocation(), LT_EndPoint, ECC_Camera, QueryParams)) continue;
AActor* HitActor = outHit.GetActor(); AActor* HitActor = outHit.GetActor();
if (!HitActor->ActorHasTag(FName("Enemy"))) continue; if (!HitActor->ActorHasTag(FName("Enemy")) || HitActor->ActorHasTag("Dead")) continue;
//DrawDebugLine(GetWorld(), outHit.TraceStart, outHit.ImpactPoint, FColor::Blue, false, 3, 0, 3); //DrawDebugLine(GetWorld(), outHit.TraceStart, outHit.ImpactPoint, FColor::Blue, false, 3, 0, 3);
ActorsToIgnore.Add(HitActor); ActorsToIgnore.Add(HitActor);

View File

@ -3,7 +3,6 @@
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "VisionLinkEnemyLOSTest.h"
#include "EndlessVendetta/GadgetSystem/ReconGadget.h" #include "EndlessVendetta/GadgetSystem/ReconGadget.h"
#include "VisionLink.generated.h" #include "VisionLink.generated.h"

View File

@ -1,74 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "VisionLinkEnemyLOSTest.h"
#include "Components/BoxComponent.h"
#include "Kismet/KismetMathLibrary.h"
// Sets default values
AVisionLinkEnemyLOSTest::AVisionLinkEnemyLOSTest()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AVisionLinkEnemyLOSTest::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AVisionLinkEnemyLOSTest::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void AVisionLinkEnemyLOSTest::TestLOS(TArray<uint32> EnemiesInLink, AActor* LOSActor)
{
// Get all overlapping Actors
UBoxComponent* CollisionBox = Cast<UBoxComponent>(GetComponentByClass(UBoxComponent::StaticClass()));
if (!IsValid(CollisionBox))
{
Destroy();
return;
}
TArray<AActor*> OverlappingEnemies;
CollisionBox->GetOverlappingActors(OverlappingEnemies);
if (OverlappingEnemies.IsEmpty())
{
Destroy();
return;
}
for (int i = 0; i < OverlappingEnemies.Num(); i++)
{
// Overlapping Enemies Array should only contain enemies which aren't already in the link
if (!OverlappingEnemies[i]->ActorHasTag(FName("Enemy")) || EnemiesInLink.Contains(OverlappingEnemies[i]->GetUniqueID()))
{
UE_LOG(LogTemp, Warning, TEXT("enemy name: %s"), *OverlappingEnemies[i]->GetName());
OverlappingEnemies.RemoveAt(i);
}
}
if (OverlappingEnemies.IsEmpty())
{
Destroy();
return;
}
/*for (AActor* Enemy : OverlappingEnemies)
{
FRotator LookAtRotation = UKismetMathLibrary::FindLookAtRotation(LOSActor->GetActorLocation(), Enemy->GetActorLocation());
UE_LOG(LogTemp, Warning, TEXT("Look at Rotation: %f"), LookAtRotation.Yaw);
}*/
Destroy();
}

View File

@ -1,30 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "VisionLinkEnemyLOSTest.generated.h"
UCLASS()
class ENDLESSVENDETTA_API AVisionLinkEnemyLOSTest : public AActor
{
GENERATED_BODY()
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
UPROPERTY(EditDefaultsOnly, Category = "Vision Link")
float SpawnOffset = 0;
// Sets default values for this actor's properties
AVisionLinkEnemyLOSTest();
// Called every frame
virtual void Tick(float DeltaTime) override;
void TestLOS(TArray<uint32> EnemiesInLink, AActor* LOS_Actor);
};