Is Valid Dungeon
This function determines if the dungeon corresponds to your needs.
Check all requirements you want here and return true if the dungeon meets all of them.
If you return false, the generator will wipes the generated dungeon and begins a new generation starting at the Generation Init
event.
In output, you have to return true to validate the dungeon, or false to regenerate.
Here an example where we check if the dungeon has an exit:
- Blueprint
- C++
MyDungeonGenerator.h
UCLASS()
class AMyDungeonGenerator : public ADungeonGenerator
{
GENERATED_BODY()
public:
// ...
virtual bool IsValidDungeon_Implementation() override;
// This variable is just for example purpose
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "My Dungeon")
URoomData* EndingRoom {nullptr};
// ...
}
MyDungeonGenerator.cpp
bool AMyDungeonGenerator::IsValidDungeon_Implementation()
{
return GetRooms()->HasAlreadyRoomData(EndingRoom);
}