// © 2024 Long Ly. All rights reserved. Any unauthorized use, reproduction, or distribution of this trademark is strictly prohibited and may result in legal action.

#pragma once

#include "CoreMinimal.h"
#include "Data/OLSEnumLibrary.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "OLSLocomotionBPLibrary.generated.h"

/**
 * 
 */
UCLASS()
class OLSANIMATION_API UOLSLocomotionBPLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

public:

	/**
	 * Predict where the character will stop based on its current movement properties and parameters from the movement component.
	 * This uses prediction logic that is heavily tied to the UCharacterMovementComponent.
	 * Each parameter corresponds to a value from the UCharacterMovementComponent with the same name.
	 * Because this is a thread safe function, it's	recommended to populate these fields via the Property Access system.
	 * @return The predicted stop position in local space to the character. The size of this vector will be the distance to the stop location.
	 */
	UFUNCTION(BlueprintCallable, BlueprintPure, Category = "OLS|Function Library", meta=(BlueprintThreadSafe))
	static FVector PredictGroundMovementStopLocation(const FVector& velocity, bool shouldUseSeparateBrakingFriction,
													 float brakingFriction, float groundFriction,
													 float brakingFrictionFactor, float brakingDecelerationWalking);

	/**
 * Predict where the character will change direction during a pivot based on its current movement properties and parameters from the movement component.
 * This uses prediction logic that is heavily tied to the UCharacterMovementComponent.
 * Each parameter corresponds to a value from the UCharacterMovementComponent with the same name.
 * Because this is a thread safe function, it's	recommended to populate these fields via the Property Access system.
 * @return The predicted pivot position in local space to the character. The size of this vector will be the distance to the pivot.
 */
	UFUNCTION(BlueprintCallable, BlueprintPure, Category = "OLS|Function Library", meta=(BlueprintThreadSafe))
	static FVector PredictGroundMovementPivotLocation(const FVector& acceleration, const FVector& velocity,
													  float groundFriction);
	
public:
	
	UFUNCTION(BlueprintCallable,BlueprintPure,Category = "OLS|Function Library",meta=(BlueprintThreadSafe))
	static EOLSCardinalDirection SelectCardinalDirectionFromAngle(float angle, float deadZone, EOLSCardinalDirection currentDirection, bool useCurrentDirection = false);

	UFUNCTION(BlueprintCallable,BlueprintPure,Category = "OLS|Function Library",meta=(BlueprintThreadSafe))
	static EOLSCardinalDirection GetOppositeCardinalDirectional(EOLSCardinalDirection currentDirection);
	
	UFUNCTION(BlueprintCallable,BlueprintPure,Category = "OLS|Function Library",meta=(BlueprintThreadSafe))
	static EOLSHipDirection GetOppositeHipDirection(EOLSHipDirection currentHipDirection);
	
public:

	UFUNCTION(BlueprintCallable, Category = "OLS|Function Library")
	static void TryLinkAnimLayer(USkeletalMeshComponent* mesh, TSubclassOf<UAnimInstance> animClass, FName groupName, bool shouldUnlinkGroupIfInvalid);
};
