unreal/AdventureMap.h

99 lines
3.3 KiB
C
Raw Normal View History

2022-01-11 11:07:17 +01:00
// 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"
2022-01-28 21:58:04 +01:00
#include "HexVector.h"
2022-01-11 11:07:17 +01:00
#include "AdventureMap.generated.h"
class AHexTile;
class AMapObject;
2022-01-26 16:48:58 +01:00
class AAdventurePlayerController;
2022-01-11 11:07:17 +01:00
UCLASS()
class FRAY_API AAdventureMap : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AAdventureMap();
2022-01-28 21:58:04 +01:00
UPROPERTY()
UWorld* World;
2022-01-11 11:07:17 +01:00
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
TSubclassOf<AHexTile> BaseTileClass;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
2022-01-29 20:54:35 +01:00
int32 GridSize = 100;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
2022-01-11 11:07:17 +01:00
int32 TileSize = 100;
UFUNCTION(BlueprintCallable, Category = "Generation")
void MakeGrid();
UPROPERTY(BlueprintReadOnly, Category = "Generation")
bool bHexGridReady;
UPROPERTY(BlueprintReadOnly, Category = "Generation")
2022-01-11 11:07:17 +01:00
TArray<AHexTile*> Grid;
2022-01-28 21:58:04 +01:00
UFUNCTION(BlueprintCallable, Category = "Utility")
2022-01-11 11:07:17 +01:00
int32 GridIndex(int32 q, int32 r);
2022-01-28 21:58:04 +01:00
UFUNCTION(BlueprintCallable, Category = "Utility")
AHexTile* RandomHex();
2022-01-28 21:58:04 +01:00
// 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<FHexVector> NeighborUnitVectors;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
TArray<FHexVector> DiagonalUnitVectors;
UFUNCTION(BlueprintCallable, Category = "Runtime")
2022-01-28 21:58:04 +01:00
TArray<AHexTile*> Neighbors(AHexTile* OfHex, bool bFreeOnly);
UFUNCTION(BlueprintCallable, Category = "Runtime")
2022-01-29 20:54:35 +01:00
TArray<AHexTile*> FreeDiagonals(AHexTile* OfHex);
UFUNCTION(BlueprintCallable, Category = "Runtime")
2022-01-28 21:58:04 +01:00
TSet<AHexTile*> BreadthFirstSearch(AHexTile* Start, int32 Radius);
UFUNCTION(BlueprintCallable, Category = "Runtime")
2022-01-28 21:58:04 +01:00
TArray<AHexTile*> FindPathAStar(AHexTile* Start, AHexTile* Goal, bool bDiags);
2022-01-29 20:54:35 +01:00
// considering a MapObjectManager class or moving pathfinding & search to PlayerController
2022-01-28 21:58:04 +01:00
UPROPERTY(BlueprintReadWrite, EditAnywhere)
TMap<AHexTile*, AMapObject*> MapObjects;
UPROPERTY(BlueprintReadOnly)
TMap<int32, AMapObject*> MapObjectsByID;
UPROPERTY(BlueprintReadWrite, VisibleAnywhere)
int32 IncID = -1;
2022-01-11 11:07:17 +01:00
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
};