<commit_before>// Fill out your copyright notice in the Description page of Project Settings.

#include "Lab_1.h"
#include "Lab_1Character.h"
#include "Kismet/GameplayStatics.h"
#include "EngineGlobals.h"
#include "Engine/Engine.h"
#include "BaseAIController.h"
#include "Lab_1GameMode.h"


ABaseAIController::ABaseAIController()
{
    ControllerId = -1;
}

void ABaseAIController::BeginPlay()
{
    Super::BeginPlay();

    auto* MyGameMode = GetGameMode();
    if (!MyGameMode) {
        UE_LOG(LogTemp, Warning, TEXT("Failed to register controller in GameMode"));
    }
    ControllerId = MyGameMode->RegisterController(this);
}

void ABaseAIController::Tick(float DeltaSeconds)
{
}

void ABaseAIController::SetNewMoveDestination(const FVector DestLocation)
{
    auto* MyGameMode = GetGameMode();
    if (MyGameMode->GetCurrentState() == ELab_1PlayState::EGameOver) {
        return;
    }

	APawn* const Pawn = GetPawn();
	if (Pawn)
	{
		UNavigationSystem* const NavSys = GetWorld()->GetNavigationSystem();
		float const Distance = FVector::Dist(DestLocation, Pawn->GetActorLocation());

		// We need to issue move command only if far enough in order for walk animation to play correctly
		if (NavSys && (Distance > 120.0f))
		{
			NavSys->SimpleMoveToLocation(this, DestLocation);
		}
	}
}

float ABaseAIController::GetDistanceBetween(const FVector SrcLocation, const FVector DestLocation)
{
    return FVector::Dist(SrcLocation, DestLocation);
}

float ABaseAIController::GetDistanceToDestination(const FVector DestLocation)
{
	APawn* const Pawn = GetPawn();
	if (Pawn) {
        return GetDistanceBetween(Pawn->GetActorLocation(), DestLocation);
	}
    return 0.0f;
}

bool ABaseAIController::TryGrabPizza()
{
    auto* Character = GetCharacter();
    if (!Character) {
        return false;<commit_msg>[Lab_2] Use move clever MoveToLocation function<commit_after>// Fill out your copyright notice in the Description page of Project Settings.

#include "Lab_1.h"
#include "Lab_1Character.h"
#include "Kismet/GameplayStatics.h"
#include "EngineGlobals.h"
#include "Engine/Engine.h"
#include "BaseAIController.h"
#include "Lab_1GameMode.h"


ABaseAIController::ABaseAIController()
{
    ControllerId = -1;
}

void ABaseAIController::BeginPlay()
{
    Super::BeginPlay();

    auto* MyGameMode = GetGameMode();
    if (!MyGameMode) {
        UE_LOG(LogTemp, Warning, TEXT("Failed to register controller in GameMode"));
    }
    ControllerId = MyGameMode->RegisterController(this);
}

void ABaseAIController::Tick(float DeltaSeconds)
{
}

void ABaseAIController::SetNewMoveDestination(const FVector DestLocation)
{
    auto* MyGameMode = GetGameMode();
    if (MyGameMode->GetCurrentState() == ELab_1PlayState::EGameOver) {
        return;
    }

	APawn* const Pawn = GetPawn();
	if (Pawn)
	{
		UNavigationSystem* const NavSys = GetWorld()->GetNavigationSystem();
		float const Distance = FVector::Dist(DestLocation, Pawn->GetActorLocation());

		// We need to issue move command only if far enough in order for walk animation to play correctly
		if (NavSys && (Distance > 120.0f))
		{
			MoveToLocation(DestLocation, 0, 0, 1);
		}
	}
}

float ABaseAIController::GetDistanceBetween(const FVector SrcLocation, const FVector DestLocation)
{
    return FVector::Dist(SrcLocation, DestLocation);
}

float ABaseAIController::GetDistanceToDestination(const FVector DestLocation)
{
	APawn* const Pawn = GetPawn();
	if (Pawn) {
        return GetDistanceBetween(Pawn->GetActorLocation(), DestLocation);
	}
    return 0.0f;
}

bool ABaseAIController::TryGrabPizza()
{
    auto* Character = GetCharacter();
    if (!Character) {
        return false;
{'fraction_non_alphanumeric': 0.11632373113854595, 'fraction_numerical': 0.007133058984910837, 'mean_word_length': 4.7781299524564185, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3733076', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1181, 'n_words': 276}