2024-04-12 23:31:49 -07:00
|
|
|
|
#include "GasaLevelScriptActor.h"
|
|
|
|
|
|
|
|
|
|
#include "GasaDevOptions.h"
|
2024-04-22 22:10:02 -07:00
|
|
|
|
#include "GasaGameInstance.h"
|
|
|
|
|
#include "Engine/PostProcessVolume.h"
|
2024-04-12 23:31:49 -07:00
|
|
|
|
#include "Kismet/GameplayStatics.h"
|
2024-04-22 22:10:02 -07:00
|
|
|
|
#include "Materials/MaterialInstance.h"
|
|
|
|
|
#include "Materials/MaterialInstanceDynamic.h"
|
2024-04-23 15:54:17 -07:00
|
|
|
|
#include "Networking/GasaNetLibrary_Inlines.h"
|
2024-04-22 22:10:02 -07:00
|
|
|
|
using namespace Gasa;
|
2024-04-12 23:31:49 -07:00
|
|
|
|
|
2024-04-22 22:10:02 -07:00
|
|
|
|
#pragma region Game Framework
|
|
|
|
|
AGasaLevelScriptActor::AGasaLevelScriptActor()
|
|
|
|
|
{
|
|
|
|
|
// Replication
|
|
|
|
|
|
|
|
|
|
bReplicates = true;
|
|
|
|
|
bNetLoadOnClient = true;
|
|
|
|
|
NetDormancy = DORM_Awake;
|
|
|
|
|
NetCullDistanceSquared = NetCullDist_Default;
|
|
|
|
|
NetUpdateFrequency = 10.0f;
|
|
|
|
|
MinNetUpdateFrequency = 1.0f;
|
|
|
|
|
NetPriority = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AGasaLevelScriptActor::OnGameFrameworkInitialized()
|
|
|
|
|
{
|
|
|
|
|
NetLog("Received game framework initialization.");
|
|
|
|
|
BP_OnGameFrameworkInitialized();
|
|
|
|
|
}
|
|
|
|
|
#pragma endregion Game Framework
|
|
|
|
|
|
|
|
|
|
#pragma region Actor
|
2024-04-12 23:31:49 -07:00
|
|
|
|
void AGasaLevelScriptActor::BeginPlay()
|
|
|
|
|
{
|
|
|
|
|
Super::BeginPlay();
|
2024-04-22 22:10:02 -07:00
|
|
|
|
NetLog("BeginPlay");
|
2024-04-12 23:31:49 -07:00
|
|
|
|
|
2024-04-13 02:32:52 -07:00
|
|
|
|
using namespace Gasa;
|
|
|
|
|
|
2024-04-12 23:31:49 -07:00
|
|
|
|
TArray<AActor*> TaggedActors;
|
2024-04-13 02:32:52 -07:00
|
|
|
|
UGameplayStatics::GetAllActorsWithTag(GetWorld(), GetDevOptions()->Tag_GlobalPPV, TaggedActors);
|
2024-04-12 23:31:49 -07:00
|
|
|
|
for (AActor* Actor : TaggedActors)
|
|
|
|
|
{
|
|
|
|
|
GlobalPPV = Cast<APostProcessVolume>(Actor);
|
|
|
|
|
|
2024-04-13 02:32:52 -07:00
|
|
|
|
APostProcessVolume* PPV = GetLevelActor(this)->GlobalPPV;
|
2024-04-12 23:31:49 -07:00
|
|
|
|
UMaterialInstance* Blendable = Cast<UMaterialInstance>(PPV->Settings.WeightedBlendables.Array[0].Object);
|
|
|
|
|
UMaterialInstanceDynamic* MID = UMaterialInstanceDynamic::Create(Blendable, this);
|
|
|
|
|
PPV->Settings.WeightedBlendables.Array[0].Object = MID;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2024-04-22 22:10:02 -07:00
|
|
|
|
|
|
|
|
|
UGasaGameInstance* GI = GetGameInstance<UGasaGameInstance>();
|
|
|
|
|
if(GI)
|
|
|
|
|
GI->Event_OnGameFrameworkInitialized.AddUniqueDynamic(this, & ThisClass::OnGameFrameworkInitialized);
|
|
|
|
|
|
2024-04-23 15:54:17 -07:00
|
|
|
|
if (!bOverrideGameFrameworkReady)
|
2024-04-22 22:10:02 -07:00
|
|
|
|
GI->NotifyGameFrameworkClassReady(EGameFrameworkClassFlag::Levels);
|
2024-04-12 23:31:49 -07:00
|
|
|
|
}
|
2024-04-22 22:10:02 -07:00
|
|
|
|
#pragma endregion Actor
|