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

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Explosive.generated.h"

UCLASS()
class ENDLESSVENDETTA_API AExplosive : public AActor
{
	GENERATED_BODY()

	void DrawShrapnelDebugLines(bool HitSomething, FVector StartVector, FVector EndVector, FVector ImpactPoint);

protected:
	// Maximum amount of damage dealt by an individual piece of shrapnel
	UPROPERTY(EditDefaultsOnly, Category = "Explosion")
	float ShrapnelDamage = 10;

	// Number of shrapnel pieces uniformly spread around the Y axis
	UPROPERTY(EditDefaultsOnly, Category = "Explosion")
	int ShrapnelPitchDensity = 40;

	// Number of shrapnel pieces uniformly spread around the Z axis
	UPROPERTY(EditDefaultsOnly, Category = "Explosion")
	int ShrapnelYawDensity = 40;

	// How far shrapnel should travel from origin point, given its not obstructed along its path
	UPROPERTY(EditDefaultsOnly, Category = "Explosion")
	float ShrapnelTravelDistance = 600;

	// After what distance travelled should shrapnel damage start to decrease
	UPROPERTY(EditDefaultsOnly, Category = "Explosion")
	float ShrapnelDamageFalloffDistance = 200;

	// Delay from spawning in before explosion happens
	UPROPERTY(EditDefaultsOnly, Category = "Explosion")
	float ExplosionDelayInSeconds = 0;

	/**
	 * Should debug lines be drawn to show planned travel trajectory of each
	 * shrapnel piece in red, and actual travelled shrapnel trajectory in green
	 */
	UPROPERTY(EditAnywhere, Category = "Explosion")
	bool DrawDebugLines = false;

	UFUNCTION(BlueprintImplementableEvent, Category = "Explosion")
	void PlayExplosionEffects();

	void Explosion();
	
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:
	// Sets default values for this actor's properties
	AExplosive();
	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

};
