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

#include "DebugLibrary.h"

// Engine headers.
#include "DrawDebugHelpers.h"
#include "Engine/Engine.h"
#include "GameFramework/Actor.h"

void UDebugLibrary::DrawVector(
	class UWorld* World,
	const FVector& VectorStart,
	const FVector& VectorDirection,
	const FColor& Color,
	float ArrowSize,
	float ArrowLength,
	float ArrowThickness)
{
	FVector NormalizedVectorDirection = VectorDirection;
	NormalizedVectorDirection.Normalize();

	DrawDebugDirectionalArrow(World, VectorStart, VectorStart + ArrowLength * NormalizedVectorDirection,
		ArrowSize, Color, false, -1.0f, (uint8)'\000', ArrowThickness);
}

void UDebugLibrary::DrawDirectionalVectors(AActor* Actor, float ArrowSize, float ArrowLength, float ArrowThickness)
{
	UWorld* World = Actor->GetWorld();
	FVector ActorLocation = Actor->GetActorLocation();

	DrawVector(World, ActorLocation, Actor->GetActorForwardVector(),
		FColor::Red, ArrowSize, ArrowLength, ArrowThickness);
	DrawVector(World, ActorLocation, Actor->GetActorRightVector(),
		FColor::Green, ArrowSize, ArrowLength, ArrowThickness);
	DrawVector(World, ActorLocation, Actor->GetActorUpVector(),
		FColor::Blue, ArrowSize, ArrowLength, ArrowThickness);
}

void UDebugLibrary::PrintTextOnScreen(const FString& Message, float Duration, const FColor& Color)
{
	GEngine->AddOnScreenDebugMessage(-1, Duration, Color, Message);
}
