Created
September 19, 2016 04:42
-
-
Save coderespawn/6138dd751276701cdbfb4216c1a8cf19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename T> | |
T* GetAsset(const FName& Path) { | |
UObject* Obj = StaticLoadObject(UDungeonThemeAsset::StaticClass(), nullptr, *Path.ToString()); | |
return Cast<T>(Obj); | |
} | |
void ADA413XGameMode::BuildDynamicDungeon() { | |
// Create a new dungeon actor | |
Dungeon = GetWorld()->SpawnActor<ADungeon>(ADungeon::StaticClass()); | |
// Grab a reference to the theme asset and register it with the dungeon actor | |
UDungeonThemeAsset* MyTheme = GetAsset<UDungeonThemeAsset>("/Game/DA_Candy/Themes/D_Candy_v2"); // Set your theme path here | |
Dungeon->Themes.Add(MyTheme); | |
// Set the builder type | |
Dungeon->BuilderClass = UGridDungeonBuilder::StaticClass(); | |
Dungeon->CreateBuilderInstance(); | |
// Set the dungeon configuration | |
UGridDungeonConfig* GridConfig = Cast<UGridDungeonConfig>(Dungeon->GetConfig()); | |
if (GridConfig) { | |
GridConfig->Seed = FMath::Rand(); // Randomize our dungeon | |
// Set other grid config here | |
} | |
Dungeon->BuildDungeon(); | |
} | |
void ADA413XGameMode::StartPlay() { | |
Super::StartPlay(); | |
BuildDynamicDungeon(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment