diff --git a/AdventureCameraPawn.cpp b/AdventureCameraPawn.cpp index 2ac6bab..6f7502e 100644 --- a/AdventureCameraPawn.cpp +++ b/AdventureCameraPawn.cpp @@ -39,7 +39,7 @@ void AAdventureCameraPawn::BeginPlay() // The Viewport properties are inaccurate right after BeginPlay, so we need to wait a short time before saving them here. FTimerHandle UnusedHandle; GetWorldTimerManager().SetTimer( - UnusedHandle, this, &AAdventureCameraPawn::GetTheDamnViewport, 1.5, false); + UnusedHandle, this, &AAdventureCameraPawn::GetTheDamnViewport, 1, false); } void AAdventureCameraPawn::GetTheDamnViewport() diff --git a/AdventureCameraPawn.h b/AdventureCameraPawn.h index d98b21d..71bfae4 100644 --- a/AdventureCameraPawn.h +++ b/AdventureCameraPawn.h @@ -47,6 +47,7 @@ public: UPROPERTY(BlueprintReadWrite, Category = "Runtime") class AHexTile* SelectedHex; + protected: // Called when the game starts or when spawned virtual void BeginPlay() override; diff --git a/AdventureMap.cpp b/AdventureMap.cpp index 9f5daf8..5da4c30 100644 --- a/AdventureMap.cpp +++ b/AdventureMap.cpp @@ -79,10 +79,12 @@ void AAdventureMap::MakeGrid() { tile->Index = GridIndex(tile->Q, tile->R); } + + bHexGridReady = true; } AHexTile* AAdventureMap::RandomHex() { - int32 SpawnHex = GridIndex(FMath::RandRange(0, GridSize), FMath::RandRange(0, GridSize)); - return Grid[SpawnHex]; + int32 RandHex = GridIndex(FMath::RandRange(0, GridSize), FMath::RandRange(0, GridSize)); + return Grid[RandHex]; } \ No newline at end of file diff --git a/AdventureMap.h b/AdventureMap.h index 31333b4..a06fc7e 100644 --- a/AdventureMap.h +++ b/AdventureMap.h @@ -26,11 +26,16 @@ public: int32 GridSize = 100; // squared is the number of Tiles UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Config") int32 TileSize = 100; - UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, Category = "MapData") + + UPROPERTY(BlueprintReadOnly, Category = "Generation") + bool bHexGridReady; + + UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, Category = "Runtime") TArray Grid; UFUNCTION(BlueprintCallable) int32 GridIndex(int32 q, int32 r); + // Player spawn section UPROPERTY(VisibleAnywhere, BlueprintReadWrite) APawn* CameraPawn;