48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "GameFramework/Actor.h"
|
|
#include "Components/SphereComponent.h"
|
|
#include "LevelStreamingActor.generated.h"
|
|
|
|
class ACharacter;
|
|
|
|
UCLASS(BlueprintType, meta = (BlueprintSpawnableComponent))
|
|
class PROJECTELERI_API ULevelStreamingComponent : public USphereComponent {
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
ULevelStreamingComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) {
|
|
LineThickness = 250.f;
|
|
}
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
TSoftObjectPtr<UWorld> WorldRef;
|
|
};
|
|
|
|
UCLASS()
|
|
class PROJECTELERI_API ALevelStreamingActor : public AActor
|
|
{
|
|
GENERATED_BODY()
|
|
public:
|
|
ALevelStreamingActor();
|
|
void BeginPlay() override;
|
|
void Tick(float DeltaSeconds) override;
|
|
|
|
protected:
|
|
UPROPERTY()
|
|
TObjectPtr<ACharacter> PlayerPtr;
|
|
|
|
UPROPERTY()
|
|
TArray<ULevelStreamingComponent*> LevelStreamingComps;
|
|
UPROPERTY()
|
|
TArray<bool> LevelStreamed;
|
|
|
|
bool InsideLevelZone(ULevelStreamingComponent* Comp) const;
|
|
|
|
void LoadLevel(TSoftObjectPtr<UWorld> World, int32 Index);
|
|
void UnloadLevel(TSoftObjectPtr<UWorld> World, int32 Index);
|
|
};
|