unreal/AdventureMap.h

77 lines
2.7 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 "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();
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
TSubclassOf<AHexTile> BaseTileClass;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
TSubclassOf<ACharacter> BasePartyCharacterClass;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
2022-01-11 11:07:17 +01:00
int32 GridSize = 100; // squared is the number of Tiles
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
2022-01-11 11:07:17 +01:00
int32 TileSize = 100;
UPROPERTY()
UWorld* World;
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;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
TMap<AHexTile*, AMapObject*> MapObjects;
UPROPERTY(BlueprintReadOnly)
TMap<int32, AMapObject*> MapObjectsByID;
int32 IncID = -1;
UFUNCTION(BlueprintCallable, Category = "Runtime")
2022-01-11 11:07:17 +01:00
int32 GridIndex(int32 q, int32 r);
UFUNCTION(BlueprintCallable, Category = "Runtime")
AHexTile* RandomHex();
UFUNCTION(BlueprintCallable, Category = "Runtime")
TArray<AHexTile*> Neighbors(AHexTile* OfHex);
UFUNCTION(BlueprintCallable, Category = "Runtime")
TArray<AHexTile*> BreadthFirstSearch(AHexTile* Start, int32 Radius);
UFUNCTION(BlueprintCallable, Category = "Runtime")
TArray<AHexTile*> AStar(AHexTile* Start, AHexTile* Goal);
UFUNCTION(BlueprintCallable, Category = "Runtime")
TArray<AHexTile*> LinkPath(AHexTile* Start, AHexTile* Goal);
// 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;
};