// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "GameFramework/Actor.h" #include "Containers/Map.h" #include "HexVector.h" #include "AdventureMap.generated.h" class AHexTile; class AMapObject; class AAdventurePlayerController; UCLASS() class FRAY_API AAdventureMap : public AActor { GENERATED_BODY() public: // Sets default values for this actor's properties AAdventureMap(); UPROPERTY() UWorld* World; UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config") TSubclassOf BaseTileClass; UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config") int32 GridSize = 100; UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config") int32 TileSize = 100; UFUNCTION(BlueprintCallable, Category = "Generation") void MakeGrid(); UPROPERTY(BlueprintReadOnly, Category = "Generation") bool bHexGridReady; UPROPERTY(BlueprintReadOnly, Category = "Generation") TArray Grid; UFUNCTION(BlueprintCallable, Category = "Utility") int32 GridIndex(int32 q, int32 r); UFUNCTION(BlueprintCallable, Category = "Utility") AHexTile* RandomHex(); // Cardinal direction vectors UPROPERTY(BlueprintReadOnly, VisibleAnywhere) //diag FHexVector N = FHexVector(1, -2); UPROPERTY(BlueprintReadOnly, VisibleAnywhere) FHexVector NNE = FHexVector(1, -1); UPROPERTY(BlueprintReadOnly, VisibleAnywhere) //diag FHexVector ENE = FHexVector(2, -1); UPROPERTY(BlueprintReadOnly, VisibleAnywhere) FHexVector E = FHexVector(1, 0); UPROPERTY(BlueprintReadOnly, VisibleAnywhere) //diag FHexVector ESE = FHexVector(1, 1); UPROPERTY(BlueprintReadOnly, VisibleAnywhere) FHexVector SSE = FHexVector(0, 1); UPROPERTY(BlueprintReadOnly, VisibleAnywhere) //diag FHexVector S = FHexVector(-1, 2); UPROPERTY(BlueprintReadOnly, VisibleAnywhere) FHexVector SSW = FHexVector(-1, 1); UPROPERTY(BlueprintReadOnly, VisibleAnywhere) //diag FHexVector WSW = FHexVector(-2, 1); UPROPERTY(BlueprintReadOnly, VisibleAnywhere) FHexVector W = FHexVector(-1, 0); UPROPERTY(BlueprintReadOnly, VisibleAnywhere) //diag FHexVector WNW = FHexVector(-1, -1); UPROPERTY(BlueprintReadOnly, VisibleAnywhere) FHexVector NNW = FHexVector(0, -1); UPROPERTY(BlueprintReadOnly, VisibleAnywhere) TArray NeighborUnitVectors; UPROPERTY(BlueprintReadOnly, VisibleAnywhere) TArray DiagonalUnitVectors; UFUNCTION(BlueprintCallable, Category = "Runtime") TArray Neighbors(AHexTile* OfHex, bool bFreeOnly); UFUNCTION(BlueprintCallable, Category = "Runtime") TArray FreeDiagonals(AHexTile* OfHex); UFUNCTION(BlueprintCallable, Category = "Runtime") TSet BreadthFirstSearch(AHexTile* Start, int32 Radius); UFUNCTION(BlueprintCallable, Category = "Runtime") TArray FindPathAStar(AHexTile* Start, AHexTile* Goal, bool bDiags); // considering a MapObjectManager class or moving pathfinding & search to PlayerController UPROPERTY(BlueprintReadWrite, EditAnywhere) TMap MapObjects; UPROPERTY(BlueprintReadOnly) TMap MapObjectsByID; UPROPERTY(BlueprintReadWrite, VisibleAnywhere) int32 IncID = -1; protected: // Called when the game starts or when spawned virtual void BeginPlay() override; };