// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "ResComLevelPackLoader.h" #include "Engine/LevelStreaming.h" #include "Kismet/GameplayStatics.h" #include "ResComApartmentManager.h" #include "CoreMinimal.h" #include "GameFramework/Actor.h" #include "ResComFloorManager.generated.h" /*Single-cast delegate declaration. No parameters*/ DECLARE_DYNAMIC_DELEGATE(FOnPreview); DECLARE_DYNAMIC_DELEGATE(FOnShouldBeVisible); DECLARE_DYNAMIC_DELEGATE(FOnShouldBeLoaded); DECLARE_DYNAMIC_DELEGATE(FOnLoaded); UENUM(BlueprintType) enum Enum_LevelType { preview UMETA(DisplayName = "preview"), visible UMETA(DisplayName = "visible"), loaded UMETA(DisplayName = "loaded"), }; USTRUCT(BlueprintType) struct FFloorLevelStreaming { GENERATED_BODY() UPROPERTY(EditAnywhere, BlueprintReadWrite) ULevelStreaming* level = nullptr; UPROPERTY(EditAnywhere, BlueprintReadWrite) TEnumAsByte type; UPROPERTY(EditAnywhere, BlueprintReadWrite) int32 depth = 0; }; USTRUCT(BlueprintType) struct FFloorPack { GENERATED_BODY() UPROPERTY(EditAnywhere, BlueprintReadWrite) FApartmentLocation location; UPROPERTY(EditAnywhere, BlueprintReadWrite) TArray levels; UPROPERTY(EditAnywhere, BlueprintReadWrite) bool loaded = false; bool IsLoaded() { loaded = false; for (auto& level : levels) { if (!IsValid(level.level)) return loaded; if (!(level.level->IsLevelVisible())) return loaded; } loaded = true; return loaded; } }; UCLASS() class FORTIS_TAKTIKA_API AResComFloorManager : public AActor { GENERATED_BODY() protected: UPROPERTY(EditAnywhere, BlueprintReadWrite) TArray packs; private: UFUNCTION() void OnLevelPreview(); UFUNCTION() void OnLevelVisible(); UFUNCTION() void OnLevelLoaded(); bool GetPack(FApartmentLocation loc, FFloorPack* pack); public: // Sets default values for this actor's properties AResComFloorManager(); protected: // Called when the game starts or when spawned virtual void BeginPlay() override; UFUNCTION(BlueprintCallable, Category = "StreamingLevel") TArray GetStreamingLevels(const UObject* WorldContextObject); UPROPERTY() FOnPreview OnPreview; UPROPERTY() FOnShouldBeVisible OnShouldBeVisible; UPROPERTY() FOnShouldBeLoaded OnShouldBeLoaded; UPROPERTY() FOnLoaded OnLoaded; UFUNCTION(BlueprintCallable, Category = "Pack") void AddLevelToPack(FApartmentLocation loc, FFloorLevelStreaming level); UFUNCTION(BlueprintCallable, Category = "Pack") bool GetPack(FApartmentLocation loc, FFloorPack& pack) const; UFUNCTION(BlueprintCallable, Category = "Pack") void AddPack(const FFloorPack& pack); public: // Called every frame virtual void Tick(float DeltaTime) override; UFUNCTION(BlueprintCallable, Category="Pack") //bool LoadPack(FApartmentLocation loc, const FOnPreview& delegatePreview, const FOnShouldBeVisible& delegateShouldBeVisible, const FOnShouldBeLoaded& delegateShouldBeLoaded); bool LoadPack(FApartmentLocation loc, const FOnLoaded& delegateOnLoaded); UFUNCTION(BlueprintCallable, Category = "Pack") bool UnloadPack(FApartmentLocation loc, const FOnPreview& delegatePreview, const FOnShouldBeVisible& delegateShouldBeVisible, const FOnShouldBeLoaded& delegateShouldBeLoaded); };