Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Fill out your copyright notice in the Description page of Project Settings.
- #pragma once
- #include "CoreMinimal.h"
- #include "Runtime/Engine/Classes/GameFramework/Actor.h"
- #include "Runtime/CoreUObject/Public/UObject/Class.h"
- #include "Components/ActorComponent.h"
- #include "Runtime/Engine/Public/TimerManager.h"
- #include "Kismet/KismetStringLibrary.h"
- #include "EarthTime.generated.h"
- // Enum of Months
- UENUM(BlueprintType)
- enum class ECalendarMonths : uint8
- {
- January, February, March, April, May, June, July,
- August, September, October, November, December
- };
- // Input struct containing necessary values to determine "Sun position" during day/night cycle
- USTRUCT(BlueprintType)
- struct FDay_Night_Cycle
- {
- GENERATED_USTRUCT_BODY()
- public:
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sun Position", meta = (ClampMin = "0", UIMin = "0"))
- float Min_Degrees;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sun Position", meta = (ClampMax = "359", UIMax = "359"))
- float Max_Degrees;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sun Position", meta = (ClampMin = "0", UIMin = "0"))
- int32 Sunrise;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sun Position", meta = (ClampMin = "0", UIMin = "0"))
- int32 Hours_Of_Daylight;
- float Sun_Start_Degrees;
- };
- // Input struct containing all necessary values to determine where to begin counting time
- USTRUCT(BlueprintType)
- struct FStandard_Calendar
- {
- GENERATED_USTRUCT_BODY()
- public:
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Standard", meta = (ClampMin = "0", ClampMax = "59", UIMin = "0", UIMax = "59"))
- int32 Seconds;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Standard", meta = (ClampMin = "0", ClampMax = "59", UIMin = "0", UIMax = "59"))
- int32 Minutes;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Standard", meta = (ClampMin = "0", ClampMax = "23", UIMin = "0", UIMax = "23"))
- int32 Hours;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Standard", meta = (ClampMin = "1", ClampMax = "31", UIMin = "1", UIMax = "31"))
- int32 Day;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Standard", meta = (ClampMin = "1", ClampMax = "12", UIMin = "1", UIMax = "12"))
- ECalendarMonths Month;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Standard", meta = (ClampMin = "0", UIMin = "0"))
- int32 Year;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Standard")
- FDay_Night_Cycle Daylight_Settings;
- };
- // Struct to define custom calendar types with non-standard day/month/year & second/minute/hour cycles
- USTRUCT(BlueprintType)
- struct FChaos_Calendar_Defaults
- {
- GENERATED_USTRUCT_BODY()
- public:
- // Customized calendar cycle variables
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Chaos", meta = (DisplayName = "Seconds Per Minute", ClampMin = "0", UIMin = "0"))
- int32 Seconds;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Chaos", meta = (DisplayName = "Minutes Per Hour", ClampMin = "0", UIMin = "0"))
- int32 Minutes;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Chaos", meta = (DisplayName = "Hours Per Day", ClampMin = "0", UIMin = "0"))
- int32 Hours;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Chaos", meta = (DisplayName = "Days Per Month", ClampMin = "1", UIMin = "1"))
- int32 Day;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Chaos", meta = (DisplayName = "Month Names"))
- TArray<FString> Chaos_Months;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Chaos")
- FDay_Night_Cycle Daylight_Settings;
- // Where to start counting time on a custom calendar cycle
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Chaos", meta = (DisplayName = "Start Second", ClampMin = "0", UIMin = "0"))
- int32 Start_Seconds;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Chaos", meta = (DisplayName = "Start Minute", ClampMin = "0", UIMin = "0"))
- int32 Start_Minutes;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Chaos", meta = (DisplayName = "Start Hour", ClampMin = "0", UIMin = "0"))
- int32 Start_Hours;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Chaos", meta = (DisplayName = "Start Day", ClampMin = "1", UIMin = "1"))
- int32 Start_Day;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Chaos", meta = (DisplayName = "Start Month Index", ClampMin = "0", UIMin = "0"))
- int32 Start_Month;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar|Chaos", meta = (DisplayName = "Start Year", ClampMin = "0", UIMin = "0"))
- int32 Start_Year;
- };
- UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
- class CODE_TEST_API UEarthTime : public UActorComponent
- {
- GENERATED_BODY()
- public:
- // Sets default values for this component's properties
- UEarthTime();
- // Called every frame
- virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
- // "Read Only" blueprint variables to give access to function data for UI purposes
- UPROPERTY(BlueprintReadOnly, Category = "Earth Time")
- FString World_Clock;
- UPROPERTY(BlueprintReadOnly, Category = "Earth Time")
- FString World_Date;
- UPROPERTY(BlueprintReadOnly, Category = "Earth Time")
- int32 Current_Seconds;
- UPROPERTY(BlueprintReadOnly, Category = "Earth Time")
- int32 Current_Minutes;
- UPROPERTY(BlueprintReadOnly, Category = "Earth Time")
- int32 Current_Hours;
- UPROPERTY(BlueprintReadOnly, Category = "Earth Time")
- int32 Current_Day;
- UPROPERTY(BlueprintReadOnly, Category = "Earth Time")
- int32 Current_Month;
- UPROPERTY(BlueprintReadOnly, Category = "Earth Time")
- int32 Current_Year;
- UPROPERTY(BlueprintReadOnly, Category = "Earth Time")
- float Sun_Degrees;
- // Blueprint exposed functions to manipulate World Clock settings
- UFUNCTION(BlueprintCallable)
- void Earth_Genesis(UPARAM()FStandard_Calendar Standard_Calendar, float Rate, UPARAM(DisplayName = "Military Time") bool TwentyFour, UPARAM()FChaos_Calendar_Defaults Chaos_Calendar, bool Custom_Calendar);
- UFUNCTION(BlueprintCallable)
- void AlterTime(float New_Rate, UPARAM(DisplayName = "Military Time") bool NewClock);
- UFUNCTION(BlueprintCallable)
- void Pause();
- UFUNCTION(BlueprintCallable)
- void Unpause();
- UFUNCTION(BlueprintCallable)
- void ClearTimer();
- UFUNCTION(BlueprintCallable)
- void ResetClock();
- UFUNCTION(BlueprintCallable)
- void SaveStandardDate(FStandard_Calendar &End_Date, bool Pause_Timer, bool Clear_Timer);
- UFUNCTION(BlueprintCallable)
- void SaveChaosDate(FChaos_Calendar_Defaults &End_Date, bool Pause_Timer, bool Clear_Timer);
- // Internal Functions
- UFUNCTION()
- void AgeOfEarth();
- UFUNCTION()
- void GenerateWorld_Clock();
- UFUNCTION()
- void GenerateWorld_Date();
- UFUNCTION()
- void GenerateDaysReset(int32 ActiveMonth);
- UFUNCTION()
- FString MonthAsString(int32 ConvertMonth);
- UFUNCTION()
- void Sun_Dial();
- // Global variables necessary for Earth Time functionality
- bool Time_Altered;
- bool Military_Time;
- bool Chaos;
- float Delta_Degrees;
- float Range;
- int32 SecondsReset;
- int32 SecondsResetValue;
- int32 MinutesReset;
- int32 MinutesResetValue;
- int32 HoursReset;
- int32 HoursResetValue;
- int32 DaysReset;
- int32 MonthsReset;
- ECalendarMonths Calendar_Months;
- FChaos_Calendar_Defaults Initial_Chaos_Calendar;
- FDay_Night_Cycle Daylight;
- TArray<FString> Chaos_Months;
- FTimerHandle Universal_Age;
- AActor* Parent_Actor;
- protected:
- // Called when the game starts
- virtual void BeginPlay() override;
- };
- ----------------------------------------------------------------------------------------
- #include "EarthTime.h"
- // Sets default values for this component's properties
- UEarthTime::UEarthTime()
- {
- // Disable tick for this component
- PrimaryComponentTick.bCanEverTick = false;
- // Retrieve actor component's Parent Actor
- Parent_Actor = GetOwner();
- // Assume no alterations to the rate and AM/PM output desired initially
- Time_Altered = false;
- Military_Time = false;
- // Set second/minute/hour/day/month cycle to standard values
- SecondsReset = 60;
- SecondsResetValue = 0;
- MinutesReset = 60;
- MinutesResetValue = 0;
- HoursReset = 24;
- HoursResetValue = 0;
- DaysReset = 32;
- MonthsReset = 12;
- // Initialize Daylight variables
- Sun_Degrees = 0;
- Delta_Degrees = 0.1;
- Range = 180;
- }
- // Called when the game starts
- void UEarthTime::BeginPlay()
- {
- Super::BeginPlay();
- }
- // Called every frame
- void UEarthTime::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
- {
- Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
- }
- // Set date and time values for timer function
- void UEarthTime::Earth_Genesis(UPARAM()FStandard_Calendar Standard_Calendar, float Rate, UPARAM(DisplayName = "Military Time") bool TwentyFour, UPARAM()FChaos_Calendar_Defaults Chaos_Calendar, bool Custom_Calendar)
- {
- // Should we start counting from initial input values or do we already have values
- if (Time_Altered == false)
- {
- // Determine if we are using a standard or non-standard calendar, if non-standard initialize user defined settings
- if (Custom_Calendar == true)
- {
- // We won't use AM/PM for non-standard calendars
- Military_Time = true;
- // Let the other functions know we are using a custom calendar
- Chaos = true;
- // Set the custom calendar cycle
- Initial_Chaos_Calendar = Chaos_Calendar;
- SecondsReset = Chaos_Calendar.Seconds;
- MinutesReset = Chaos_Calendar.Minutes;
- HoursReset = Chaos_Calendar.Hours;
- DaysReset = (Chaos_Calendar.Day + 1);
- MonthsReset = Chaos_Calendar.Chaos_Months.Num();
- Daylight = Chaos_Calendar.Daylight_Settings;
- // If no months named, populate array with error message & set start month to "0" index (prevents crash & identifies improper input)
- if (Chaos_Calendar.Chaos_Months.Num() < 1)
- {
- Chaos_Months = { "No Months Named In Custom Calendar" };
- Current_Month = 0;
- }
- else
- {
- Chaos_Months = Chaos_Calendar.Chaos_Months;
- Current_Month = Chaos_Calendar.Start_Month;
- }
- // Set initial start date and time for custom calendar
- Current_Seconds = Chaos_Calendar.Start_Seconds;
- Current_Minutes = Chaos_Calendar.Start_Minutes;
- Current_Hours = Chaos_Calendar.Start_Hours;
- Current_Day = Chaos_Calendar.Start_Day;
- Current_Year = Chaos_Calendar.Start_Year;
- // Ensure we don't start a month on Day "0"
- if (Current_Day == 0)
- {
- Current_Day = 1;
- }
- }
- else
- {
- // Determine if we are using a 12 or 24 hour clock
- Military_Time = TwentyFour;
- // Set start time and date to user defined input on a standard calendar
- Current_Seconds = Standard_Calendar.Seconds;
- Current_Minutes = Standard_Calendar.Minutes;
- Current_Hours = Standard_Calendar.Hours;
- Current_Day = Standard_Calendar.Day;
- Current_Month = static_cast<int>(Standard_Calendar.Month);
- Current_Year = Standard_Calendar.Year;
- Daylight = Standard_Calendar.Daylight_Settings;
- // Ensure we don't start a month on Day "0"
- if (Current_Day == 0)
- {
- Current_Day = 1;
- }
- }
- // Call function to ensure we don't start a month on a non-valid day
- GenerateDaysReset(Current_Month);
- // Set Sun starting position
- Sun_Degrees = Daylight.Sun_Start_Degrees;
- }
- // If we have altered time ensure the Sun is appropriately positioned to the point it was just before alteration
- if (Time_Altered == true && Chaos == true)
- {
- Sun_Degrees = Chaos_Calendar.Daylight_Settings.Sun_Start_Degrees;
- Military_Time = true;
- }
- else if (Time_Altered == true && Chaos == false)
- {
- Sun_Degrees = Standard_Calendar.Daylight_Settings.Sun_Start_Degrees;
- Military_Time = TwentyFour;
- }
- // Prevent division by "0" from improper user input
- if (Rate == 0)
- {
- Rate = 1;
- }
- // Calculate the number of degrees to move the Sun's position based on total daylight hours, total degrees and rate of time passage
- Range = (Daylight.Max_Degrees - Daylight.Min_Degrees);
- Delta_Degrees = (Range / Daylight.Hours_Of_Daylight / MinutesReset / SecondsReset);
- // Create a timer
- Parent_Actor->GetWorldTimerManager().SetTimer(Universal_Age, this, &UEarthTime::AgeOfEarth, 1 / Rate, true);
- }
- // Function that actually tracks date and time
- void UEarthTime::AgeOfEarth()
- {
- Current_Seconds++;
- if (Current_Seconds == SecondsReset)
- {
- Current_Seconds = SecondsResetValue;
- Current_Minutes ++;
- if (Current_Minutes == MinutesReset)
- {
- Current_Minutes = MinutesResetValue;
- Current_Hours ++;
- }
- if (Current_Hours == HoursReset)
- {
- Current_Hours = HoursResetValue;
- Current_Day ++;
- }
- if (Current_Day == DaysReset)
- {
- Current_Day = 1;
- Current_Month ++;
- GenerateDaysReset(Current_Month);
- }
- if (Current_Month == MonthsReset)
- {
- Current_Month = 0;
- Current_Year ++;
- }
- }
- // Function calls to create World Date and Clock string values and output the Sun position in degrees
- GenerateWorld_Clock();
- GenerateWorld_Date();
- Sun_Dial();
- }
- // Function to convert time values into "00:00:00" format (AM/PM if necessary)
- void UEarthTime::GenerateWorld_Clock()
- {
- FString HoursOutput;
- FString MinutesOutput;
- FString SecondsOutput;
- FString TimeOfDay = "AM";
- int32 StandardHours = Current_Hours;
- bool PM = false;
- if (Military_Time == false && StandardHours == 0)
- {
- StandardHours = 12;
- TimeOfDay = "AM";
- }
- else if (Military_Time == false && StandardHours > 12)
- {
- StandardHours -= 12;
- PM = true;
- TimeOfDay = "PM";
- }
- else if (Military_Time == false && StandardHours == 12)
- {
- PM = true;
- TimeOfDay = "PM";
- }
- HoursOutput = FString::FromInt(StandardHours);
- if (HoursOutput.Len() < 2)
- {
- HoursOutput = "0" + HoursOutput;
- }
- MinutesOutput = FString::FromInt(Current_Minutes);
- if (MinutesOutput.Len() < 2)
- {
- MinutesOutput = "0" + MinutesOutput;
- }
- SecondsOutput = FString::FromInt(Current_Seconds);
- if (SecondsOutput.Len() < 2)
- {
- SecondsOutput = "0" + SecondsOutput;
- }
- // If not on military time output string will include "AM/PM" designation
- if (Military_Time == false)
- {
- World_Clock = (HoursOutput + " : " + MinutesOutput + " : " + SecondsOutput + " " + TimeOfDay);
- }
- else
- {
- World_Clock = (HoursOutput + " : " + MinutesOutput + " : " + SecondsOutput);
- }
- }
- // Function to convert month, day, year values into "MM/DD/YYYY" format
- void UEarthTime::GenerateWorld_Date()
- {
- FString MonthOutput;
- FString DayOutput;
- FString YearOutput;
- MonthOutput = MonthAsString(Current_Month);
- DayOutput = FString::FromInt(Current_Day);
- if (DayOutput.Len() < 2)
- {
- DayOutput = "0" + DayOutput;
- }
- YearOutput = FString::FromInt(Current_Year);
- World_Date = (MonthOutput + " " + DayOutput + ", " + YearOutput);
- }
- // Function to "Pause" World Time
- void UEarthTime::Pause()
- {
- Parent_Actor->GetWorldTimerManager().PauseTimer(Universal_Age);
- }
- // Function to "Unpause" World Time
- void UEarthTime::Unpause()
- {
- Parent_Actor->GetWorldTimerManager().UnPauseTimer(Universal_Age);
- }
- // Function to "Clear" World Time
- void UEarthTime::ClearTimer()
- {
- Parent_Actor->GetWorldTimerManager().ClearTimer(Universal_Age);
- }
- // Function to "Reset" World Time to 00:00:00
- void UEarthTime::ResetClock()
- {
- Current_Seconds = 0;
- Current_Minutes = 0;
- Current_Hours = 0;
- }
- // Function to "Save" current World Time and Date
- void UEarthTime::SaveStandardDate(FStandard_Calendar &End_Date, bool Pause_Timer, bool Clear_Timer)
- {
- // Should we pause our timer during a save cycle or continue counting
- if (Pause_Timer == true)
- {
- Pause();
- }
- End_Date.Month = static_cast<ECalendarMonths>(Current_Month);
- End_Date.Day = Current_Day;
- End_Date.Year = Current_Year;
- End_Date.Hours = Current_Hours;
- End_Date.Minutes = Current_Minutes;
- End_Date.Seconds = Current_Seconds;
- End_Date.Daylight_Settings = Daylight;
- // Overwrite the default Sun position during a save cycle
- End_Date.Daylight_Settings.Sun_Start_Degrees = Sun_Degrees;
- // Should we stop our timer after saving or continue counting
- if (Clear_Timer == true)
- {
- ClearTimer();
- }
- }
- // Function to "Save" current World Time and Date for custom calendar types
- void UEarthTime::SaveChaosDate(FChaos_Calendar_Defaults &End_Date, bool Pause_Timer, bool Clear_Timer)
- {
- // Should we pause our timer during a save cycle or continue counting
- if (Pause_Timer == true)
- {
- Pause();
- }
- // When saving a custom calendar cycle, save the input defaults back out
- End_Date.Seconds = Initial_Chaos_Calendar.Seconds;
- End_Date.Minutes = Initial_Chaos_Calendar.Minutes;
- End_Date.Hours = Initial_Chaos_Calendar.Hours;
- End_Date.Day = Initial_Chaos_Calendar.Day;
- End_Date.Chaos_Months = Initial_Chaos_Calendar.Chaos_Months;
- End_Date.Daylight_Settings = Daylight;
- /* The new start time and date will be set to the last registered values, this way the struct can be directly fed back into the "Earth Genesis"
- function with no additional modifications and the cycle will continue at the exact spot of the last save with the same default cycle values*/
- End_Date.Start_Seconds = Current_Seconds;
- End_Date.Start_Minutes = Current_Minutes;
- End_Date.Start_Hours = Current_Hours;
- End_Date.Start_Day = Current_Day;
- End_Date.Start_Month = Current_Month;
- End_Date.Start_Year = Current_Year;
- // Overwrite the default Sun position during a save cycle
- End_Date.Daylight_Settings.Sun_Start_Degrees = Sun_Degrees;
- // Should we stop our timer after saving or continue counting
- if (Clear_Timer == true)
- {
- ClearTimer();
- }
- }
- // Function to change rate of World Time passage
- void UEarthTime::AlterTime(float New_Rate, UPARAM(DisplayName = "Military Time") bool NewClock)
- {
- // Declare both possible input types for a new Earth Genesis call **only one will be valid and used**
- FStandard_Calendar New_Start_Date;
- FChaos_Calendar_Defaults New_Chaos_Date;
- if (Chaos == true)
- {
- New_Chaos_Date.Seconds = Current_Seconds;
- New_Chaos_Date.Minutes = Current_Minutes;
- New_Chaos_Date.Hours = Current_Hours;
- New_Chaos_Date.Day = Current_Day;
- New_Chaos_Date.Start_Month = Current_Month;
- New_Chaos_Date.Start_Year = Current_Year;
- New_Chaos_Date.Daylight_Settings = Daylight;
- New_Chaos_Date.Daylight_Settings.Sun_Start_Degrees = Sun_Degrees;
- }
- else
- {
- New_Start_Date.Seconds = Current_Seconds;
- New_Start_Date.Minutes = Current_Minutes;
- New_Start_Date.Hours = Current_Hours;
- New_Start_Date.Day = Current_Day;
- New_Start_Date.Month = static_cast<ECalendarMonths>(Current_Month);
- New_Start_Date.Year = Current_Year;
- New_Start_Date.Daylight_Settings = Daylight;
- New_Start_Date.Daylight_Settings.Sun_Start_Degrees = Sun_Degrees;
- }
- // Let other functions know we have altered time
- Time_Altered = true;
- // Clear our current timer
- Parent_Actor->GetWorldTimerManager().ClearTimer(Universal_Age);
- // Reset our Earth Timer to the new rate and/or clock output type
- Earth_Genesis(New_Start_Date, New_Rate, NewClock, New_Chaos_Date, Chaos);
- }
- // Function to convert Month Enum to string for output to blueprints
- FString UEarthTime::MonthAsString(int32 ConvertMonth)
- {
- FString EnumMonth;
- if (Chaos == true)
- {
- EnumMonth = Chaos_Months[ConvertMonth];
- }
- else
- {
- switch (ConvertMonth)
- {
- case 0:
- EnumMonth = "January";
- break;
- case 1:
- EnumMonth = "February";
- break;
- case 2:
- EnumMonth = "March";
- break;
- case 3:
- EnumMonth = "April";
- break;
- case 4:
- EnumMonth = "May";
- break;
- case 5:
- EnumMonth = "June";
- break;
- case 6:
- EnumMonth = "July";
- break;
- case 7:
- EnumMonth = "August";
- break;
- case 8:
- EnumMonth = "September";
- break;
- case 9:
- EnumMonth = "October";
- break;
- case 10:
- EnumMonth = "November";
- break;
- case 11:
- EnumMonth = "December";
- break;
- default:
- EnumMonth = "Bad Month";
- break;
- }
- }
- return EnumMonth;
- }
- // Function to determine when to "reset" day count (adjusts for Leap year)
- void UEarthTime::GenerateDaysReset(int32 ActiveMonth)
- {
- // If using a non-standard calendar skip determining how many days/month, we will assume all months have the same # of days
- if (Chaos == true)
- ;
- else
- {
- switch (ActiveMonth)
- {
- case 0: case 2: case 4: case 6: case 7: case 9: case 11:
- DaysReset = 32;
- break;
- case 1:
- if (Current_Year % 4 == 0)
- {
- DaysReset = 30;
- }
- else
- {
- DaysReset = 29;
- }
- break;
- case 3: case 5: case 8: case 10:
- DaysReset = 31;
- break;
- default:
- DaysReset = 31;
- break;
- }
- }
- // Now that we know how many days are in the current month ensure we are on a valid day
- if (Current_Day >= DaysReset)
- {
- Current_Day = (DaysReset - 1);
- }
- }
- // Function to determine the Sun's position in degrees
- void UEarthTime::Sun_Dial()
- {
- /* Ensure we are only moving the Sun through the specified "Min" and "Max" degrees and make sure we only
- change the Sun's position during the specified "Daylight" hours, otherwise Sun position will be at "0" degrees*/
- if (Current_Hours < Daylight.Sunrise || Sun_Degrees >= Daylight.Max_Degrees || (Current_Hours - Daylight.Sunrise) >= Daylight.Hours_Of_Daylight)
- {
- Sun_Degrees = 0;
- }
- else
- {
- Sun_Degrees += Delta_Degrees;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment