58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Actors/SunMoonDaySequenceActor.h"
|
|
#include "Faye/Structs/TimeOfDayDef.h"
|
|
|
|
#include "TimeOfDayActor.generated.h"
|
|
|
|
class ADaySequenceActor;
|
|
|
|
USTRUCT(BlueprintType)
|
|
struct FTimeChangedPayload
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Time")
|
|
float SecondsPassed = 0.f;
|
|
};
|
|
|
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTimeChanged, FTimeChangedPayload, Payload);
|
|
|
|
UCLASS()
|
|
class FAYE_API ATimeOfDayActor : public ASunMoonDaySequenceActor
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
|
|
// Real life second = how many in game seconds
|
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Time")
|
|
float RealTimeSpeed = 10.f;
|
|
|
|
UPROPERTY(BlueprintAssignable)
|
|
FOnTimeChanged OnTimeChanged;
|
|
|
|
ATimeOfDayActor(const FObjectInitializer& Init);
|
|
virtual void Tick(float DeltaTime) override;
|
|
|
|
UFUNCTION(BlueprintPure)
|
|
const FTimeOfDayDef& GetTime() const { return TimeDef; }
|
|
|
|
protected:
|
|
|
|
UPROPERTY(BlueprintReadOnly, Category = "Time")
|
|
bool bTimeActive = true;
|
|
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Time")
|
|
FTimeOfDayDef TimeDef;
|
|
|
|
UPROPERTY()
|
|
float AccumulatedSeconds = 0.f;
|
|
|
|
virtual void BeginPlay() override;
|
|
void AddTime(float Seconds);
|
|
};
|