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

#pragma once

#include "CoreMinimal.h"
#include "Camera/CameraComponent.h"
#include "EndlessVendetta/GadgetSystem/CombatGadget.h"
#include "EndlessVendetta/GadgetSystem/GadgetClasses/Combat/Explosive.h"
#include "OverloadModule.generated.h"

/**
 * 
 */
UCLASS()
class ENDLESSVENDETTA_API AOverloadModule : public ACombatGadget
{
	GENERATED_BODY()
	
	ACharacter* PlayerChar;
	
	UCameraComponent* PlayerCam;
	
	AActor* PotentialHackTarget;

	AActor* ClosestEnemy;

	// An Array of previously hacked enemies, stops player from hacking the same Dead Enemy
	TArray<uint32> HackedEnemies; 
	
	virtual void BeginPlay() override;
	
	virtual void Tick(float DeltaSeconds) override;

	virtual void Activate() override;

	virtual void FinishedUsing() override;

	void CheckForPotentialHackTarget();

	void ExplodeClosestAliveEnemy();

	void SpawnExplosiveOnActor(AActor* ActortoExplode);

protected:
	UPROPERTY(EditDefaultsOnly, Category = "Overload Module")
	float AreaOfEffectInMeters = 20;

	UPROPERTY(EditDefaultsOnly, Category = "Overload Module")
	float DeadBodyCheckDistance = 250;

	UPROPERTY(EditDefaultsOnly, Category = "Overload Module")
	TSubclassOf<AExplosive> Explosive;

// --------------- Display Functions ---------------
	UFUNCTION(BlueprintImplementableEvent, Category = "Overload Module")
	void DisplayAlreadyHacked();

	UFUNCTION(BlueprintImplementableEvent, Category = "Overload Module")
	void DisplayNeedADeadEnemy();

	UFUNCTION(BlueprintImplementableEvent, Category = "Overload Module")
	void DisplayFoundPotentialTarget();
	
	UFUNCTION(BlueprintImplementableEvent, Category = "Overload Module")
	void PlayHackingAnim(float Loadingtime);

	UFUNCTION(BlueprintImplementableEvent, Category = "Overload Module")
	void DisplayHackingFailure();

	UFUNCTION(BlueprintImplementableEvent, Category = "Overload Module")
	void DisplayHackingSuccess();

	UFUNCTION(BlueprintImplementableEvent, Category = "Overload Module")
	void PlayRechargingAnim(float RechargingTime);
};
