// All rights reserved. #include "SpawnManager.h" // Sets default values ASpawnManager::ASpawnManager() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = false; } void ASpawnManager::GenerateBoard(const TSubclassOf Template) { FVector ActorLocation = this->GetActorLocation(); CurrentLevel = GetWorld()->SpawnActor(Template, this->GetActorTransform()); UPaperTileMapComponent* Tilemap = CurrentLevel->Template; TArray> Classes; for (int32 i = 0; i < BlocksY; i++) { for (int32 o = 0; o < BlocksX; o++) { // Make transform FTransform SpawnTransform; SpawnTransform.SetLocation(FVector((ActorLocation.X - (Distance * BlocksX / 2) + (o * Distance)), (ActorLocation.Y - (Distance * (BlocksY / 2)) + (i * Distance)), ActorLocation.Z)); // Spawn block int32 TileId = Tilemap->GetTile(i, o, 0).GetTileIndex(); TSubclassOf TileClass = *BlockTemplates.Find(TileId); ABuildingBlock* ThisBlock = GetWorld()->SpawnActor(TileClass, SpawnTransform); ThisBlock->Index = (10 * i) + o; if (ThisBlock->HasVariants) { ThisBlock->Variant = FMath::RandRange(1, MaxVariants); } ThisBlock->FadeIn(); } } }