5#include "CoreMinimal.h"
8#include "DungeonData.generated.h"
15DECLARE_CYCLE_STAT(TEXT(
"Procedural Dungeons (All Functions)"), STAT_ProceduralDungeons, STATGROUP_ProceduralDungeons);
16DECLARE_CYCLE_STAT(TEXT(
"Builder (All Functions)"), STAT_ProceduralDungeons_Builder, STATGROUP_ProceduralDungeons);
17DECLARE_CYCLE_STAT(TEXT(
"Rooms (All Functions)"), STAT_ProceduralDungeons_Rooms, STATGROUP_ProceduralDungeons);
18DECLARE_CYCLE_STAT(TEXT(
"BP Library (All Functions)"), STAT_ProceduralDungeons_BPLib, STATGROUP_ProceduralDungeons);
32 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=
"Special Room")
33 TSubclassOf<AActor> Class =
nullptr;
34 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Special Room")
35 int32 NumberToSpawn = 1;
42 : Class(InClass), NumberToSpawn(InNumberToSpawn) {}
46 if(
Other.Class == Class){
return true;}
62 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=
"General")
63 TSubclassOf<AActor> Type =
nullptr;
65 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="
General")
71 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="
General")
72 bool bDisable = false;
74 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="
General")
75 bool bSpawnLimit = false;
77 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="
General", meta=(EditCondition=bSpawnLimit))
78 int32 NumberToSpawn = -1;
79 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Spawn")
80 int32 NumberSpawned = 0;
81 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="
General")
82 bool bRequired = false;
85 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Calculated")
86 bool bCalculatedValues = false;
88 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Calculated")
89 int32 CalculatedExits = 0;
90 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Calculated")
92 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Calculated")
93 FBox CalculatedRoomBounds = FBox(FVector::ZeroVector, FVector::ZeroVector);
95 bool GetHasSpawnedLimit()
const
99 return NumberSpawned >= NumberToSpawn;
107 return CalculatedExits;
129 if(Type ==
nullptr){UE_LOG(LogDungeonData,
Error, TEXT(
"FDungeonSpawnRoom::GetWeightedTypes No Valid Type"));
return WeightedTypes;}
130 WeightedTypes.Empty();
131 for(int32 i = 0; i < TypeWeight; ++i)
133 WeightedTypes.Add(Type);
135 return WeightedTypes;
144 if(
Other.Type == Type){
return true;}
149 if(
Other.Type != Type){
return true;}
158 if(Type->ImplementsInterface(UDungeonRoom::StaticClass()) ==
false)
160 UE_LOG(LogDungeonData,
Error, TEXT(
"FDungeonSpawnRoom::IsValid Please Remove RoomType %s Doesn't Implement Interface"), *Type->GetName());
167USTRUCT(BlueprintType)
177 return GetRoomsWithNumOfExits(0);
187 TArray<FDungeonSpawnRoom> SelectedRooms;
188 for(
auto& Room : Rooms)
190 if(Room.Type == ActorClass)
192 SelectedRooms.Add(Room);
195 return SelectedRooms;
203 return GetRoomsWithNumOfExits(1);
208 return GetRoomsWithNumOfExits(0, 0);
214 TArray<FDungeonSpawnRoom> SelectedRooms;
215 for(int32 i = 0; i < Rooms.Num(); ++i)
217 if(Rooms[i].IsValid() ==
false){UE_LOG(LogDungeonData,
Warning, TEXT(
"FDungeonSpawns::GetRoomsWithNumOfExits Room %i Not Valid"), i);
continue;}
219 if(Rooms[i].GetExits() >= MinExits)
221 SelectedRooms.AddUnique(Rooms[i]);
224 return SelectedRooms;
228 TArray<FDungeonSpawnRoom> SelectedRooms;
229 for(int32 i = 0; i < Rooms.Num(); ++i)
231 if(Rooms[i].IsValid() ==
false){UE_LOG(LogDungeonData,
Warning, TEXT(
"FDungeonSpawns::GetRoomsWithNumOfExits Room %i Not Valid"), i);
continue;}
233 if(Rooms[i].GetExits() >= MinExits && Rooms[i].GetExits() <= MaxExits)
236 SelectedRooms.AddUnique(Rooms[i]);
239 return SelectedRooms;
244 for(
auto& Room : Rooms)
246 if(Room.Type == ActorClass)
255 for(
auto& Room : Rooms)
257 if(Room.Type == ActorClass)
259 return Room.CalculatedType;
262 return EDungeonRoomType::Hallway;
268 return Rooms.IsEmpty();
272 return Rooms.IsValidIndex(Index);
285 Rooms = InitialRooms;
290 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=
"General")
DECLARE_CYCLE_STAT(TEXT("Procedural Dungeons (All Functions)"), STAT_ProceduralDungeons, STATGROUP_ProceduralDungeons)
DECLARE_STATS_GROUP(TEXT("Procedural Dungeons"), STATGROUP_ProceduralDungeons, STATCAT_Advanced)
DECLARE_LOG_CATEGORY_CLASS(LogDungeonData, Display, All)
DECLARE_DWORD_COUNTER_STAT(TEXT("Dungeon Rooms"), STAT_RoomsCreated, STATGROUP_ProceduralDungeons)
EDungeonRoomType
Definition DungeonEnums.h:11
Definition DungeonData.h:300
Definition DungeonRoom.h:21
Definition DungeonData.h:58
bool IsValid() const
Definition DungeonData.h:152
bool operator==(const FDungeonSpawnRoom &Other) const
Definition DungeonData.h:142
bool operator!=(const FDungeonSpawnRoom &Other) const
Definition DungeonData.h:147
int32 GetExits() const
Definition DungeonData.h:105
FDungeonSpawnRoom()
Definition DungeonData.h:115
TArray< TSubclassOf< AActor > > WeightedTypes
Definition DungeonData.h:139
TArray< TSubclassOf< AActor > > & GetWeightedTypes()
Definition DungeonData.h:127
Definition DungeonData.h:169
bool IsEmpty() const
Definition DungeonData.h:266
bool IsValidIndex(const int32 Index) const
Definition DungeonData.h:270
TArray< FDungeonSpawnRoom > & GetRooms()
Definition DungeonData.h:180
FDungeonSpawns()
Definition DungeonData.h:279
TArray< FDungeonSpawnRoom > GetRoomsWithNumOfExits(const int32 MinExits, const int32 MaxExits) const
Definition DungeonData.h:226
EDungeonRoomType FindType(const TSubclassOf< AActor > ActorClass) const
Definition DungeonData.h:253
int32 Num() const
Definition DungeonData.h:274
TArray< FDungeonSpawnRoom > GetRoomsWithExits() const
Definition DungeonData.h:201
FDungeonSpawns(const TArray< FDungeonSpawnRoom > &InitialRooms)
Definition DungeonData.h:283
TArray< FDungeonSpawnRoom > GetRoomsWithNoExits() const
Definition DungeonData.h:206
TArray< FDungeonSpawnRoom > GetRoomsOfType(const TSubclassOf< AActor > ActorClass)
Definition DungeonData.h:185
FDungeonSpawnRoom * Find(const TSubclassOf< AActor > ActorClass)
Definition DungeonData.h:242
TArray< FDungeonSpawnRoom > GetRoomsWithNumOfExits(const int32 MinExits) const
Definition DungeonData.h:212
Definition DungeonData.h:29
FDungeonSpecialItem(const TSubclassOf< AActor > InClass, const int32 InNumberToSpawn)
Definition DungeonData.h:41
bool operator==(const FDungeonSpecialItem &Other) const
Definition DungeonData.h:44