Inital Commit

This commit is contained in:
Mueller Wayan
2025-08-15 10:40:09 +02:00
commit d31b693fd2
521 changed files with 933 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyClass.h"
MyClass::MyClass()
{
}
MyClass::~MyClass()
{
}
+15
View File
@@ -0,0 +1,15 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
/**
*
*/
class NESIANDMYPROJECT_API MyClass
{
public:
MyClass();
~MyClass();
};
@@ -0,0 +1,24 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
public class NesiAndMyProject : ModuleRules
{
public NesiAndMyProject(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" , "Niagara" });
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}
@@ -0,0 +1,6 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "NesiAndMyProject.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, NesiAndMyProject, "NesiAndMyProject" );
@@ -0,0 +1,6 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
@@ -0,0 +1,33 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyActorComponent.h"
// Sets default values for this component's properties
UMyActorComponent::UMyActorComponent()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
}
// Called when the game starts
void UMyActorComponent::BeginPlay()
{
Super::BeginPlay();
// ...
}
// Called every frame
void UMyActorComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}
@@ -0,0 +1,172 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "WheatherSystem.h"
#include <Camera/CameraComponent.h>
// Sets default values
AWheatherSystem::AWheatherSystem()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
RainComponent = CreateDefaultSubobject<UNiagaraComponent>(TEXT("RainComponent"));
SnowComponent = CreateDefaultSubobject<UNiagaraComponent>(TEXT("SnowComponent"));
RainComponent->bAutoActivate = false;
SnowComponent->bAutoActivate = false;
RainComponent->Deactivate();
SnowComponent->Deactivate();
SetActorLocation(FVector(0, 0, 0));
if (Sun != NULL && DayCurve != NULL && Moon != NULL) {
FRotator* SunRotation = new FRotator(0.0, 0.0, 0.0);
FRotator* MoonRotation = new FRotator(0.0, 0.0, 0.0);
SunRotation->Pitch = DayCurve->GetFloatValue(CurrentTime);
MoonRotation->Pitch = DayCurve->GetFloatValue(CurrentTime) * -1;
Moon->SetActorRotation(*MoonRotation);
Sun->SetActorRotation(*SunRotation);
UpdateWeather();
}
}
// Called when the game starts or when spawned
void AWheatherSystem::BeginPlay()
{
Super::BeginPlay();
OneHoure = (DayLengthMiutes * 60) / 24;
APawn* PlayerPawn = UGameplayStatics::GetPlayerPawn(this, 0);
USceneComponent* PlayerRoot = PlayerPawn->GetRootComponent();
UCameraComponent* PlayerCamera = PlayerPawn->FindComponentByClass<UCameraComponent>();
RainComponent->AttachToComponent(PlayerCamera, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, true));
SnowComponent->AttachToComponent(PlayerCamera, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, true));
const FNiagaraParameterStore& RainParameterStore = RainComponent->GetOverrideParameters();
const FNiagaraParameterStore& SnowParameterStore = SnowComponent->GetOverrideParameters();
FNiagaraVariable Variable(FNiagaraTypeDefinition::GetFloatDef(), "SpawnRate");
RainParameterStore.GetParameterValue(MaxRain, Variable);
SnowParameterStore.GetParameterValue(MaxSnow, Variable);
}
// Called every frame
void AWheatherSystem::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
double newTime = CurrentTime + (DeltaTime / OneHoure);
if (newTime > 24) {
newTime = newTime - 24;
}
CurrentTime = newTime;
if (Sun != NULL && DayCurve != NULL && Moon != NULL) {
FRotator* SunRotation = new FRotator(0.0, 0.0, 0.0);
FRotator* MoonRotation = new FRotator(0.0, 0.0, 0.0);
// Sonnenbewegung
SunRotation->Pitch = DayCurve->GetFloatValue(CurrentTime);
// Mondbewegung
MoonRotation->Pitch = SunRotation->Pitch - 180.0f;
//Rotationen anwenden
Sun->SetActorRotation(*SunRotation);
Moon->SetActorRotation(*MoonRotation);
UpdateWeather();
}
}
void AWheatherSystem::UpdateWeather() {
if (SunlightItensity != NULL && SkylightIntensity != NULL && WeatherTypeCurve != NULL) {
float weatherType = WeatherTypeCurve->GetFloatValue(CurrentTime);
Sun->GetLightComponent()->SetIntensity(
FMath::Lerp(
SunlightItensity->GetVectorValue(CurrentTime).X,
SunlightItensity->GetVectorValue(CurrentTime).Y,
weatherType));
SkyLight->GetLightComponent()->SetIntensity(
FMath::Lerp(
SkylightIntensity->GetVectorValue(CurrentTime).X,
SkylightIntensity->GetVectorValue(CurrentTime).Y,
weatherType));
}
UpdateRain();
UpdateSnow();
UpdateFog();
Sun->GetLightComponent()->SetEnableLightShaftBloom(CurrentTime > 6.0 && CurrentTime < 18.0);
Sun->GetComponent()->SetEnableLightShaftOcclusion(CurrentTime > 6.0 && CurrentTime < 18.0);
}
void AWheatherSystem::UpdateRain()
{
if (bRain){
if (RainTimelineCurve != NULL) {
float CurrentIntensity = RainTimelineCurve->GetFloatValue(CurrentTime);
if (CurrentIntensity <= 0.000001) {
RainComponent->Deactivate();
}
else {
RainComponent->Activate();
RainComponent->SetFloatParameter("SpawnRate", MaxRain * CurrentIntensity);
}
}
}
else {
RainComponent->Deactivate();
}
}
void AWheatherSystem::UpdateSnow()
{
if (bSnow){
if (SnowTimelineCurve != NULL) {
float CurrentIntensity = SnowTimelineCurve->GetFloatValue(CurrentTime);
if (CurrentIntensity <= 0.000001) {
SnowComponent->Deactivate();
}
else {
SnowComponent->Activate();
SnowComponent->SetFloatParameter("SpawnRate", MaxSnow * CurrentIntensity);
}
}
}
else {
SnowComponent->Deactivate();
}
}
void AWheatherSystem::UpdateFog()
{
if (Fog != NULL) {
UExponentialHeightFogComponent* FogComponent = Fog->GetComponent();
if (bFog) {
if (FogTimelineCurve != NULL) {
FogComponent->SetFogDensity(FogTimelineCurve->GetFloatValue(CurrentTime));
}
}
else {
FogComponent->SetFogDensity(0.005);
}
if (FogHeightFalloffCurve != NULL) {
FogComponent->SetFogHeightFalloff(FogHeightFalloffCurve->GetFloatValue(CurrentTime));
}
}
}
@@ -0,0 +1,28 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "MyActorComponent.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class NESIANDMYPROJECT_API UMyActorComponent : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UMyActorComponent();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
};
@@ -0,0 +1,110 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Engine/DirectionalLight.h"
#include "Components/DirectionalLightComponent.h"
#include "Engine/SkyLight.h"
#include "Components/SkyLightComponent.h"
#include "Engine/ExponentialHeightFog.h"
#include <Components/SkyAtmosphereComponent.h>
#include "Components/ExponentialHeightFogComponent.h"
#include <Curves/CurveVector.h>
#include "NiagaraComponent.h"
#include "Kismet/GameplayStatics.h"
#include "GameFramework/Pawn.h"
#include "Components/SceneComponent.h"
#include "WheatherSystem.generated.h"
/** Please add a class description */
UCLASS(Blueprintable, BlueprintType)
class NESIANDMYPROJECT_API AWheatherSystem : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AWheatherSystem();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
public:
/** Please add a variable description */
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "Components")
TObjectPtr<UNiagaraComponent> RainComponent;
/** Please add a variable description */
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "Components")
TObjectPtr<UNiagaraComponent> SnowComponent;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditInstanceOnly, Category = "Standard")
TObjectPtr<ADirectionalLight> Sun;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditInstanceOnly, Category = "Standard")
TObjectPtr<ADirectionalLight> Moon;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditInstanceOnly, Category = "Standard")
TObjectPtr<ASkyLight> SkyLight;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditInstanceOnly, Category = "Standard")
TObjectPtr<ASkyAtmosphere> SkyAtmosphere;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditInstanceOnly, Category = "Standard")
TObjectPtr<AExponentialHeightFog> Fog;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Standard")
double CurrentTime;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Standard")
double DayLengthMiutes;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Standard")
TObjectPtr<UCurveFloat> DayCurve;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Standard")
double OneHoure;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Standard")
TObjectPtr<UCurveVector> SunlightItensity;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Standard")
TObjectPtr<UCurveVector> SkylightIntensity;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Standard")
TObjectPtr<UCurveFloat> WeatherTypeCurve;
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Standard")
TObjectPtr<UCurveFloat> FogTimelineCurve;
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Standard")
TObjectPtr<UCurveFloat> RainTimelineCurve;
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Standard")
TObjectPtr<UCurveFloat> SnowTimelineCurve;
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Standard")
TObjectPtr<UCurveFloat> FogHeightFalloffCurve;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Standard")
bool bFog = false;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Standard")
bool bRain = false;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Standard")
bool bSnow = false;
private:
void UpdateWeather();
void UpdateRain();
void UpdateSnow();
void UpdateFog();
float MaxSnow = 0.0;
float MaxRain = 0.0;
};