Skip to content

Instantly share code, notes, and snippets.

@ultraviolet-jordan
Created June 16, 2023 18:40
Show Gist options
  • Save ultraviolet-jordan/8ef68d7b0fcf71fa75c60f577e2ad331 to your computer and use it in GitHub Desktop.
Save ultraviolet-jordan/8ef68d7b0fcf71fa75c60f577e2ad331 to your computer and use it in GitHub Desktop.
@JvmInline
value class MapSquareLandTile(
private val packed: Long
) {
constructor(
height: Int,
overlayId: Int,
overlayPath: Int,
overlayRotation: Int,
collision: Int,
underlayId: Int
) : this(((height and 0xff) or ((overlayId and 0xff) shl 8) or ((overlayPath and 0xff) shl 16)).toLong() or (((overlayRotation and 0xff) or ((collision and 0xff) shl 8) or ((underlayId and 0xff) shl 16)).toLong() shl 24))
val height: Int get() = (packed and 0xff).toInt()
val overlayId: Int get() = (packed shr 8 and 0xff).toInt()
val overlayPath: Int get() = (packed shr 16 and 0xff).toInt()
val collision: Int get() = ((packed shr 24 and 0xffffffffL).toInt() shr 8 and 0xff)
val overlayRotation: Int get() = ((packed shr 24 and 0xffffffffL).toInt() and 0xff)
val underlayId: Int get() = ((packed shr 24 and 0xffffffffL).toInt() shr 16 and 0xff)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment