mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-06 08:38:30 +09:00
barehand action will not remove fixtures (more pricisely, actorblocks)
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package net.torvald
|
package net.torvald
|
||||||
|
|
||||||
|
import net.torvald.terrarum.savegame.ByteArray64
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2019-08-05.
|
* Created by minjaesong on 2019-08-05.
|
||||||
*/
|
*/
|
||||||
@@ -27,4 +29,47 @@ fun getKeycapFkeys(n: Int) = when (n) {
|
|||||||
in 1..9 -> "\uE090${(0xE090 + n).toChar()}"
|
in 1..9 -> "\uE090${(0xE090 + n).toChar()}"
|
||||||
in 10..12 -> "\uE09D${(0xE090 + n).toChar()}"
|
in 10..12 -> "\uE09D${(0xE090 + n).toChar()}"
|
||||||
else -> throw IllegalArgumentException("Not in range: $n")
|
else -> throw IllegalArgumentException("Not in range: $n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun List<Int>.toJavaString(): String {
|
||||||
|
val sb = StringBuilder()
|
||||||
|
this.forEach {
|
||||||
|
if (it > 65535) {
|
||||||
|
val u = it - 65536
|
||||||
|
sb.append((0xD800 or (u ushr 10).and(1023)).toChar())
|
||||||
|
sb.append((0xDC00 or (u and 1023)).toChar())
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sb.append(it.toChar())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun List<Int>.toUTF8Bytes64(): ByteArray64 {
|
||||||
|
val ba = ByteArray64()
|
||||||
|
this.forEach { codepoint ->
|
||||||
|
when (codepoint) {
|
||||||
|
in 0..127 -> ba.add(codepoint.toByte())
|
||||||
|
in 128..2047 -> {
|
||||||
|
ba.add((0xC0 or codepoint.ushr(6).and(31)).toByte())
|
||||||
|
ba.add((0x80 or codepoint.and(63)).toByte())
|
||||||
|
}
|
||||||
|
in 2048..65535 -> {
|
||||||
|
ba.add((0xE0 or codepoint.ushr(12).and(15)).toByte())
|
||||||
|
ba.add((0x80 or codepoint.ushr(6).and(63)).toByte())
|
||||||
|
ba.add((0x80 or codepoint.and(63)).toByte())
|
||||||
|
}
|
||||||
|
in 65536..1114111 -> {
|
||||||
|
ba.add((0xF0 or codepoint.ushr(18).and(7)).toByte())
|
||||||
|
ba.add((0x80 or codepoint.ushr(12).and(63)).toByte())
|
||||||
|
ba.add((0x80 or codepoint.ushr(6).and(63)).toByte())
|
||||||
|
ba.add((0x80 or codepoint.and(63)).toByte())
|
||||||
|
}
|
||||||
|
else -> throw IllegalArgumentException("Not a unicode code point: U+${codepoint.toString(16).toUpperCase()}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ba
|
||||||
|
}
|
||||||
|
|
||||||
|
fun List<Int>.toUTF8Bytes() = this.toUTF8Bytes64().toByteArray()
|
||||||
@@ -132,6 +132,7 @@ object Block {
|
|||||||
const val NULL = "basegame:-1"
|
const val NULL = "basegame:-1"
|
||||||
|
|
||||||
val actorblocks = listOf(
|
val actorblocks = listOf(
|
||||||
|
ACTORBLOCK_TILING_PLACEHOLDER,
|
||||||
ACTORBLOCK_NO_COLLISION,
|
ACTORBLOCK_NO_COLLISION,
|
||||||
ACTORBLOCK_FULL_COLLISION,
|
ACTORBLOCK_FULL_COLLISION,
|
||||||
ACTORBLOCK_ALLOW_MOVE_DOWN,
|
ACTORBLOCK_ALLOW_MOVE_DOWN,
|
||||||
|
|||||||
@@ -1220,7 +1220,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
// else, punch a block
|
// else, punch a block
|
||||||
val punchBlockSize = punchSize.div(TILE_SIZED).floorInt()
|
val punchBlockSize = punchSize.div(TILE_SIZED).floorInt()
|
||||||
if (punchBlockSize > 0) {
|
if (punchBlockSize > 0) {
|
||||||
PickaxeCore.startPrimaryUse(actor, delta, null, Terrarum.mouseTileX, Terrarum.mouseTileY, 1.0 / punchBlockSize, punchBlockSize, punchBlockSize)
|
PickaxeCore.startPrimaryUse(actor, delta, null, Terrarum.mouseTileX, Terrarum.mouseTileY, 1.0 / punchBlockSize, punchBlockSize, punchBlockSize, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,10 @@ object PickaxeCore {
|
|||||||
* @param mw width of the digging
|
* @param mw width of the digging
|
||||||
* @param mh height of the digging
|
* @param mh height of the digging
|
||||||
*/
|
*/
|
||||||
fun startPrimaryUse(actor: ActorWithBody, delta: Float, item: GameItem?, mx: Int, my: Int, dropProbability: Double = 1.0, mw: Int = 1, mh: Int = 1) = inInteractableRange(actor) {
|
fun startPrimaryUse(
|
||||||
|
actor: ActorWithBody, delta: Float, item: GameItem?, mx: Int, my: Int,
|
||||||
|
dropProbability: Double = 1.0, mw: Int = 1, mh: Int = 1, attackActorBlocks: Boolean = true
|
||||||
|
) = inInteractableRange(actor) {
|
||||||
// un-round the mx
|
// un-round the mx
|
||||||
val ww = INGAME.world.width
|
val ww = INGAME.world.width
|
||||||
val apos = actor.centrePosPoint
|
val apos = actor.centrePosPoint
|
||||||
@@ -50,6 +53,7 @@ object PickaxeCore {
|
|||||||
|
|
||||||
val mousePoint = Point2d(x.toDouble(), y.toDouble())
|
val mousePoint = Point2d(x.toDouble(), y.toDouble())
|
||||||
val actorvalue = actor.actorValue
|
val actorvalue = actor.actorValue
|
||||||
|
val tile = (INGAME.world).getTileFromTerrain(x, y)
|
||||||
|
|
||||||
item?.using = true
|
item?.using = true
|
||||||
|
|
||||||
@@ -64,7 +68,7 @@ object PickaxeCore {
|
|||||||
if (!ret1) return ret1*/
|
if (!ret1) return ret1*/
|
||||||
|
|
||||||
// return false if here's no tile
|
// return false if here's no tile
|
||||||
if (Block.AIR == (INGAME.world).getTileFromTerrain(x, y)) {
|
if (Block.AIR == tile || (!attackActorBlocks && tile in Block.actorblocks)) {
|
||||||
usageStatus = usageStatus or false
|
usageStatus = usageStatus or false
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,15 +70,15 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
|
|||||||
tex.forEach { it.flip(false, true) }
|
tex.forEach { it.flip(false, true) }
|
||||||
|
|
||||||
goButton.touchDownListener = { _, _, _, _ ->
|
goButton.touchDownListener = { _, _, _, _ ->
|
||||||
printdbg(this, "generate!")
|
printdbg(this, "generate! Size=${sizeSelector.selection}, Name=${nameInput.getTextOrPlaceholder()}, Seed=${seedInput.getTextOrPlaceholder()}")
|
||||||
}
|
}
|
||||||
backButton.touchDownListener = { _, _, _, _ ->
|
backButton.touchDownListener = { _, _, _, _ ->
|
||||||
printdbg(this, "back!")
|
printdbg(this, "back!")
|
||||||
}
|
}
|
||||||
|
|
||||||
addUIitem(sizeSelector)
|
addUIitem(sizeSelector)
|
||||||
addUIitem(nameInput)
|
addUIitem(seedInput) // order is important
|
||||||
addUIitem(seedInput)
|
addUIitem(nameInput) // because of the IME candidates overlay
|
||||||
addUIitem(goButton)
|
addUIitem(goButton)
|
||||||
addUIitem(backButton)
|
addUIitem(backButton)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import net.torvald.terrarum.gamecontroller.TerrarumInputMethod
|
|||||||
import net.torvald.terrarum.utils.Clipboard
|
import net.torvald.terrarum.utils.Clipboard
|
||||||
import net.torvald.terrarumsansbitmap.gdx.CodepointSequence
|
import net.torvald.terrarumsansbitmap.gdx.CodepointSequence
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
import net.torvald.toJavaString
|
||||||
import kotlin.streams.toList
|
import kotlin.streams.toList
|
||||||
|
|
||||||
data class InputLenCap(val count: Int, val unit: CharLenUnit) {
|
data class InputLenCap(val count: Int, val unit: CharLenUnit) {
|
||||||
@@ -336,7 +337,7 @@ class UIItemTextLineInput(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun textbufToString(): String {
|
private fun textbufToString(): String {
|
||||||
return ""
|
return textbuf.toJavaString()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render(batch: SpriteBatch, camera: Camera) {
|
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||||
@@ -457,7 +458,7 @@ class UIItemTextLineInput(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getText() = textbufToString()
|
fun getText() = textbufToString()
|
||||||
fun getTextOrPlaceholder() = if (textbuf.isEmpty()) currentPlaceholderText else getText()
|
fun getTextOrPlaceholder(): String = if (textbuf.isEmpty()) currentPlaceholderText.toJavaString() else getText()
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
fbo.dispose()
|
fbo.dispose()
|
||||||
|
|||||||
Reference in New Issue
Block a user