#pragma once

#include "CoreMinimal.h"
#include "PounceAttack.h"
#include "DBDTunableRowHandle.h"
#include "TwinJumpAttack.generated.h"

class UCurveFloat;
class ADBDPlayer;
class AConjoinedTwin;

UCLASS(Blueprintable, meta=(BlueprintSpawnableComponent))
class UTwinJumpAttack : public UPounceAttack
{
	GENERATED_BODY()

protected:
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	bool _wasLastAttackSuccessful;

private:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	FDBDTunableRowHandle _jumpVelocity;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	UCurveFloat* _jumpAngleCurve;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	FDBDTunableRowHandle _upDownObstructionAnglePrecision;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	FDBDTunableRowHandle _leftRightObstructionAnglePrecision;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	FDBDTunableRowHandle _authorizedLandingHeight;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, ReplicatedUsing=OnRep_ShouldTwinHaveJumpObjectType, meta=(AllowPrivateAccess=true))
	bool _shouldTwinHaveJumpObjectType;

public:
	UFUNCTION(BlueprintCallable, Server, Reliable)
	void Server_StopJump();

	UFUNCTION(BlueprintCallable, Server, Reliable)
	void Server_OnJumpStartTwin();

private:
	UFUNCTION(BlueprintCallable)
	void OnRep_ShouldTwinHaveJumpObjectType();

	UFUNCTION(BlueprintCallable, NetMulticast, Reliable)
	void Multicast_SetIsForbiddenLandingLocation(bool isForbiddenLocation);

	UFUNCTION(BlueprintCallable, NetMulticast, Reliable)
	void Multicast_DestroyTwinOnWrongLanding();

	UFUNCTION(BlueprintCallable, NetMulticast, Reliable)
	void Multicast_AttachToSurvivor(ADBDPlayer* survivorToAttachTo);

protected:
	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_OnUnSuccessfulJumpAttack(AConjoinedTwin* owningTwin);

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_OnSuccessfulJumpAttack(AConjoinedTwin* owningTwin);

public:
	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_OnJumpStarted(AConjoinedTwin* owningTwin);

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_OnJumpObstructed(AConjoinedTwin* owningTwin);

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_OnJumpLanded(AConjoinedTwin* owningTwin);

protected:
	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_OnJumpCooldownChanged(bool isInJumpCooldown, AConjoinedTwin* owningTwin);

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_OnIsForbiddenLandingLocationChanged(bool isForbiddenLocation, AConjoinedTwin* twin);

private:
	UFUNCTION(BlueprintCallable, Client, Unreliable)
	void Client_Debug_PrintLandingLocationDebug(const bool foundProjectedPoint, const bool foundPath);

public:
	virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;

public:
	UTwinJumpAttack();
};

FORCEINLINE uint32 GetTypeHash(const UTwinJumpAttack) { return 0; }
