Bugfix Soft Lock when Combat is Initialised on Dialogue or Merchant
This commit is contained in:
parent
ccb50a804e
commit
9c747a96c2
@ -49,6 +49,7 @@ void UInteractNPC::Interact()
|
|||||||
{
|
{
|
||||||
//DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 5.0f, 0, 10.0f);
|
//DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 5.0f, 0, 10.0f);
|
||||||
if (Cast<ATempCharacter>(GetOwner())->bShopKeeperText) return;
|
if (Cast<ATempCharacter>(GetOwner())->bShopKeeperText) return;
|
||||||
|
if (Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState())->bIsInCombat) return;
|
||||||
UDialogueNPC* DialogueNPC = HitResult.GetActor()->FindComponentByClass<UDialogueNPC>();
|
UDialogueNPC* DialogueNPC = HitResult.GetActor()->FindComponentByClass<UDialogueNPC>();
|
||||||
if (DialogueNPC->bIsInDialogue)
|
if (DialogueNPC->bIsInDialogue)
|
||||||
{
|
{
|
||||||
@ -61,3 +62,22 @@ void UInteractNPC::Interact()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UInteractNPC::EndInteract()
|
||||||
|
{
|
||||||
|
FVector Start = Cast<UCameraComponent>(GetOwner()->FindComponentByClass<UCameraComponent>())->GetComponentLocation();
|
||||||
|
FVector End = GetOwner()->GetActorForwardVector() * 300.0f + Start;
|
||||||
|
FCollisionQueryParams CollisionParams;
|
||||||
|
CollisionParams.AddIgnoredActor(GetOwner());
|
||||||
|
if (FHitResult HitResult; GetWorld()->LineTraceSingleByChannel(HitResult, Start, End, ECC_Pawn, CollisionParams))
|
||||||
|
{
|
||||||
|
//UE_LOG(LogTemp, Warning, TEXT("Hit: %s"), *HitResult.GetActor()->GetName());
|
||||||
|
if (HitResult.GetActor()->Tags.Contains("NPC"))
|
||||||
|
{
|
||||||
|
//DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 5.0f, 0, 10.0f);
|
||||||
|
UDialogueNPC* DialogueNPC = HitResult.GetActor()->FindComponentByClass<UDialogueNPC>();
|
||||||
|
DialogueNPC->EndDialogue();
|
||||||
|
}
|
||||||
|
//DrawDebugLine(GetWorld(), Start, End, FColor::Red, false, 5.0f, 0, 10.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -26,4 +26,7 @@ public:
|
|||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void Interact();
|
void Interact();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void EndInteract();
|
||||||
};
|
};
|
||||||
|
@ -114,6 +114,8 @@ void ATempCharacter::Tick(float DeltaTime)
|
|||||||
FVector WidgetLocation;
|
FVector WidgetLocation;
|
||||||
FirstPlayerController->DeprojectMousePositionToWorld(WidgetLocation, VectorRotation);
|
FirstPlayerController->DeprojectMousePositionToWorld(WidgetLocation, VectorRotation);
|
||||||
WidgetPointer->SetWorldLocationAndRotation(WidgetLocation, VectorRotation.Rotation().Quaternion());
|
WidgetPointer->SetWorldLocationAndRotation(WidgetLocation, VectorRotation.Rotation().Quaternion());
|
||||||
|
CrossHair->SetBrush(FSlateBrush());
|
||||||
|
CrossHair->SetDesiredSizeOverride(FVector2D(5, 5));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -242,6 +244,28 @@ void ATempCharacter::LineTraceLogic()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ATempCharacter::ExitMerchant()
|
||||||
|
{
|
||||||
|
ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
|
||||||
|
const float GlobalTrace = TraceDistance;
|
||||||
|
const FVector Start = ThisCamera->GetComponentLocation();
|
||||||
|
const FVector End = Start + GlobalTrace * ThisCamera->GetForwardVector();
|
||||||
|
FCollisionQueryParams TraceParams;
|
||||||
|
TraceParams.AddIgnoredActor(this);
|
||||||
|
bHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Pawn, TraceParams);
|
||||||
|
if (bHit)
|
||||||
|
{
|
||||||
|
if (OutHit.GetActor() == nullptr) return;
|
||||||
|
if (AInteraction* MyInteractable = Cast<AInteraction>(OutHit.GetActor()))
|
||||||
|
{
|
||||||
|
if (MyInteractable->ShopDialogWidget->IsVisible())
|
||||||
|
{
|
||||||
|
MyInteractable->ExitScreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ATempCharacter::AddToInventory()
|
void ATempCharacter::AddToInventory()
|
||||||
{
|
{
|
||||||
if (OutHit.GetActor()->FindComponentByClass<UInventoryComponent>())
|
if (OutHit.GetActor()->FindComponentByClass<UInventoryComponent>())
|
||||||
|
@ -56,7 +56,6 @@ public:
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = "true"))
|
||||||
class UInventoryComponent* Inventory; //Using the InventoryComponent class
|
class UInventoryComponent* Inventory; //Using the InventoryComponent class
|
||||||
|
|
||||||
|
|
||||||
// Called to bind functionality to input
|
// Called to bind functionality to input
|
||||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||||
|
|
||||||
@ -70,6 +69,9 @@ public:
|
|||||||
|
|
||||||
void LineTraceLogic();
|
void LineTraceLogic();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void ExitMerchant();
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
class UPawnNoiseEmitterComponent* NoiseEmitter;
|
class UPawnNoiseEmitterComponent* NoiseEmitter;
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
#include "Kismet/KismetMathLibrary.h"
|
#include "Kismet/KismetMathLibrary.h"
|
||||||
#include "Misc/OutputDeviceNull.h"
|
#include "Misc/OutputDeviceNull.h"
|
||||||
|
#include "the_twilight_abyss/Dialogue/InteractNPC.h"
|
||||||
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
|
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
|
||||||
#include "the_twilight_abyss/Quest/QuestSystem.h"
|
#include "the_twilight_abyss/Quest/QuestSystem.h"
|
||||||
|
|
||||||
@ -57,6 +58,15 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, const bool bWasShot)
|
|||||||
Cast<UQuestSystem>(PlayerActor->GetComponentByClass(UQuestSystem::StaticClass()))->QuestWidgetInstance->SetVisibility(ESlateVisibility::Hidden);
|
Cast<UQuestSystem>(PlayerActor->GetComponentByClass(UQuestSystem::StaticClass()))->QuestWidgetInstance->SetVisibility(ESlateVisibility::Hidden);
|
||||||
HealingJellyAmountTextBlock->SetText(FText::FromString(FString::FromInt(FMath::Clamp(Cast<ATempCharacter>(PlayerActor)->Inventory->GetItemAmount(0), 0, 99))));
|
HealingJellyAmountTextBlock->SetText(FText::FromString(FString::FromInt(FMath::Clamp(Cast<ATempCharacter>(PlayerActor)->Inventory->GetItemAmount(0), 0, 99))));
|
||||||
|
|
||||||
|
if (Cast<ATempCharacter>(PlayerActor)->bIsInDialogue)
|
||||||
|
{
|
||||||
|
Cast<UInteractNPC>(PlayerActor->GetComponentByClass(UInteractNPC::StaticClass()))->EndInteract();
|
||||||
|
}
|
||||||
|
if (Cast<ATempCharacter>(PlayerActor)->bShopKeeperText)
|
||||||
|
{
|
||||||
|
Cast<ATempCharacter>(PlayerActor)->ExitMerchant();
|
||||||
|
}
|
||||||
|
|
||||||
FOutputDeviceNull AR;
|
FOutputDeviceNull AR;
|
||||||
const FString Command = FString::Printf(TEXT("CloseInventory"));
|
const FString Command = FString::Printf(TEXT("CloseInventory"));
|
||||||
PlayerActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true);
|
PlayerActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user