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

#pragma once

#include "CoreMinimal.h"
#include "Components/WidgetComponent.h"
#include "EndlessVendetta/InteractionInterface.h"
#include "GameFramework/Actor.h"
#include "LandingZone.generated.h"

UCLASS()
class ENDLESSVENDETTA_API ALandingZone : public AActor, public IInteractionInterface
{
	GENERATED_BODY()

//	------------------------------ Attributes -------------------------------------------------	
	UPROPERTY(EditAnywhere, Category = "Landing Zone")
	FTransform LZ_ExitTransform;
	
	UPROPERTY(EditAnywhere, Category = "Landing Zone")
	FTransform LZ_TakeoffTransform;
	
	UWidgetComponent* WaypointWidgetComponent;

	APawn* PlayersPawn;

protected:
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Landing Zone")
	bool IsHomeBase_LZ = false;

public:
	bool IsWaypointVisible = false;
//	------------------------------ Methods -------------------------------------------------
private:
	// Runs when game starts or this actor spawns
	virtual void BeginPlay() override;
                        	
	// Runs once per frame
	virtual void Tick(float DeltaSeconds) override;
	
	// Hides or shows key aesthetic features of LZ's based on if the player is landing or not
	void UpdateAllLandingZones(bool Landing);

	// Updates waypoints rotation and scale based on players location, only if visible
	void UpdateWaypointTransform();

protected:	
	// Allows player to enter their ship through a LZ
	void Interact() override;

	// Used to implement a pop up for interaction
	void InteractPrompt() override;
	
public:	
	// Sets default values for this actor's properties
	ALandingZone();
	
	// Waypoint will display something along the lines of Press F to Land
	UFUNCTION(BlueprintImplementableEvent)
    void SuggestLandingWidget();
	
	// Ran when a player takes off from any LZ in the world
	UFUNCTION(BlueprintImplementableEvent)
	void ShowWaypoint();
	
	// Ran when player lands at any LZ in the world
	UFUNCTION(BlueprintImplementableEvent)
	void HideWaypoint();

	// Updates all LZ's, then runs exit ship func on player and passes the exit transform
	void Land();
	
	// Updates all LZ's, then runs enter ship func on player passing the correct takeoff transform
	void Takeoff();
};
