This repository has been archived on 2026-05-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
AgrarianGameArchive/Source/AgrarianGame/AgrarianGameState.h
T

122 lines
4.8 KiB
C++

// Copyright Pacificao. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameStateBase.h"
#include "AgrarianTypes.h"
#include "AgrarianGameState.generated.h"
UCLASS()
class AAgrarianGameState : public AGameStateBase
{
GENERATED_BODY()
public:
AAgrarianGameState();
virtual void BeginPlay() override;
virtual void Tick(float DeltaSeconds) override;
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Replicated, Category = "Agrarian|World")
float WorldHours = 8.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|World", meta = (ClampMin = "0.1"))
float GameHoursPerRealMinute = 0.1f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Replicated, Category = "Agrarian|World|Calendar", meta = (ClampMin = "1", ClampMax = "366"))
int32 DaysPerAgrarianYear = 366;
UPROPERTY(EditAnywhere, BlueprintReadOnly, ReplicatedUsing = OnRep_Weather, Category = "Agrarian|World")
EAgrarianWeatherType Weather = EAgrarianWeatherType::Clear;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Replicated, Category = "Agrarian|World")
float AmbientTemperatureC = 12.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Replicated, Category = "Agrarian|World|Tile Solar")
FName ActiveSolarTileId = TEXT("gz_us_ca_pacifica_utm10n_e544_n4160");
UPROPERTY(EditAnywhere, BlueprintReadOnly, Replicated, Category = "Agrarian|World|Tile Solar")
float ActiveTileLatitude = 37.5925f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Replicated, Category = "Agrarian|World|Tile Solar")
float ActiveTileLongitude = -122.4995f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Replicated, Category = "Agrarian|World|Tile Solar")
FString ActiveTileTimeZoneId = TEXT("America/Los_Angeles");
UPROPERTY(EditAnywhere, BlueprintReadOnly, Replicated, Category = "Agrarian|World|Tile Solar")
float ActiveTileUtcOffsetHours = -7.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Replicated, Category = "Agrarian|World|Tile Solar", meta = (ClampMin = "1", ClampMax = "366"))
int32 ActiveDayOfYear = 172;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Replicated, Category = "Agrarian|World|Calendar", meta = (ClampMin = "1"))
int32 ActiveYear = 1;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Replicated, Category = "Agrarian|World|Growing Season")
FAgrarianGrowingSeasonProfile ActiveGrowingSeason;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated, Category = "Agrarian|World|Tile Solar")
bool bHasActiveTileSolarData = false;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated, Category = "Agrarian|World|Tile Solar")
float SunriseHourLocal = 6.0f;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated, Category = "Agrarian|World|Tile Solar")
float SunsetHourLocal = 20.0f;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated, Category = "Agrarian|World|Tile Solar")
float SolarNoonHourLocal = 13.0f;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated, Category = "Agrarian|World|Tile Solar")
float DayLengthHours = 14.0f;
UFUNCTION(BlueprintCallable, Category = "Agrarian|World")
bool IsNight() const;
UFUNCTION(BlueprintCallable, Category = "Agrarian|World")
void SetWeather(EAgrarianWeatherType NewWeather);
UFUNCTION(BlueprintCallable, Category = "Agrarian|World|Tile Solar")
bool ConfigureActiveSolarTile(FName TileId, float Latitude, float Longitude, const FString& TimeZoneId, float UtcOffsetHours);
UFUNCTION(BlueprintPure, Category = "Agrarian|World|Calendar")
FAgrarianCalendarSnapshot GetCalendarSnapshot() const;
UFUNCTION(BlueprintPure, Category = "Agrarian|World|Calendar")
int32 GetAbsoluteAgrarianDay() const;
UFUNCTION(BlueprintPure, Category = "Agrarian|World|Calendar")
EAgrarianSeason GetSeasonForDay(int32 DayOfYear) const;
UFUNCTION(BlueprintPure, Category = "Agrarian|World|Calendar")
int32 GetDayOfSeason(int32 DayOfYear) const;
UFUNCTION(BlueprintPure, Category = "Agrarian|World|Calendar")
float ConvertAgrarianDaysToRealHours(float AgrarianDays) const;
UFUNCTION(BlueprintPure, Category = "Agrarian|World|Calendar")
float ConvertRealHoursToAgrarianDays(float RealHours) const;
UFUNCTION(BlueprintPure, Category = "Agrarian|World|Calendar")
float GetLongTaskProgress(int32 StartAbsoluteDay, float StartHourOfDay, float DurationAgrarianDays) const;
UFUNCTION(BlueprintPure, Category = "Agrarian|World|Growing Season")
bool IsDayInsideActiveGrowingSeason(int32 DayOfYear) const;
UFUNCTION(BlueprintPure, Category = "Agrarian|World|Growing Season")
int32 GetDaysRemainingInActiveGrowingSeason(int32 PlantDayOfYear) const;
UFUNCTION(BlueprintPure, Category = "Agrarian|World|Growing Season")
FAgrarianCropSeasonAssessment AssessCropForActiveGrowingSeason(int32 CropMaturityDays, int32 PlantDayOfYear) const;
protected:
UFUNCTION()
void OnRep_Weather();
void UpdateSolarTimes();
void UpdateAmbientTemperature();
};