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 "Runtime/Engine/Classes/Materials/MaterialParameterCollection.h"
- #include "Runtime/CoreUObject/Public/UObject/Class.h"
- #include "Runtime/Engine/Classes/Kismet/KismetMaterialLibrary.h"
- #include "Runtime/Engine/Classes/Materials/MaterialParameterCollectionInstance.h"
- #include "TimerManager.h"
- #include "Engine/World.h"
- #include "ConstructorHelpers.h"
- #include "Runtime/Engine/Classes/Particles/ParticleSystemComponent.h"
- #include "Runtime/Engine/Classes/Engine/DirectionalLight.h"
- #include "Core.h"
- #include "GameFramework/Actor.h"
- #include "DynamicSkysphereController.generated.h"
- UENUM(BlueprintType)
- enum EWeather
- {
- Sunny,
- Raining,
- Snowing
- };
- UCLASS()
- class SWCPP_API ADynamicSkysphereController : public AActor
- {
- GENERATED_BODY()
- public:
- FTimerHandle WeatherTimerHandle;
- UPROPERTY(EditAnywhere)
- bool ForceResetTimer = false;
- UPROPERTY(EditAnywhere)
- bool ForceUpdateWeather = false;
- UPROPERTY(VisibleAnywhere, Category = "Weather")
- int WeatherTimerMinimumInSeconds;
- UPROPERTY(VisibleAnywhere, Category = "Weather")
- int WeatherTimerMaximumInSeconds;
- UPROPERTY(EditAnywhere, BlueprintReadwrite, Category = "Weather")
- float WeatherTimerMaximumInMinutes = 2;
- UPROPERTY(EditAnywhere, BlueprintReadwrite, Category = "Weather")
- float WeatherTimerMinimumInMinutes = 1;
- UPROPERTY(VisibleAnywhere, Category = "Weather")
- int TimeBeforeWeatherChangeInSeconds;
- UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Date")
- int Day = 0;
- UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Date")
- int Month = 0;
- UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Date")
- int Year = 0;
- UPROPERTY(EditAnywhere, BlueprintReadwrite, Category = "Day/Night Cycle")
- float DayLengthInMinutes = 1;
- UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Day/Night Cycle")
- float CurrentHour;
- UPROPERTY(VisibleAnywhere, Category = "Day/Night Cycle")
- float SunAngle;
- UPROPERTY(EditAnywhere, BlueprintReadwrite, Category = "Day/Night Cycle")
- float HourOffset = 0;
- UPROPERTY(EditAnywhere, BlueprintReadwrite, Category = "Day/Night Cycle")
- float MaxSunIntensity = 10;
- UPROPERTY(EditAnywhere, BlueprintReadwrite, Category = "Day/Night Cycle")
- float SpeedOfSunRiseAndFall = 5;
- UPROPERTY(EditAnywhere, BlueprintReadwrite, Category = "Day/Night Cycle")
- ADirectionalLight* Sun;
- UPROPERTY(EditAnywhere, BlueprintReadwrite, Category = "Day/Night Cycle")
- AActor* Skysphere;
- UPROPERTY(BlueprintReadOnly, Category = "Day/Night Cycle")
- float OneDayInSeconds;
- UPROPERTY(BlueprintReadOnly, Category = "Day/Night Cycle")
- float OneHour;
- UPROPERTY(BlueprintReadOnly, Category = "Day/Night Cycle")
- float DeltaSpeedOfSun;
- UPROPERTY(BlueprintReadOnly, Category = "Day/Night Cycle")
- float CurrentInterpValue;
- UPROPERTY()
- class UParticleSystemComponent* PSRain;
- UPROPERTY()
- class UParticleSystemComponent* PSSnow;
- UPROPERTY(EditAnywhere, BlueprintReadwrite, Category = "Weather")
- TEnumAsByte<EWeather> CurrentWeather;
- UMaterialParameterCollectionInstance* matParamInst;
- UMaterialParameterCollection* matParam;
- UWorld* worldContext;
- private:
- void Lights();
- void IncrementDay();
- void PickRandomInteger();
- void ChooseRandomWeather();
- void setValues();
- void UpdateWeather();
- void ChangeWeather();
- public:
- // Sets default values for this actor's properties
- ADynamicSkysphereController();
- protected:
- // Called when the game starts or when spawned
- virtual void BeginPlay() override;
- public:
- // Called every frame
- virtual void Tick(float DeltaTime) override;
- UFUNCTION(BlueprintCallable, BlueprintPure)
- bool IsRaining();
- UFUNCTION(BlueprintCallable, BlueprintPure)
- bool IsSnowing();
- UFUNCTION(BlueprintCallable, BlueprintPure)
- bool IsSunny();
- };
Add Comment
Please, Sign In to add comment