Don't write clever code
This commit is contained in:
+53
-19
@@ -25,28 +25,62 @@ AMovementArrow::AMovementArrow()
|
||||
}
|
||||
}
|
||||
|
||||
void AMovementArrow::SetVariant(FHexVector InVector, FHexVector OutVector) {
|
||||
|
||||
void AMovementArrow::SetVariant(FHexVector InVec, FHexVector OutVec) {
|
||||
int32 InVectorIndex = MapRef->UnitVectors.Find(InVector);
|
||||
int32 OutVectorIndex = MapRef->UnitVectors.Find(OutVector);
|
||||
int32 VariantIndex;
|
||||
|
||||
int32 InVecIndex = MapRef->UnitVectors.Find(InVec);
|
||||
|
||||
SceneComponent->SetRelativeRotation(FRotator(0, InVecIndex * 60.f, 0));
|
||||
|
||||
int32 OutVecIndex = MapRef->UnitVectors.Find(OutVec);
|
||||
|
||||
|
||||
int32 BackMotion = (InVecIndex + 3) % 6;
|
||||
if (BackMotion < 0) { BackMotion = (((InVecIndex + 3) % 6) + 6) % 6; } // c++ modulus weirdness
|
||||
|
||||
if (InVecIndex < BackMotion && OutVecIndex > BackMotion) {
|
||||
OutVecIndex--; }
|
||||
if (InVecIndex > BackMotion && OutVecIndex < BackMotion) {
|
||||
InVecIndex--; }
|
||||
|
||||
|
||||
int32 VariantIndex = (OutVecIndex - InVecIndex) % 5;
|
||||
if (VariantIndex < 0) { VariantIndex = ((OutVecIndex - InVecIndex) % 5 + 5) % 5; } // c++ modulus weirdness
|
||||
if (InVectorIndex == 0)
|
||||
{
|
||||
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; }
|
||||
}
|
||||
if (InVectorIndex == 1)
|
||||
{
|
||||
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; }
|
||||
}
|
||||
if (InVectorIndex == 2)
|
||||
{
|
||||
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; }
|
||||
}
|
||||
if (InVectorIndex == 3)
|
||||
{
|
||||
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; }
|
||||
}
|
||||
if (InVectorIndex == 4)
|
||||
{
|
||||
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; }
|
||||
}
|
||||
if (InVectorIndex == 5)
|
||||
{
|
||||
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));
|
||||
MeshVariants[VariantIndex]->ToggleVisibility();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user