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 "AdventureMap.generated.h"
|
|
|
|
|
|
|
|
class AHexTile;
|
2022-01-25 18:30:49 +01:00
|
|
|
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();
|
|
|
|
|
|
|
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
|
|
|
|
TSubclassOf<AHexTile> BaseTileClass;
|
|
|
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
|
|
|
|
TSubclassOf<ACharacter> BasePartyCharacterClass;
|
2022-01-12 18:22:16 +01:00
|
|
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
|
2022-01-11 11:07:17 +01:00
|
|
|
int32 GridSize = 100; // squared is the number of Tiles
|
2022-01-12 18:22:16 +01:00
|
|
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
|
2022-01-11 11:07:17 +01:00
|
|
|
int32 TileSize = 100;
|
2022-01-17 17:53:54 +01:00
|
|
|
UPROPERTY()
|
|
|
|
UWorld* World;
|
2022-01-11 18:16:26 +01:00
|
|
|
|
2022-01-12 18:22:16 +01:00
|
|
|
UFUNCTION(BlueprintCallable, Category = "Generation")
|
|
|
|
void MakeGrid();
|
2022-01-11 18:16:26 +01:00
|
|
|
UPROPERTY(BlueprintReadOnly, Category = "Generation")
|
|
|
|
bool bHexGridReady;
|
2022-01-25 18:30:49 +01:00
|
|
|
UPROPERTY(BlueprintReadOnly, Category = "Generation")
|
2022-01-11 11:07:17 +01:00
|
|
|
TArray<AHexTile*> Grid;
|
2022-01-12 18:22:16 +01:00
|
|
|
|
2022-01-25 18:30:49 +01:00
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
|
|
|
TMap<AHexTile*, AMapObject*> MapObjects;
|
|
|
|
UPROPERTY(BlueprintReadOnly)
|
|
|
|
TMap<int32, AMapObject*> MapObjectsByID;
|
|
|
|
int32 IncID = -1;
|
|
|
|
|
2022-01-13 16:54:37 +01:00
|
|
|
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
2022-01-11 11:07:17 +01:00
|
|
|
int32 GridIndex(int32 q, int32 r);
|
2022-01-13 16:54:37 +01:00
|
|
|
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
2022-01-12 18:22:16 +01:00
|
|
|
AHexTile* RandomHex();
|
2022-01-13 16:54:37 +01:00
|
|
|
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
|
|
|
TArray<AHexTile*> Neighbors(AHexTile* OfHex);
|
2022-01-25 18:30:49 +01:00
|
|
|
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
|
|
|
TArray<AHexTile*> BreadthFirstSearch(AHexTile* Start, int32 Radius);
|
2022-01-16 18:33:43 +01:00
|
|
|
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
2022-01-18 20:09:37 +01:00
|
|
|
TArray<AHexTile*> AStar(AHexTile* Start, AHexTile* Goal);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
|
|
|
TArray<AHexTile*> LinkPath(AHexTile* Start, AHexTile* Goal);
|
|
|
|
|
2022-01-25 18:30:49 +01:00
|
|
|
// Cardinal direction vectors
|
|
|
|
TPair<int32, int32> N = TPair<int32,int32>(1, -2); //diag
|
|
|
|
TPair<int32, int32> NE = TPair<int32,int32>(1, -1);
|
|
|
|
TPair<int32, int32> ENE = TPair<int32,int32>(2, -1); //diag
|
|
|
|
TPair<int32, int32> E = TPair<int32,int32>(1, 0);
|
|
|
|
TPair<int32, int32> ESE = TPair<int32,int32>(1, 1); //diag
|
|
|
|
TPair<int32, int32> SE = TPair<int32,int32>(0, 1);
|
|
|
|
TPair<int32, int32> S = TPair<int32,int32>(-1, 2); //diag
|
|
|
|
TPair<int32, int32> SW = TPair<int32,int32>(-1, 1);
|
|
|
|
TPair<int32, int32> WSW = TPair<int32,int32>(-2, 1); //diag
|
|
|
|
TPair<int32, int32> W = TPair<int32,int32>(-1, 0);
|
|
|
|
TPair<int32, int32> WNW = TPair<int32,int32>(-1, -1); //diag
|
|
|
|
TPair<int32, int32> NW = TPair<int32,int32>(0, -1);
|
2022-01-11 11:07:17 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// Called when the game starts or when spawned
|
|
|
|
virtual void BeginPlay() override;
|
2022-01-16 18:33:43 +01:00
|
|
|
};
|