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

#pragma once

#include "CoreMinimal.h"
#include "PhoneRinging.h"
#include "EndlessVendetta/GadgetSystem/ReconGadget.h"
#include "Camera/CameraComponent.h"
#include "RingModule.generated.h"

/**
 * 
 */
UCLASS()
class ENDLESSVENDETTA_API ARingModule : public AReconGadget
{
	GENERATED_BODY()

	ACharacter* PlayerChar;
	
	UCameraComponent* PlayerCam;
	
	AActor* PotentialHackTarget;	

	// 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();

	// Returns false if there are no nearby enemies
	bool SpawnRingingPhoneForAllNearbyEnemies();
	
protected:
	UPROPERTY(EditDefaultsOnly, Category = "Ring Module")
	float AreaOfEffectInMeters = 20;

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

	UPROPERTY(EditDefaultsOnly, Category = "Ring Module")
	TSubclassOf<APhoneRinging> PhoneRingingClass;
	
	// --------------- Display Functions ---------------
	UFUNCTION(BlueprintImplementableEvent, Category = "Ring Module")
	void DisplayAlreadyHacked();

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

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

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

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

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