Bugfix Initiating Combat with the Inventory Open Blocks Input

This commit is contained in:
Philip W 2023-05-21 15:20:11 +01:00
parent 14f4ff4d35
commit 5104a21b2f

View File

@ -48,8 +48,6 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, const bool bWasShot)
EnemyActor = Enemy;
StatusTextBlock->SetRenderOpacity(0.0f);
BookHUD->SetVisibility(ESlateVisibility::SelfHitTestInvisible);
Cast<ATempCharacter>(PlayerActor)->InventoryWidget->SetVisibility(ESlateVisibility::Hidden);
Cast<ATempCharacter>(PlayerActor)->EscapeMenuWidget->SetVisibility(ESlateVisibility::Hidden);
HUD->AddToViewport(-1);
BookStaticMeshComponent->SetVisibility(true);
EscapePercentage = CalculateEscapePercentage();
@ -59,6 +57,12 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, const bool bWasShot)
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))));
FOutputDeviceNull AR;
const FString Command = FString::Printf(TEXT("CloseInventory"));
PlayerActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true);
const FString Command69 = FString::Printf(TEXT("CloseEscapeMenu"));
PlayerActor->CallFunctionByNameWithArguments(*Command69, AR, nullptr, true);
//Disable Character Movement
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
PlayerController->SetIgnoreMoveInput(true);
@ -75,9 +79,8 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, const bool bWasShot)
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");
if (const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty); IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor))
{
FOutputDeviceNull AR;
const FString Command = FString::Printf(TEXT("TriggerCombatAnimation true"));
EnemyActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true);
const FString Command123 = FString::Printf(TEXT("TriggerCombatAnimation true"));
EnemyActor->CallFunctionByNameWithArguments(*Command123, AR, nullptr, true);
FVector Direction = EnemyActor->GetActorLocation() - PlayerActor->GetActorLocation();
Direction.Normalize();
FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator();
@ -169,11 +172,17 @@ void ATurnBaseCombatV2::EndCombat()
//Enable Character Movement
//Set to Game Mode Only
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
PlayerController->SetInputMode(FInputModeGameOnly());
PlayerController->SetIgnoreMoveInput(false);
PlayerController->SetIgnoreLookInput(false);
PlayerController->SetInputMode(FInputModeGameOnly());
PlayerController->bShowMouseCursor = false;
//Enable Character Movement
if (ACharacter* PlayerCharacter = Cast<ACharacter>(GetWorld()->GetFirstPlayerController()->GetPawn()))
{
PlayerCharacter->EnableInput(GetWorld()->GetFirstPlayerController());
}
if (IsValid(EnemyActor))
{
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");