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 "Components/ActorComponent.h"
- #include "Runtime/Engine/Classes/GameFramework/Actor.h"
- #include "Runtime/UMG/Public/Components/ProgressBar.h"
- #include "Runtime/Engine/Public/TimerManager.h"
- #include "Runtime/UMG/Public/Blueprint/UserWidget.h"
- #include "Floating_Fill_Bar.generated.h"
- // Enum of Times
- UENUM(BlueprintType)
- enum class ETime : uint8
- {
- Seconds, Minutes, Hours, Days, Months, Years
- };
- // Input struct for fill duration
- USTRUCT(BlueprintType)
- struct FCustom_Signals
- {
- GENERATED_USTRUCT_BODY()
- public:
- // How often we will call this event
- UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ClampMin = "0", UIMin = "0"))
- int32 Cycle_Length;
- // Enum selection of time denominations
- UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ClampMin = "0", UIMin = "0"))
- ETime Time_Category;
- };
- // Input struct for clock suffixes
- USTRUCT(BlueprintType)
- struct FClock_Suffix
- {
- GENERATED_USTRUCT_BODY()
- public:
- // The displayed suffix for the "year" length of time
- UPROPERTY(EditAnywhere, BlueprintReadWrite)
- FString Year_Suffix;
- // The displayed suffix for the "month" length of time
- UPROPERTY(EditAnywhere, BlueprintReadWrite)
- FString Month_Suffix;
- // The displayed suffix for the "day" length of time
- UPROPERTY(EditAnywhere, BlueprintReadWrite)
- FString Day_Suffix;
- // The displayed suffix for the "hour" length of time
- UPROPERTY(EditAnywhere, BlueprintReadWrite)
- FString Hour_Suffix;
- // The displayed suffix for the "minute" length of time
- UPROPERTY(EditAnywhere, BlueprintReadWrite)
- FString Minute_Suffix;
- // The displayed suffix for the "second" length of time
- UPROPERTY(EditAnywhere, BlueprintReadWrite)
- FString Second_Suffix;
- };
- // Input struct containing all data necessary to update the given progress bar
- USTRUCT(BlueprintType)
- struct FWait_Time
- {
- GENERATED_USTRUCT_BODY()
- public:
- // The fill percent between 0 and 100 to start out progress bar at
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Wait Time", meta = (ClampMin = "0", ClampMax = "100", UIMin = "0", UIMax = "100"))
- int32 Start_Percent;
- // The number of seconds on the clock
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Wait Time", meta = (ClampMin = "0", ClampMax = "59", UIMin = "0", UIMax = "59"))
- int32 Seconds;
- // The number of minutes on the clock
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Wait Time", meta = (ClampMin = "0", ClampMax = "59", UIMin = "0", UIMax = "59"))
- int32 Minutes;
- // The number of hours on the clock
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Wait Time", meta = (ClampMin = "0", ClampMax = "23", UIMin = "0", UIMax = "23"))
- int32 Hours;
- // The number of days on the clock
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Wait Time", meta = (ClampMin = "0", ClampMax = "31", UIMin = "0", UIMax = "31"))
- int32 Days;
- // The number of months on the clock
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Wait Time", meta = (ClampMin = "0", ClampMax = "12", UIMin = "0", UIMax = "12"))
- int32 Months;
- // The number of years on the clock
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Wait Time", meta = (ClampMin = "0", UIMin = "0"))
- int32 Years;
- // The name of the progress bar variable inside the widget
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Wait Time")
- FName Progress_Bar_Name;
- // Input struct of all time denomination suffixes
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Wait Time")
- FClock_Suffix Custom_Suffix;
- // Input array of all custom blueprint events to fire off with their cycle lengths
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Wait Time")
- TArray<FCustom_Signals> Signals;
- // Save the Signal Counter value in case we load from a save file we will still fire off events at the given cycle instead of starting over
- int32 SaveCount;
- };
- UCLASS( ClassGroup=(Custom), Blueprintable, meta=(BlueprintSpawnableComponent) )
- class CODE_TEST_API UFloating_Fill_Bar : public UActorComponent
- {
- GENERATED_BODY()
- public:
- // Sets default values for this component's properties
- UFloating_Fill_Bar();
- // Called every frame
- virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
- // Read the value representing the remaining time on the clock
- UPROPERTY(BlueprintReadOnly, Category = "Floating Fill Bar")
- FString Clock;
- // Read the seconds left on the clock
- UPROPERTY(BlueprintReadOnly, Category = "Floating Fill Bar")
- int32 Seconds_Left;
- // Read the minutes left on the clock
- UPROPERTY(BlueprintReadOnly, Category = "Floating Fill Bar")
- int32 Minutes_Left;
- // Read the hours left on the clock
- UPROPERTY(BlueprintReadOnly, Category = "Floating Fill Bar")
- int32 Hours_Left;
- // Read the days left on the clock
- UPROPERTY(BlueprintReadOnly, Category = "Floating Fill Bar")
- int32 Days_Left;
- // Read the months left on the clock
- UPROPERTY(BlueprintReadOnly, Category = "Floating Fill Bar")
- int32 Months_Left;
- // Read the years left on the clock
- UPROPERTY(BlueprintReadOnly, Category = "Floating Fill Bar")
- int32 Years_Left;
- // Function to modify an input widget's progress bar by name
- UFUNCTION(BlueprintCallable)
- void UpdateBar(FWait_Time Duration, float GameSeconds_Per_Realtime, bool Fill, bool Hide_When_Complete, UUserWidget* Floating_Widget, bool Custom_Signaling);
- // Function to change the rate of time passage
- UFUNCTION(BlueprintCallable)
- void Alter_Rate_Of_Time_Passage(float New_Speed);
- // Function to pause our timer
- UFUNCTION(BlueprintCallable)
- void Pause();
- // Function to unpause our timer
- UFUNCTION(BlueprintCallable)
- void Unpause();
- // Function to clear our timer
- UFUNCTION(BlueprintCallable)
- void ClearTimer();
- // Function to modify the remaining time on the clock and/or speed changes to other variables will not be carried through and can be left blank
- UFUNCTION(BlueprintCallable)
- void Modify_Clock(FWait_Time Modify_Time, float Modify_Speed);
- // Function to output a single struct with the last known remaining time, can be directly fed back into a call to "Update Bar"
- UFUNCTION(BlueprintCallable)
- void SaveClock(FWait_Time &Save_Time);
- // Function called when the clock has finished counting down
- UFUNCTION(BlueprintImplementableEvent)
- void FillBar_Completed();
- // Custom event to fire off at the given interval
- UFUNCTION(BlueprintImplementableEvent)
- void Custom_Signal_1();
- // Custom event to fire off at the given interval
- UFUNCTION(BlueprintImplementableEvent)
- void Custom_Signal_2();
- // Custom event to fire off at the given interval
- UFUNCTION(BlueprintImplementableEvent)
- void Custom_Signal_3();
- // Custom event to fire off at the given interval
- UFUNCTION(BlueprintImplementableEvent)
- void Custom_Signal_4();
- // Custom event to fire off at the given interval
- UFUNCTION(BlueprintImplementableEvent)
- void Custom_Signal_5();
- // Global variables for internal use only
- bool IsFilling;
- bool Error;
- bool UseCustomSignals;
- bool Hide;
- int32 SecondsResetValue;
- int32 MinutesResetValue;
- int32 HoursResetValue;
- int32 DaysResetValue;
- int32 MonthsResetValue;
- int32 DefaultReset;
- int32 SignalCounter;
- float TotalWaitTime;
- float DeltaPercent;
- float CurrentPercent;
- FString SecondsOutput;
- FString MinutesOutput;
- FString HoursOutput;
- FString DaysOutput;
- FString MonthsOutput;
- FString YearsOutput;
- FString InputWarning;
- FWait_Time InternalWaitTime;
- FTimerHandle FillBarHandle;
- UUserWidget* InternalWidget;
- UProgressBar* InternalProgressBar;
- AActor* Parent_Actor;
- // Internal use functions
- void CountTime();
- void Fill_Unfill();
- void GenerateClock();
- void Check_Custom_Signals();
- void Revert_Signal_Cycle();
- protected:
- // Called when the game starts
- virtual void BeginPlay() override;
- };
- -------------------------------------------------------------------------------------------------
- // Fill out your copyright notice in the Description page of Project Settings.
- #include "Floating_Fill_Bar.h"
- // Sets default values for this component's properties
- UFloating_Fill_Bar::UFloating_Fill_Bar()
- {
- // Disable tick
- PrimaryComponentTick.bCanEverTick = false;
- // Retrieve actor component's Parent Actor
- Parent_Actor = GetOwner();
- // Assume a proper time was entered
- Error = false;
- // Many variables need to be reset at "-1", we shall declare this as an easy to read variable
- DefaultReset = -1;
- // Set the clock's reset values
- SecondsResetValue = 59;
- MinutesResetValue = 59;
- HoursResetValue = 23;
- DaysResetValue = 29;
- MonthsResetValue = 11;
- // Always start our signal counter at 0
- SignalCounter = 0;
- // Assume we should hide when complete
- Hide = true;
- }
- // Called when the game starts
- void UFloating_Fill_Bar::BeginPlay()
- {
- Super::BeginPlay();
- // ...
- }
- // Called every frame
- void UFloating_Fill_Bar::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
- {
- Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
- // ...
- }
- void UFloating_Fill_Bar::UpdateBar(FWait_Time Duration, float GameSeconds_Per_Realtime, bool Fill, bool Hide_When_Complete, UUserWidget* Floating_Widget, bool Custom_Signaling)
- {
- // Copy our input struct for use in other functions
- InternalWaitTime = Duration;
- // Determine if we are filling or emptying the progress bar
- IsFilling = Fill;
- // Should we hide the fill bar once complete?
- Hide = Hide_When_Complete;
- // Determine if we have custom signals to handle
- UseCustomSignals = Custom_Signaling;
- // Set the current percent and wait time to desired values
- CurrentPercent = float(InternalWaitTime.Start_Percent) / 100;
- Seconds_Left = InternalWaitTime.Seconds;
- Minutes_Left = InternalWaitTime.Minutes;
- Hours_Left = InternalWaitTime.Hours;
- Days_Left = InternalWaitTime.Days;
- Months_Left = InternalWaitTime.Months;
- Years_Left = InternalWaitTime.Years;
- // If this is saved data our Signal Count should be set to the last value it had, otherwise it will remain at the default value of 0
- if (InternalWaitTime.SaveCount > 0)
- {
- SignalCounter = InternalWaitTime.SaveCount;
- }
- // Set our global widget variable to the widget reference supplied by the user
- InternalWidget = Floating_Widget;
- // Set our progress bar pointer
- InternalProgressBar = dynamic_cast<UProgressBar*>(InternalWidget->GetWidgetFromName(FName(InternalWaitTime.Progress_Bar_Name)));
- // If we are using the custom signal feature calculate the cycle length in seconds
- if (UseCustomSignals == true && InternalWaitTime.Signals.Num() > 0)
- {
- // Local variables for making time conversions
- int32 ConversionRate = 1;
- // Loop through input array and convert all signal durations into seconds
- for (int x = 0; x < InternalWaitTime.Signals.Num(); ++x)
- {
- if (InternalWaitTime.Signals[x].Cycle_Length > 0)
- {
- switch (InternalWaitTime.Signals[x].Time_Category)
- {
- case ETime::Seconds:
- ConversionRate = 1;
- break;
- case ETime::Minutes:
- ConversionRate = 60;
- break;
- case ETime::Hours:
- ConversionRate = 3600;
- break;
- case ETime::Days:
- ConversionRate = 86400;
- break;
- case ETime::Months:
- ConversionRate = 2592000;
- break;
- case ETime::Years:
- ConversionRate = 31536000;
- break;
- default:
- break;
- }
- InternalWaitTime.Signals[x].Cycle_Length *= ConversionRate;
- }
- }
- }
- else
- {
- UseCustomSignals = false;
- }
- // Set the progress bar to the desired percentage
- InternalProgressBar->SetPercent(CurrentPercent);
- // Ensure input percentage is between 0 and 1 and makes sense based on whether we are filling or emptying the bar
- if (CurrentPercent < 0.f && IsFilling == true)
- {
- CurrentPercent = 0.f;
- // We will repeat this function since we assume the input is correct and simply out of range ** we are filling an empty bar **
- InternalProgressBar->SetPercent(CurrentPercent);
- }
- else if (CurrentPercent <= 0 && IsFilling == false)
- {
- // We will not attempt to guess the user's intent here, the inputs are contradictory as the warning text states so we will error out
- Error = true;
- InputWarning = "Attempting to drain an empty bar!!";
- }
- else if (CurrentPercent > 1.f && IsFilling == false)
- {
- CurrentPercent = 1.f;
- // We will repeat this function since we assume the input is correct and simply out of range ** we are emptying a full bar **
- InternalProgressBar->SetPercent(CurrentPercent);
- }
- else if (CurrentPercent >= 1.f && IsFilling == true)
- {
- // We will not attempt to guess the user's intent here, the inputs are contradictory as the warning text states so we will error out
- Error = true;
- InputWarning = "Attempting to fill a full bar!!";
- }
- // Perform initial subtraction to ensure time counts down properly in cases where we start at 0 seconds
- if (Seconds_Left == 0)
- {
- if (Minutes_Left > 0)
- {
- Minutes_Left--;
- Seconds_Left = 60;
- }
- else if (Hours_Left > 0)
- {
- Hours_Left--;
- Minutes_Left = MinutesResetValue;
- Seconds_Left = SecondsResetValue;
- }
- else if (Days_Left > 0)
- {
- Days_Left--;
- Hours_Left = HoursResetValue;
- Minutes_Left = MinutesResetValue;
- Seconds_Left = SecondsResetValue;
- }
- else if (Months_Left > 0)
- {
- Months_Left--;
- Days_Left = DaysResetValue;
- Hours_Left = HoursResetValue;
- Minutes_Left = MinutesResetValue;
- Seconds_Left = SecondsResetValue;
- }
- else if (Years_Left > 0)
- {
- Years_Left--;
- Months_Left = MonthsResetValue;
- Days_Left = DaysResetValue;
- Hours_Left = HoursResetValue;
- Minutes_Left = MinutesResetValue;
- Seconds_Left = SecondsResetValue;
- }
- else
- {
- Error = true;
- InputWarning = "Attempting to count down but no time was entered!!";
- }
- }
- // If no input errors occured ** a valid time was entered ** we may continue
- if (Error == false)
- {
- // For delta time calculation purposes create a temporary percent in case we are starting at 0% otherwise we will have no "delta" value
- float TempPercent;
- if (CurrentPercent == 0.f || CurrentPercent == 1.f)
- {
- // If we fill from empty or drain from full we must traverse the entire fill bar thus the "percent" is set to 1
- TempPercent = 1.f;
- }
- else
- {
- // Get the remaining percent to fill
- TempPercent = (1 - CurrentPercent);
- }
- // Prevent accidental division by "0"
- if (GameSeconds_Per_Realtime == 0.f)
- {
- GameSeconds_Per_Realtime = 1.f;
- }
- // Determine how long in seconds it will take to fill the progress bar
- TotalWaitTime = float((InternalWaitTime.Years * 31536000) + (InternalWaitTime.Months * 2592000) + (InternalWaitTime.Days * 86400) + (InternalWaitTime.Hours * 3600) + (InternalWaitTime.Minutes * 60) + (InternalWaitTime.Seconds));
- // Determine how much the progress bar should change each cycle ** this is why TempPercent is needed because starting at 0% will give a 0 value here
- DeltaPercent = (TempPercent / TotalWaitTime);
- // If we are emptying the progress bar make DeltaPercent negative
- if (IsFilling == false)
- {
- DeltaPercent *= -1;
- }
- // Create a timer
- Parent_Actor->GetWorldTimerManager().SetTimer(FillBarHandle, this, &UFloating_Fill_Bar::CountTime, (1 / GameSeconds_Per_Realtime), true);
- }
- else
- {
- // Output an error message where we expect to see the time remaining
- Clock = InputWarning;
- }
- }
- // Function that actually counts time down
- void UFloating_Fill_Bar::CountTime()
- {
- Seconds_Left--;
- if (Seconds_Left == DefaultReset)
- {
- Seconds_Left = SecondsResetValue;
- Minutes_Left--;
- if (Minutes_Left == DefaultReset && Hours_Left > 0)
- {
- Minutes_Left = MinutesResetValue;
- Hours_Left--;
- }
- else if (Minutes_Left == DefaultReset && Hours_Left == 0)
- {
- Hours_Left--;
- }
- if (Hours_Left == DefaultReset && Days_Left > 0)
- {
- Minutes_Left = MinutesResetValue;
- Hours_Left = HoursResetValue;
- Days_Left--;
- }
- else if(Hours_Left == DefaultReset && Days_Left == 0)
- {
- Days_Left--;
- }
- if (Days_Left == DefaultReset && Months_Left > 0)
- {
- Minutes_Left = MinutesResetValue;
- Hours_Left = HoursResetValue;
- Days_Left = DaysResetValue;
- Months_Left--;
- }
- else if (Days_Left == DefaultReset && Months_Left == 0)
- {
- Months_Left--;
- }
- if (Months_Left == DefaultReset && Years_Left > 0)
- {
- Minutes_Left = MinutesResetValue;
- Hours_Left = HoursResetValue;
- Days_Left = DaysResetValue;
- Months_Left = MonthsResetValue;
- Years_Left--;
- }
- }
- if (UseCustomSignals == true)
- {
- SignalCounter++;
- Check_Custom_Signals();
- }
- // Check if we have completed filling or emptying the progress bar
- if (Seconds_Left == 0 && Minutes_Left == 0 && Hours_Left == 0 && Days_Left == 0 && Months_Left == 0 && Years_Left == 0)
- {
- if (IsFilling == true)
- {
- InternalProgressBar->SetPercent(0.f);
- }
- else
- {
- InternalProgressBar->SetPercent(1.f);
- }
- // If we are finished pause the timer and clear it
- Pause();
- ClearTimer();
- // Fire off blueprint event when fill bar is done filling or emptying
- FillBar_Completed();
- // Should we hide our fill bar now that is is complete?
- if (Hide == true)
- {
- InternalProgressBar->SetVisibility(ESlateVisibility::Hidden);
- }
- }
- // Function call to create Clock string values
- GenerateClock();
- // Function call to fill or empty our progress bar by the specified amount
- Fill_Unfill();
- }
- // Function that creates the output string "Clock"
- void UFloating_Fill_Bar::GenerateClock()
- {
- if (Years_Left == 0)
- {
- YearsOutput = "";
- }
- else
- {
- YearsOutput = FString::FromInt(Years_Left) + " " + InternalWaitTime.Custom_Suffix.Year_Suffix + " ";
- }
- if (Months_Left == 0 && Years_Left == 0)
- {
- MonthsOutput = "";
- }
- else
- {
- MonthsOutput = FString::FromInt(Months_Left) + " " + InternalWaitTime.Custom_Suffix.Month_Suffix + " ";
- }
- if (Days_Left == 0 && Months_Left == 0 && Years_Left == 0)
- {
- DaysOutput = "";
- }
- else
- {
- DaysOutput = FString::FromInt(Days_Left) + " " + InternalWaitTime.Custom_Suffix.Day_Suffix + " ";
- }
- if (Hours_Left == 0 && Days_Left == 0 && Months_Left == 0 && Years_Left == 0)
- {
- HoursOutput = "";
- }
- else
- {
- HoursOutput = FString::FromInt(Hours_Left) + " " + InternalWaitTime.Custom_Suffix.Hour_Suffix + " ";
- }
- if (Minutes_Left == 0 && Hours_Left == 0 && Days_Left == 0 && Months_Left == 0 && Years_Left == 0)
- {
- MinutesOutput = "";
- }
- else
- {
- MinutesOutput = FString::FromInt(Minutes_Left) + " " + InternalWaitTime.Custom_Suffix.Minute_Suffix + " ";
- }
- SecondsOutput = FString::FromInt(Seconds_Left) + " " + InternalWaitTime.Custom_Suffix.Second_Suffix + " ";
- Clock = YearsOutput + MonthsOutput + DaysOutput + HoursOutput + MinutesOutput + SecondsOutput;
- if (Error == true)
- {
- Clock = "PLEASE ENTER A VALID TIME";
- }
- }
- // Update our progress bar, either fill or empty it incrementally
- void UFloating_Fill_Bar::Fill_Unfill()
- {
- CurrentPercent += DeltaPercent;
- InternalProgressBar->SetPercent(CurrentPercent);
- }
- // Allows for modification of the rate of time passage through a blueprint function call
- void UFloating_Fill_Bar::Alter_Rate_Of_Time_Passage(float New_Speed)
- {
- Revert_Signal_Cycle();
- InternalWaitTime.Seconds = Seconds_Left;
- InternalWaitTime.Minutes = Minutes_Left;
- InternalWaitTime.Hours = Hours_Left;
- InternalWaitTime.Days = Days_Left;
- InternalWaitTime.Months = Months_Left;
- InternalWaitTime.Years = Years_Left;
- InternalWaitTime.Start_Percent = (CurrentPercent * 100);
- UpdateBar(InternalWaitTime, New_Speed, IsFilling, Hide, InternalWidget, UseCustomSignals);
- }
- // Function to pause our timer
- void UFloating_Fill_Bar::Pause()
- {
- Parent_Actor->GetWorldTimerManager().PauseTimer(FillBarHandle);
- }
- // Function to unpause our timer
- void UFloating_Fill_Bar::Unpause()
- {
- Parent_Actor->GetWorldTimerManager().UnPauseTimer(FillBarHandle);
- }
- // Function to clear our timer
- void UFloating_Fill_Bar::ClearTimer()
- {
- Parent_Actor->GetWorldTimerManager().ClearTimer(FillBarHandle);
- }
- // Function to modify our count down in real time
- void UFloating_Fill_Bar::Modify_Clock(FWait_Time Modify_Time, float Modify_Speed)
- {
- Revert_Signal_Cycle();
- InternalWaitTime.Seconds = Modify_Time.Seconds;
- InternalWaitTime.Minutes = Modify_Time.Minutes;
- InternalWaitTime.Hours = Modify_Time.Hours;
- InternalWaitTime.Days = Modify_Time.Days;
- InternalWaitTime.Months = Modify_Time.Months;
- InternalWaitTime.Years = Modify_Time.Years;
- InternalWaitTime.Start_Percent = Modify_Time.Start_Percent;
- UpdateBar(InternalWaitTime, Modify_Speed, IsFilling, Hide, InternalWidget, UseCustomSignals);
- }
- // Function to save the status of our fill bar current count down
- void UFloating_Fill_Bar::SaveClock(FWait_Time &Save_Time)
- {
- Revert_Signal_Cycle();
- Save_Time = InternalWaitTime;
- Save_Time.Seconds = Seconds_Left;
- Save_Time.Minutes = Minutes_Left;
- Save_Time.Hours = Hours_Left;
- Save_Time.Days = Days_Left;
- Save_Time.Months = Months_Left;
- Save_Time.Years = Years_Left;
- Save_Time.Start_Percent = (CurrentPercent * 100);
- Save_Time.SaveCount = SignalCounter;
- }
- // Fire off blueprint events at specified rates
- void UFloating_Fill_Bar::Check_Custom_Signals()
- {
- for (int x = 0; x < InternalWaitTime.Signals.Num(); ++x)
- {
- if (InternalWaitTime.Signals[x].Cycle_Length > 0 && (SignalCounter % InternalWaitTime.Signals[x].Cycle_Length) == 0)
- {
- switch (x)
- {
- case 0:
- Custom_Signal_1();
- break;
- case 1:
- Custom_Signal_2();
- break;
- case 2:
- Custom_Signal_3();
- break;
- case 3:
- Custom_Signal_4();
- break;
- case 4:
- Custom_Signal_5();
- break;
- default:
- break;
- }
- }
- }
- // If we have reached the max value for an int32 reset the count to 0 ** cylcles greater than 68 years won't work, they exceed this value **
- if (SignalCounter == 2147483647)
- {
- SignalCounter = 0;
- }
- }
- // Function to convert the custom blueprint event cycle length back to the enum compatible value
- void UFloating_Fill_Bar::Revert_Signal_Cycle()
- {
- // Local variables for making time conversions
- int32 ConversionRate = 1;
- for (int x = 0; x < InternalWaitTime.Signals.Num(); ++x)
- {
- if (InternalWaitTime.Signals[x].Cycle_Length > 0)
- {
- switch (InternalWaitTime.Signals[x].Time_Category)
- {
- case ETime::Seconds:
- ConversionRate = 1;
- break;
- case ETime::Minutes:
- ConversionRate = 60;
- break;
- case ETime::Hours:
- ConversionRate = 3600;
- break;
- case ETime::Days:
- ConversionRate = 86400;
- break;
- case ETime::Months:
- ConversionRate = 2592000;
- break;
- case ETime::Years:
- ConversionRate = 31536000;
- break;
- default:
- break;
- }
- InternalWaitTime.Signals[x].Cycle_Length /= ConversionRate;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment