#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "UObject/NoExportTypes.h"
#include "DreamSnare.generated.h"

class UAuthoritativePoolableActorComponent;
class USphereComponent;
class UDreamSnareAbility;
class ASurvivor;

UCLASS(Blueprintable, Abstract)
class THENIGHTMARE_API ADreamSnare : public AActor
{
	GENERATED_BODY()

private:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Export, meta=(AllowPrivateAccess=true))
	UAuthoritativePoolableActorComponent* _authoritativePoolableActorComponent;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, ReplicatedUsing=OnRep_IsActive, Transient, meta=(AllowPrivateAccess=true))
	bool _isActive;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	bool _isStatic;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Export, meta=(AllowPrivateAccess=true))
	USphereComponent* _dreamSnareCollision;

	UPROPERTY(EditAnywhere, Replicated, Export)
	TWeakObjectPtr<UDreamSnareAbility> _linkedAbility;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, meta=(AllowPrivateAccess=true))
	FVector _startPosition;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, ReplicatedUsing=OnRep_Velocity, meta=(AllowPrivateAccess=true))
	FVector _velocity;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	FVector _slopeDetectionOverGroundVector;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	FVector _slopeDetectionEndVector;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	float _rotationInterpSpeed;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	int32 _maxGroundCheckTry;

private:
	UFUNCTION(BlueprintCallable)
	void OnRep_Velocity();

	UFUNCTION(BlueprintCallable)
	void OnRep_IsActive();

	UFUNCTION(BlueprintCallable, NetMulticast, Reliable)
	void Multicast_OnSnareTriggered(ASurvivor* survivorTriggering);

protected:
	UFUNCTION(BlueprintPure)
	bool IsSnareStatic() const;

private:
	UFUNCTION(BlueprintCallable)
	void InitializeSnare();

protected:
	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_SpawnSnare();

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_SnareInitialized();

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_OnSurvivorTriggerDreamTrap(ASurvivor* survivor);

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, BlueprintCosmetic)
	void Cosmetic_DespawnSnare();

private:
	UFUNCTION(BlueprintCallable)
	void Authority_OnAcquiredChanged(const bool acquired);

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

public:
	ADreamSnare();
};

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