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

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "CustomerCrowdAvoidanceComponent.generated.h"

class UNpcPawnMovement;

UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class FAYE_API UCustomerCrowdAvoidanceComponent : public UActorComponent
{
	GENERATED_BODY()
public:
	UCustomerCrowdAvoidanceComponent();

protected:
	virtual void BeginPlay() override;
	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
	
	FVector ComputeSeparation() const;
	
private:
	
	static TArray<TWeakObjectPtr<UCustomerCrowdAvoidanceComponent>> AllAgents;
	
	UPROPERTY()
	UNpcPawnMovement* NpcPawnMovement = nullptr;
	
	UPROPERTY()
	APawn* PlayerPawn = nullptr;
	
	float CapsuleRadius = 0.f;

public:
	UPROPERTY(EditAnywhere, Category = "Crowd")
	bool bDebug = false;
	
	UPROPERTY(EditAnywhere, Category = "Crowd")
	float AvoidanceRadius = 150.f;
	
	UPROPERTY(EditAnywhere, Category = "Crowd")
	float SeparationStrength = 2.f;
	
	UPROPERTY(EditAnywhere, Category = "Crowd")
	float MaxSeparationForce = 1.f;
};
