58 lines
1.4 KiB
C
58 lines
1.4 KiB
C
#pragma once
|
|
|
|
#include "HexTile.h"
|
|
#include "HexVector.generated.h"
|
|
|
|
USTRUCT(BlueprintType)
|
|
struct FHexVector
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
FORCEINLINE FHexVector();
|
|
FORCEINLINE explicit FHexVector(int32 InQ, int32 InR);
|
|
FORCEINLINE explicit FHexVector(int32 InQ, int32 InR, bool bInDiag, bool bInUnit);
|
|
FORCEINLINE explicit FHexVector(AHexTile* InHex);
|
|
FORCEINLINE explicit FHexVector(AHexTile* InHexA, AHexTile* InHexB);
|
|
|
|
|
|
UPROPERTY(BlueprintReadWrite)
|
|
int32 Q;
|
|
|
|
UPROPERTY(BlueprintReadWrite)
|
|
int32 R;
|
|
|
|
UPROPERTY(BlueprintReadWrite)
|
|
int32 S;
|
|
|
|
UPROPERTY(BlueprintReadWrite)
|
|
bool bIsDiagonal;
|
|
|
|
UPROPERTY(BlueprintReadWrite)
|
|
bool bUnit;
|
|
|
|
TArray<FHexVector> Related;
|
|
};
|
|
|
|
FORCEINLINE FHexVector::FHexVector()
|
|
{}
|
|
FORCEINLINE FHexVector::FHexVector(int32 InQ, int32 InR)
|
|
: Q(InQ), R(InR) {}
|
|
FORCEINLINE FHexVector::FHexVector(int32 InQ, int32 InR, bool InIsDiag, bool InIsUnit)
|
|
: Q(InQ), R(InR), bIsDiagonal(InIsDiag), bUnit(InIsUnit) {}
|
|
FORCEINLINE FHexVector::FHexVector(AHexTile* InHex)
|
|
: Q(InHex->Q), R(InHex->R) {}
|
|
FORCEINLINE FHexVector::FHexVector(AHexTile* InHexA, AHexTile* InHexB)
|
|
: Q(InHexA->Q - InHexB->Q), R(InHexA->R - InHexB->R) {}
|
|
|
|
|
|
FORCEINLINE bool operator==(const FHexVector& A, const FHexVector& B)
|
|
{
|
|
if (A.Q == B.Q && A.R == B.R) { return true; }
|
|
else { return false; }
|
|
}
|
|
|
|
FORCEINLINE bool operator!=(const FHexVector& A, const FHexVector& B)
|
|
{
|
|
if (A.Q == B.Q && A.R == B.R) { return false; }
|
|
else { return true; }
|
|
} |