// Copyright ExByte Studios. Item Interaction Ecosystem.

#pragma once

#include "CoreMinimal.h"
#include "GameplayTagContainer.h"
#include "ItemPlacementRules.generated.h"

/** How a placeable item snaps when previewed/placed (section 13.3). */
UENUM(BlueprintType)
enum class EItemPlacementMode : uint8
{
	FreeSurface,
	SnapToGrid,
	SnapToSocket
};

/**
 * Static placement constraints for a placeable item (section 13.3).
 * Evaluated locally for the ghost preview and re-validated on the server.
 */
USTRUCT(BlueprintType)
struct ITEMDATABASE_API FItemPlacementRules
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Placement")
	EItemPlacementMode PlacementMode = EItemPlacementMode::FreeSurface;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Placement")
	float MaxDistance = 400.f;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Placement")
	bool bRequiresFlatSurface = false;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Placement", meta = (ClampMin = "0", ClampMax = "90"))
	float MaxSlopeAngle = 35.f;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Placement")
	FName CollisionProfile = FName("BlockAll");

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Placement")
	FGameplayTagContainer AllowedSurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Placement")
	FGameplayTagContainer BlockedSurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Placement")
	float SnapToGrid = 0.f;

	/** When PlacementMode == SnapToSocket, only sockets carrying this tag accept the item. */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Placement")
	FGameplayTag SnapToSocketTag;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Placement")
	float MinDistanceFromOtherSameItems = 0.f;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Placement")
	bool bCanPlaceInWater = false;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Placement")
	bool bCanPlaceOnVehicle = false;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Placement")
	bool bCanPlaceOnWall = false;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Placement")
	bool bCanPlaceOnGround = true;
};
