2022-02-03 01:11:06 +01:00
|
|
|
#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;
|
|
|
|
};
|
|
|
|
|
|
|
|
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; }
|
2022-06-01 20:25:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE uint32 GetTypeHash(const FHexVector& Thing)
|
|
|
|
{
|
|
|
|
uint32 Hash = FCrc::MemCrc32(&Thing, sizeof(FHexVector));
|
|
|
|
return Hash;
|
2022-02-03 01:11:06 +01:00
|
|
|
}
|