// Copyright Pacificao. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "AgrarianTypes.generated.h"

UENUM(BlueprintType)
enum class EAgrarianWeatherType : uint8
{
	Clear UMETA(DisplayName = "Clear"),
	Rain UMETA(DisplayName = "Rain"),
	ColdWind UMETA(DisplayName = "Cold Wind"),
	Storm UMETA(DisplayName = "Storm")
};

USTRUCT(BlueprintType)
struct FAgrarianMappedWeatherInputs
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	FName TileId = NAME_None;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float Latitude = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float Longitude = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float TemperatureC = 12.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float DailyLowTemperatureC = 9.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float DailyHighTemperatureC = 18.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float PrecipitationMm = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float WindSpeedKmh = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float CloudCoverPercent = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float RelativeHumidityPercent = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float PressureMslHpa = 1013.25f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float VisibilityMeters = 10000.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	int32 ProviderWeatherCode = 0;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	EAgrarianWeatherType MappedWeather = EAgrarianWeatherType::Clear;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	FString Provider = TEXT("deterministic");

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	FString ProviderTimestamp;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	bool bHasProviderData = false;
};

USTRUCT(BlueprintType)
struct FAgrarianWeatherDebugSnapshot
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	FName TileId = NAME_None;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float Latitude = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float Longitude = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	FString Provider = TEXT("deterministic");

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	FString ProviderTimestamp;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	EAgrarianWeatherType AppliedWeather = EAgrarianWeatherType::Clear;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	int32 ProviderWeatherCode = 0;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float TemperatureC = 12.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float PrecipitationMm = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float WindSpeedKmh = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float CloudCoverPercent = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float RelativeHumidityPercent = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float PressureMslHpa = 1013.25f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	float VisibilityMeters = 10000.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Weather")
	bool bHasProviderData = false;
};

UENUM(BlueprintType)
enum class EAgrarianSeason : uint8
{
	Winter UMETA(DisplayName = "Winter"),
	Spring UMETA(DisplayName = "Spring"),
	Summer UMETA(DisplayName = "Summer"),
	Autumn UMETA(DisplayName = "Autumn")
};

UENUM(BlueprintType)
enum class EAgrarianCropSeasonFit : uint8
{
	Unknown UMETA(DisplayName = "Unknown"),
	FitsSeason UMETA(DisplayName = "Fits Season"),
	Marginal UMETA(DisplayName = "Marginal"),
	TooLong UMETA(DisplayName = "Too Long"),
	OutOfSeason UMETA(DisplayName = "Out Of Season")
};

USTRUCT(BlueprintType)
struct FAgrarianCalendarSnapshot
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Calendar")
	int32 DayOfYear = 1;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Calendar")
	int32 Year = 1;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Calendar")
	int32 AbsoluteDay = 1;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Calendar")
	int32 DayOfSeason = 1;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Calendar")
	EAgrarianSeason Season = EAgrarianSeason::Winter;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Calendar")
	float HourOfDay = 8.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Calendar")
	bool bInsideGrowingSeason = false;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Calendar")
	int32 GrowingSeasonDaysRemaining = 0;
};

USTRUCT(BlueprintType)
struct FAgrarianGrowingSeasonProfile
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Growing Season")
	FName TileId = NAME_None;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Growing Season")
	FString GrowingZoneLabel = TEXT("unknown");

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Growing Season", meta = (ClampMin = "1", ClampMax = "366"))
	int32 GrowingSeasonStartDay = 80;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Growing Season", meta = (ClampMin = "1", ClampMax = "366"))
	int32 GrowingSeasonEndDay = 300;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Growing Season", meta = (ClampMin = "0", ClampMax = "366"))
	int32 FrostFreeDays = 220;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Growing Season")
	float MinAverageGrowingTempC = 7.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Growing Season", meta = (ClampMin = "0", ClampMax = "90"))
	int32 CropSafetyBufferDays = 14;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Growing Season")
	FString ClimateProfile = TEXT("unknown");
};

USTRUCT(BlueprintType)
struct FAgrarianCropSeasonAssessment
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Growing Season")
	EAgrarianCropSeasonFit Fit = EAgrarianCropSeasonFit::Unknown;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Growing Season")
	int32 DaysAvailable = 0;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Growing Season")
	int32 DaysRequired = 0;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Growing Season")
	int32 SafetyBufferDays = 0;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Growing Season")
	bool bCanPlantToday = false;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Growing Season")
	FString GrowingZoneLabel = TEXT("unknown");

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Growing Season")
	FText Reason;
};

USTRUCT(BlueprintType)
struct FAgrarianItemStack
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Inventory")
	FName ItemId = NAME_None;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Inventory")
	FText DisplayName;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Inventory", meta = (ClampMin = "0"))
	int32 Quantity = 0;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Inventory", meta = (ClampMin = "0"))
	float UnitWeight = 0.0f;

	bool IsValidStack() const
	{
		return ItemId != NAME_None && Quantity > 0;
	}
};

UENUM(BlueprintType)
enum class EAgrarianItemType : uint8
{
	Resource UMETA(DisplayName = "Resource"),
	Food UMETA(DisplayName = "Food"),
	Tool UMETA(DisplayName = "Tool"),
	Structure UMETA(DisplayName = "Structure"),
	Medicine UMETA(DisplayName = "Medicine"),
	Currency UMETA(DisplayName = "Currency")
};

UENUM(BlueprintType)
enum class EAgrarianWildlifeDisposition : uint8
{
	Passive UMETA(DisplayName = "Passive"),
	Fleeing UMETA(DisplayName = "Fleeing"),
	Aggressive UMETA(DisplayName = "Aggressive")
};

UENUM(BlueprintType)
enum class EAgrarianWildlifeState : uint8
{
	Idle UMETA(DisplayName = "Idle"),
	Wandering UMETA(DisplayName = "Wandering"),
	Fleeing UMETA(DisplayName = "Fleeing"),
	Chasing UMETA(DisplayName = "Chasing"),
	Dead UMETA(DisplayName = "Dead")
};

USTRUCT(BlueprintType)
struct FAgrarianItemDefinition
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Items")
	FName ItemId = NAME_None;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Items")
	FText DisplayName;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Items")
	FText Description;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Items")
	EAgrarianItemType ItemType = EAgrarianItemType::Resource;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Items", meta = (ClampMin = "0"))
	float UnitWeight = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Items", meta = (ClampMin = "1"))
	int32 MaxStackSize = 99;
};

USTRUCT(BlueprintType)
struct FAgrarianRecipe
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Crafting")
	FName RecipeId = NAME_None;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Crafting")
	FText DisplayName;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Crafting")
	TArray<FAgrarianItemStack> Ingredients;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Crafting")
	FAgrarianItemStack Result;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Crafting", meta = (ClampMin = "0"))
	float CraftSeconds = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Crafting")
	bool bRequiresCampfire = false;
};

USTRUCT(BlueprintType)
struct FAgrarianSurvivalSnapshot
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Survival")
	float Health = 100.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Survival")
	float Stamina = 100.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Survival")
	float Exhaustion = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Survival")
	float Hunger = 100.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Survival")
	float Thirst = 100.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Survival")
	float BodyTemperature = 37.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Survival")
	float InjurySeverity = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Survival")
	float BleedingSeverity = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Survival")
	float SprainSeverity = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Survival")
	float SicknessSeverity = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Survival")
	bool bIsDead = false;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Survival")
	FName LastDeathReason = NAME_None;
};

USTRUCT(BlueprintType)
struct FAgrarianCareHistorySnapshot
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Care History")
	float NutritionQuality = 1.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Care History")
	float IllnessBurden = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Care History")
	float InjuryBurden = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Care History")
	float SleepQuality = 1.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Care History")
	float ShelterQuality = 1.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Care History")
	float StressBurden = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Care History")
	float WorkloadBurden = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Care History")
	float TreatmentQuality = 1.0f;
};
