mirror of
https://github.com/yairm210/Unciv.git
synced 2024-12-22 23:14:25 +07:00
perf: faster vector -> direction conversion
Some checks failed
Conflict marking / main (push) Failing after 11s
Detekt / detekt (ubuntu-latest) (push) Failing after 51s
Generate mkdocs from docs folder / deploy (push) Failing after 14m57s
Build and test / Check code and run unit tests (push) Failing after 52m14s
Close stale issues and PRs / stale (push) Has started running
Docker / build (push) Has started running
Some checks failed
Conflict marking / main (push) Failing after 11s
Detekt / detekt (ubuntu-latest) (push) Failing after 51s
Generate mkdocs from docs folder / deploy (push) Failing after 14m57s
Build and test / Check code and run unit tests (push) Failing after 52m14s
Close stale issues and PRs / stale (push) Has started running
Docker / build (push) Has started running
This commit is contained in:
parent
73424466d4
commit
ec2950305d
@ -253,16 +253,20 @@ enum class NeighborDirection {
|
||||
Top, TopRight, TopLeft, Bottom, BottomLeft, BottomRight;
|
||||
|
||||
companion object {
|
||||
fun fromVector(vector2: Vector2): NeighborDirection? = when {
|
||||
vector2.x == 1f && vector2.y == 1f -> Top
|
||||
vector2.x == 0f && vector2.y == 1f -> TopRight
|
||||
vector2.x == 1f && vector2.y == 0f -> TopLeft
|
||||
vector2.x == -1f && vector2.y == -1f -> Bottom
|
||||
vector2.x == 0f && vector2.y == -1f -> BottomLeft
|
||||
vector2.x == -1f && vector2.y == 0f -> BottomRight
|
||||
fun fromVector(vector2: Vector2): NeighborDirection? {
|
||||
val x = vector2.x.toInt()
|
||||
val y = vector2.y.toInt()
|
||||
return when (x) {
|
||||
1 -> if (y == 1) Top // x == 1 && y == 1
|
||||
else TopLeft // x == 1 && y == 0
|
||||
0 -> if (y == 1) TopRight // x == 0 && y == 1
|
||||
else BottomLeft // x == 0 && y == -1
|
||||
-1 -> if (y == -1) Bottom // x == -1 && y == -1
|
||||
else BottomRight // x == -1 && y == 0
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class EdgeTileImage(val fileName:String, val originTileFilter: String, val destinationTileFilter: String, val edgeType: NeighborDirection)
|
||||
|
Loading…
Reference in New Issue
Block a user