2022-06-01 20:25:33 +02:00
|
|
|
#include "MovementArrow.h"
|
|
|
|
#include "AdventureMap.h"
|
|
|
|
|
|
|
|
// Sets default values
|
|
|
|
AMovementArrow::AMovementArrow()
|
|
|
|
{
|
|
|
|
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
|
|
|
PrimaryActorTick.bCanEverTick = true;
|
|
|
|
SceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("Scene"));
|
|
|
|
RootComponent = SceneComponent;
|
|
|
|
MeshStraight = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Straight"));
|
|
|
|
MeshRight = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Right"));
|
|
|
|
MeshRightSharp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("RightSharp"));
|
|
|
|
MeshLeftSharp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("LeftSharp"));
|
|
|
|
MeshLeft = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Left"));
|
|
|
|
MeshVariants.Add(MeshStraight);
|
|
|
|
MeshVariants.Add(MeshRight);
|
|
|
|
MeshVariants.Add(MeshRightSharp);
|
|
|
|
MeshVariants.Add(MeshLeftSharp);
|
|
|
|
MeshVariants.Add(MeshLeft);
|
|
|
|
|
|
|
|
for (UStaticMeshComponent* Mesh : MeshVariants) {
|
|
|
|
Mesh->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepWorldTransform);
|
|
|
|
Mesh->ToggleVisibility();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-05 22:44:34 +02:00
|
|
|
void AMovementArrow::SetVariant(FHexVector InVector, FHexVector OutVector) {
|
|
|
|
int32 InVectorIndex = MapRef->UnitVectors.Find(InVector);
|
|
|
|
int32 OutVectorIndex = MapRef->UnitVectors.Find(OutVector);
|
|
|
|
int32 VariantIndex;
|
2022-06-08 11:39:41 +02:00
|
|
|
if (InVectorIndex == 0) {
|
2022-06-05 22:44:34 +02:00
|
|
|
if (OutVectorIndex == 0) { VariantIndex = 0; }
|
|
|
|
if (OutVectorIndex == 1) { VariantIndex = 1; }
|
|
|
|
if (OutVectorIndex == 2) { VariantIndex = 2; }
|
|
|
|
if (OutVectorIndex == 4) { VariantIndex = 3; }
|
|
|
|
if (OutVectorIndex == 5) { VariantIndex = 4; }
|
|
|
|
}
|
2022-06-08 11:39:41 +02:00
|
|
|
if (InVectorIndex == 1) {
|
2022-06-05 22:44:34 +02:00
|
|
|
if (OutVectorIndex == 0) { VariantIndex = 4; }
|
|
|
|
if (OutVectorIndex == 1) { VariantIndex = 0; }
|
|
|
|
if (OutVectorIndex == 2) { VariantIndex = 1; }
|
|
|
|
if (OutVectorIndex == 3) { VariantIndex = 2; }
|
|
|
|
if (OutVectorIndex == 5) { VariantIndex = 3; }
|
|
|
|
}
|
2022-06-08 11:39:41 +02:00
|
|
|
if (InVectorIndex == 2) {
|
2022-06-05 22:44:34 +02:00
|
|
|
if (OutVectorIndex == 0) { VariantIndex = 3; }
|
|
|
|
if (OutVectorIndex == 1) { VariantIndex = 4; }
|
|
|
|
if (OutVectorIndex == 2) { VariantIndex = 0; }
|
|
|
|
if (OutVectorIndex == 3) { VariantIndex = 1; }
|
|
|
|
if (OutVectorIndex == 4) { VariantIndex = 2; }
|
|
|
|
}
|
2022-06-08 11:39:41 +02:00
|
|
|
if (InVectorIndex == 3) {
|
2022-06-05 22:44:34 +02:00
|
|
|
if (OutVectorIndex == 1) { VariantIndex = 3; }
|
|
|
|
if (OutVectorIndex == 2) { VariantIndex = 4; }
|
|
|
|
if (OutVectorIndex == 3) { VariantIndex = 0; }
|
|
|
|
if (OutVectorIndex == 4) { VariantIndex = 1; }
|
|
|
|
if (OutVectorIndex == 5) { VariantIndex = 2; }
|
|
|
|
}
|
2022-06-08 11:39:41 +02:00
|
|
|
if (InVectorIndex == 4) {
|
2022-06-05 22:44:34 +02:00
|
|
|
if (OutVectorIndex == 0) { VariantIndex = 2; }
|
|
|
|
if (OutVectorIndex == 2) { VariantIndex = 3; }
|
|
|
|
if (OutVectorIndex == 3) { VariantIndex = 4; }
|
|
|
|
if (OutVectorIndex == 4) { VariantIndex = 0; }
|
|
|
|
if (OutVectorIndex == 5) { VariantIndex = 1; }
|
|
|
|
}
|
2022-06-08 11:39:41 +02:00
|
|
|
if (InVectorIndex == 5) {
|
2022-06-05 22:44:34 +02:00
|
|
|
if (OutVectorIndex == 0) { VariantIndex = 1; }
|
|
|
|
if (OutVectorIndex == 1) { VariantIndex = 2; }
|
|
|
|
if (OutVectorIndex == 3) { VariantIndex = 3; }
|
|
|
|
if (OutVectorIndex == 4) { VariantIndex = 4; }
|
|
|
|
if (OutVectorIndex == 5) { VariantIndex = 0; }
|
|
|
|
}
|
|
|
|
SceneComponent->SetRelativeRotation(FRotator(0, InVectorIndex * 60.f, 0));
|
2022-06-01 20:25:33 +02:00
|
|
|
MeshVariants[VariantIndex]->ToggleVisibility();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called when the game starts or when spawned
|
|
|
|
void AMovementArrow::BeginPlay()
|
|
|
|
{
|
|
|
|
Super::BeginPlay();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called every frame
|
|
|
|
void AMovementArrow::Tick(float DeltaTime)
|
|
|
|
{
|
|
|
|
Super::Tick(DeltaTime);
|
|
|
|
|
|
|
|
}
|