unreal/HexVector.h

56 lines
1.5 KiB
C
Raw Normal View History

#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; }
}
FORCEINLINE uint32 GetTypeHash(const FHexVector& Thing)
{
uint32 Hash = FCrc::MemCrc32(&Thing, sizeof(FHexVector));
return Hash;
}