mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-06 08:38:30 +09:00
no secondary click; tiki torch kinda spawns?
This commit is contained in:
5
.idea/compiler.xml
generated
5
.idea/compiler.xml
generated
@@ -4,10 +4,7 @@
|
|||||||
<annotationProcessing>
|
<annotationProcessing>
|
||||||
<profile default="true" name="Default" enabled="true" />
|
<profile default="true" name="Default" enabled="true" />
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
<bytecodeTargetLevel target="10">
|
<bytecodeTargetLevel target="8" />
|
||||||
<module name="terrarum_main" target="11" />
|
|
||||||
<module name="terrarum_test" target="11" />
|
|
||||||
</bytecodeTargetLevel>
|
|
||||||
</component>
|
</component>
|
||||||
<component name="JavacSettings">
|
<component name="JavacSettings">
|
||||||
<option name="PREFER_TARGET_JDK_COMPILER" value="false" />
|
<option name="PREFER_TARGET_JDK_COMPILER" value="false" />
|
||||||
|
|||||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -38,7 +38,7 @@
|
|||||||
<property name="caretWidth" class="java.lang.Integer" />
|
<property name="caretWidth" class="java.lang.Integer" />
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="13-incubate" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -98,6 +98,11 @@
|
|||||||
"256";"256";"BLOCK_LANTERN_IRON_REGULAR";"0.0312";"0.0312";"0.0312";"0.0312";"1";"N/A";"FXTR";"0";"0";"0";"0";"0";"0";"16";"1.0000";"0.6372";"0.0000";"0.0000";"N/A";"N/A"
|
"256";"256";"BLOCK_LANTERN_IRON_REGULAR";"0.0312";"0.0312";"0.0312";"0.0312";"1";"N/A";"FXTR";"0";"0";"0";"0";"0";"0";"16";"1.0000";"0.6372";"0.0000";"0.0000";"N/A";"N/A"
|
||||||
"257";"257";"BLOCK_SUNSTONE";"0.1252";"0.1252";"0.1252";"0.1252";"1";"N/A";"ROCK";"1";"0";"0";"0";"2";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
"257";"257";"BLOCK_SUNSTONE";"0.1252";"0.1252";"0.1252";"0.1252";"1";"N/A";"ROCK";"1";"0";"0";"0";"2";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
||||||
"258";"258";"BLOCK_DAYLIGHT_CAPACITOR";"0.1252";"0.1252";"0.1252";"0.1252";"1";"N/A";"GLAS";"1";"0";"0";"0";"3";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
"258";"258";"BLOCK_DAYLIGHT_CAPACITOR";"0.1252";"0.1252";"0.1252";"0.1252";"1";"N/A";"GLAS";"1";"0";"0";"0";"3";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
||||||
|
"4091";"0";"ACTORBLOCK_NO_COLLISION";"0.0";"0.0";"0.0";"0.0";"1";"1";"NULL";"0";"0";"0";"0";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
|
||||||
|
"4092";"0";"ACTORBLOCK_FULL_COLLISION";"0.0";"0.0";"0.0";"0.0";"1";"1";"NULL";"0";"0";"0";"0";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
|
||||||
|
"4093";"0";"ACTORBLOCK_ALLOW_MOVE_DOWN";"0.0";"0.0";"0.0";"0.0";"1";"1";"NULL";"0";"1";"0";"0";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
|
||||||
|
"4094";"0";"ACTORBLOCK_NO_PASS_RIGHT";"0.0";"0.0";"0.0";"0.0";"1";"1";"NULL";"0";"0";"0";"0";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
|
||||||
|
"4095";"0";"ACTORBLOCK_NO_PASS_LEFT";"0.0";"0.0";"0.0";"0.0";"1";"1";"NULL";"0";"0";"0";"0";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
|
||||||
"4096";"0";"BLOCK_WATER";"0.1016";"0.0744";"0.0508";"0.0826";"100";"1000";"WATR";"0";"0";"0";"0";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"005599A6";"16"
|
"4096";"0";"BLOCK_WATER";"0.1016";"0.0744";"0.0508";"0.0826";"100";"1000";"WATR";"0";"0";"0";"0";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"005599A6";"16"
|
||||||
"4097";"0";"BLOCK_LAVA";"0.9696";"0.9696";"0.9696";"0.9696";"100";"2600";"ROCK";"0";"0";"0";"0";"0";"0";"16";"0.7664";"0.2032";"0.0000";"0.0000";"FF4600E6";"32"
|
"4097";"0";"BLOCK_LAVA";"0.9696";"0.9696";"0.9696";"0.9696";"100";"2600";"ROCK";"0";"0";"0";"0";"0";"0";"16";"0.7664";"0.2032";"0.0000";"0.0000";"FF4600E6";"32"
|
||||||
"-1";"0";"BLOCK_NULL";"4.0000";"4.0000";"4.0000";"4.0000";"-1";"2600";"NULL";"0";"0";"1";"0";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
"-1";"0";"BLOCK_NULL";"4.0000";"4.0000";"4.0000";"4.0000";"-1";"2600";"NULL";"0";"0";"1";"0";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
||||||
|
|||||||
|
@@ -32,7 +32,17 @@ class KDHeapifiedTree(actors: List<ActorWBMovable>) {
|
|||||||
private fun Int.getActor() = nodes[this]
|
private fun Int.getActor() = nodes[this]
|
||||||
private fun Int.getLeft() = this * 2 + 1
|
private fun Int.getLeft() = this * 2 + 1
|
||||||
private fun Int.getRight() = this * 2 + 2
|
private fun Int.getRight() = this * 2 + 2
|
||||||
private fun Int.set(value: ActorWBMovable?) { nodes[this] = value }
|
private fun Int.set(value: ActorWBMovable?) {
|
||||||
|
try {
|
||||||
|
nodes[this] = value
|
||||||
|
}
|
||||||
|
catch (_: ArrayIndexOutOfBoundsException) {
|
||||||
|
// modification of the private fun expandArray()
|
||||||
|
val prevNodes = nodes.copyOf() + value
|
||||||
|
Array<ActorWBMovable?>(prevNodes.size * 2, { null })
|
||||||
|
create(prevNodes.toList(), 0, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
private fun Int.setLeftChild(value: ActorWBMovable?) { nodes[this.getLeft()] = value }
|
private fun Int.setLeftChild(value: ActorWBMovable?) { nodes[this.getLeft()] = value }
|
||||||
private fun Int.setRightChild(value: ActorWBMovable?) { nodes[this.getRight()] = value }
|
private fun Int.setRightChild(value: ActorWBMovable?) { nodes[this.getRight()] = value }
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package net.torvald.aa
|
package net.torvald.aa
|
||||||
|
|
||||||
|
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||||
|
import net.torvald.terrarum.gameactors.Hitbox
|
||||||
|
import net.torvald.terrarum.sqr
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2019-04-18.
|
* Created by minjaesong on 2019-04-18.
|
||||||
*/
|
*/
|
||||||
/*class KDTree(points: List<ActorWithBody>) {
|
class KDTree(points: List<ActorWithBody>) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val DIMENSION = 2
|
const val DIMENSION = 2
|
||||||
@@ -15,7 +19,7 @@ package net.torvald.aa
|
|||||||
root = create(points, 0)
|
root = create(points, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findNearest(query: ActorWithBody) = getNearest(root!!, query, 0)
|
fun findNearest(query: ActorWithBody) = getNearest(root!!, query.hitbox, 0)
|
||||||
|
|
||||||
private fun create(points: List<ActorWithBody>, depth: Int): KDNode? {
|
private fun create(points: List<ActorWithBody>, depth: Int): KDNode? {
|
||||||
if (points.isEmpty()) {
|
if (points.isEmpty()) {
|
||||||
@@ -34,21 +38,21 @@ package net.torvald.aa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getNearest(currentNode: KDNode, query: ActorWithBody, depth: Int = 0): KDNode {
|
private fun getNearest(currentNode: KDNode, actorHitbox: Hitbox, depth: Int = 0): KDNode {
|
||||||
val direction = currentNode.compare(query, depth % DIMENSION)
|
val direction = currentNode.compare(actorHitbox, depth % DIMENSION)
|
||||||
|
|
||||||
val next = if (direction < 0) currentNode.left else currentNode.right
|
val next = if (direction < 0) currentNode.left else currentNode.right
|
||||||
val other = if (direction < 0) currentNode.right else currentNode.left
|
val other = if (direction < 0) currentNode.right else currentNode.left
|
||||||
var best = if (next == null) currentNode else getNearest(next, query, depth + 1) // traverse to leaf
|
var best = if (next == null) currentNode else getNearest(next, actorHitbox, depth + 1) // traverse to leaf
|
||||||
|
|
||||||
if (currentNode.position.distSqr(query) < best.position.distSqr(query)) {
|
if (currentNode.position.distSqr(actorHitbox) < best.position.distSqr(actorHitbox)) {
|
||||||
best = currentNode
|
best = currentNode
|
||||||
}
|
}
|
||||||
|
|
||||||
if (other != null) {
|
if (other != null) {
|
||||||
if (currentNode.position.dimDistSqr(query, depth % DIMENSION) < best.position.distSqr(query)) {
|
if (currentNode.position.dimDistSqr(actorHitbox, depth % DIMENSION) < best.position.distSqr(actorHitbox)) {
|
||||||
val bestCandidate = getNearest(other, query, depth + 1)
|
val bestCandidate = getNearest(other, actorHitbox, depth + 1)
|
||||||
if (bestCandidate.position.distSqr(query) < best.position.distSqr(query)) {
|
if (bestCandidate.position.distSqr(actorHitbox) < best.position.distSqr(actorHitbox)) {
|
||||||
best = bestCandidate
|
best = bestCandidate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,14 +62,15 @@ package net.torvald.aa
|
|||||||
}
|
}
|
||||||
|
|
||||||
data class KDNode(val left: KDNode?, val right: KDNode?, val actor: ActorWithBody, val position: Hitbox) {
|
data class KDNode(val left: KDNode?, val right: KDNode?, val actor: ActorWithBody, val position: Hitbox) {
|
||||||
fun compare(other: ActorWithBody, dimension: Int) = other.getDimensionalPoint(dimension) - this.position.getDimensionalPoint(dimension)
|
//fun compare(other: ActorWithBody, dimension: Int) = other.getDimensionalPoint(dimension) - this.position.getDimensionalPoint(dimension)
|
||||||
|
fun compare(other: Hitbox, dimension: Int) = other.getDimensionalPoint(dimension) - this.position.getDimensionalPoint(dimension)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Hitbox.distSqr(other: Hitbox) {
|
private fun Hitbox.distSqr(other: Hitbox): Double {
|
||||||
var dist = 0.0
|
var dist = 0.0
|
||||||
for (i in 0 until DIMENSION)
|
for (i in 0 until DIMENSION)
|
||||||
dist += (this.getDimensionalPoint(i) - other.getDimensionalPoint(i)).sqr()
|
dist += (this.getDimensionalPoint(i) - other.getDimensionalPoint(i)).sqr()
|
||||||
|
return dist
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Hitbox.dimDistSqr(other: Hitbox, dimension: Int) = other.getDimensionalPoint(dimension).minus(this.getDimensionalPoint(dimension)).sqr()
|
private fun Hitbox.dimDistSqr(other: Hitbox, dimension: Int) = other.getDimensionalPoint(dimension).minus(this.getDimensionalPoint(dimension)).sqr()
|
||||||
@@ -74,4 +79,4 @@ package net.torvald.aa
|
|||||||
internal fun ActorWithBody.getDimensionalPoint(depth: Int) = this.hitbox.getDimensionalPoint(depth)
|
internal fun ActorWithBody.getDimensionalPoint(depth: Int) = this.hitbox.getDimensionalPoint(depth)
|
||||||
// TODO take ROUNDWORLD into account
|
// TODO take ROUNDWORLD into account
|
||||||
internal fun Hitbox.getDimensionalPoint(depth: Int) =
|
internal fun Hitbox.getDimensionalPoint(depth: Int) =
|
||||||
if (depth % KDTree.DIMENSION == 0) this.canonicalX else this.canonicalY*/
|
if (depth % KDTree.DIMENSION == 0) this.canonicalX else this.canonicalY
|
||||||
@@ -94,16 +94,18 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* I have decided that left and right clicks must do the same thing, so no secondary use from now on. --Torvald on 2019-05-26
|
||||||
|
*
|
||||||
* Event for triggering held item's `startSecondaryUse(Float)`
|
* Event for triggering held item's `startSecondaryUse(Float)`
|
||||||
*/
|
*/
|
||||||
open fun worldSecondaryClickStart(delta: Float) {
|
//open fun worldSecondaryClickStart(delta: Float) { }
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* I have decided that left and right clicks must do the same thing, so no secondary use from now on. --Torvald on 2019-05-26
|
||||||
|
*
|
||||||
* Event for triggering held item's `endSecondaryUse(Float)`
|
* Event for triggering held item's `endSecondaryUse(Float)`
|
||||||
*/
|
*/
|
||||||
open fun worldSecondaryClickEnd(delta: Float) {
|
//open fun worldSecondaryClickEnd(delta: Float) { }
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event for triggering fixture update when something is placed/removed on the world.
|
* Event for triggering fixture update when something is placed/removed on the world.
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ class UIItemInventoryElem(
|
|||||||
// equip da shit
|
// equip da shit
|
||||||
val itemEquipSlot = item!!.equipPosition
|
val itemEquipSlot = item!!.equipPosition
|
||||||
if (itemEquipSlot == GameItem.EquipPosition.NULL) {
|
if (itemEquipSlot == GameItem.EquipPosition.NULL) {
|
||||||
TODO("Equip position is NULL, does this mean it's single-consume items like a potion?")
|
TODO("Equip position is NULL, does this mean it's single-consume items like a potion? (from item: \"$item\" with itemID: ${item?.originalID}/${item?.dynamicID})")
|
||||||
}
|
}
|
||||||
|
|
||||||
val player = (Terrarum.ingame!! as Ingame).actorNowPlaying
|
val player = (Terrarum.ingame!! as Ingame).actorNowPlaying
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ object Block {
|
|||||||
const val DAYLIGHT_CAPACITOR = 258
|
const val DAYLIGHT_CAPACITOR = 258
|
||||||
|
|
||||||
|
|
||||||
const val ACTORBLOCK_NO_COLLISION = 4191
|
const val ACTORBLOCK_NO_COLLISION = 4091
|
||||||
const val ACTORBLOCK_FULL_COLLISION = 4092
|
const val ACTORBLOCK_FULL_COLLISION = 4092
|
||||||
const val ACTORBLOCK_ALLOW_MOVE_DOWN = 4093
|
const val ACTORBLOCK_ALLOW_MOVE_DOWN = 4093
|
||||||
const val ACTORBLOCK_NO_PASS_RIGHT = 4094
|
const val ACTORBLOCK_NO_PASS_RIGHT = 4094
|
||||||
|
|||||||
@@ -58,12 +58,14 @@ class IngameController(val ingame: Ingame) : InputAdapter() {
|
|||||||
// fire world click events; the event is defined as Ingame's (or any others') WorldClick event
|
// fire world click events; the event is defined as Ingame's (or any others') WorldClick event
|
||||||
if (ingame.uiContainer.map { if ((it.isOpening || it.isOpened) && it.mouseUp) 1 else 0 }.sum() == 0) { // no UI on the mouse, right?
|
if (ingame.uiContainer.map { if ((it.isOpening || it.isOpened) && it.mouseUp) 1 else 0 }.sum() == 0) { // no UI on the mouse, right?
|
||||||
|
|
||||||
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary"))) {
|
if (
|
||||||
|
Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary")) ||
|
||||||
|
Gdx.input.isButtonPressed(AppLoader.getConfigInt("mousesecondary"))) {
|
||||||
ingame.worldPrimaryClickStart(AppLoader.UPDATE_RATE.toFloat())
|
ingame.worldPrimaryClickStart(AppLoader.UPDATE_RATE.toFloat())
|
||||||
}
|
}
|
||||||
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mousesecondary"))) {
|
/*if Gdx.input.isButtonPressed(AppLoader.getConfigInt("mousesecondary")) {
|
||||||
ingame.worldSecondaryClickStart(AppLoader.UPDATE_RATE.toFloat())
|
ingame.worldSecondaryClickStart(AppLoader.UPDATE_RATE.toFloat())
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,12 +148,14 @@ class IngameController(val ingame: Ingame) : InputAdapter() {
|
|||||||
// fire world click events; the event is defined as Ingame's (or any others') WorldClick event
|
// fire world click events; the event is defined as Ingame's (or any others') WorldClick event
|
||||||
if (ingame.uiContainer.map { if ((it.isOpening || it.isOpened) && it.mouseUp) 1 else 0 }.sum() == 0) { // no UI on the mouse, right?
|
if (ingame.uiContainer.map { if ((it.isOpening || it.isOpened) && it.mouseUp) 1 else 0 }.sum() == 0) { // no UI on the mouse, right?
|
||||||
|
|
||||||
if (button == AppLoader.getConfigInt("mouseprimary")) {
|
if (
|
||||||
|
button == AppLoader.getConfigInt("mouseprimary") ||
|
||||||
|
button == AppLoader.getConfigInt("mousesecondary")) {
|
||||||
ingame.worldPrimaryClickEnd(AppLoader.UPDATE_RATE.toFloat())
|
ingame.worldPrimaryClickEnd(AppLoader.UPDATE_RATE.toFloat())
|
||||||
}
|
}
|
||||||
if (button == AppLoader.getConfigInt("mousesecondary")) {
|
/*if (button == AppLoader.getConfigInt("mousesecondary")) {
|
||||||
ingame.worldSecondaryClickEnd(AppLoader.UPDATE_RATE.toFloat())
|
ingame.worldSecondaryClickEnd(AppLoader.UPDATE_RATE.toFloat())
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,13 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
|||||||
/**
|
/**
|
||||||
* Where to equip the item.
|
* Where to equip the item.
|
||||||
*
|
*
|
||||||
* Can't use 'open val' as GSON don't like that
|
* Can't use 'open val' as GSON doesn't like that. Initialise this property like:
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* init {
|
||||||
|
* equipPosition = EquipPosition.HAND_GRIP
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
var equipPosition: Int = EquipPosition.NULL
|
var equipPosition: Int = EquipPosition.NULL
|
||||||
|
|
||||||
@@ -165,6 +171,8 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
|||||||
open fun startPrimaryUse(delta: Float): Boolean = false
|
open fun startPrimaryUse(delta: Float): Boolean = false
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* I have decided that left and right clicks must do the same thing, so no secondary use from now on. --Torvald on 2019-05-26
|
||||||
|
*
|
||||||
* Apply effects (continuously or not) while secondary button is down
|
* Apply effects (continuously or not) while secondary button is down
|
||||||
* The item will NOT be consumed, so you will want to consume it yourself by inventory.consumeItem(item)
|
* The item will NOT be consumed, so you will want to consume it yourself by inventory.consumeItem(item)
|
||||||
*
|
*
|
||||||
@@ -174,7 +182,7 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
|||||||
*
|
*
|
||||||
* note: DO NOT super() this!
|
* note: DO NOT super() this!
|
||||||
*/
|
*/
|
||||||
open fun startSecondaryUse(delta: Float): Boolean = false
|
//open fun startSecondaryUse(delta: Float): Boolean = false
|
||||||
|
|
||||||
open fun endPrimaryUse(delta: Float): Boolean = false
|
open fun endPrimaryUse(delta: Float): Boolean = false
|
||||||
open fun endSecondaryUse(delta: Float): Boolean = false
|
open fun endSecondaryUse(delta: Float): Boolean = false
|
||||||
|
|||||||
@@ -210,12 +210,12 @@ open class GameWorld {
|
|||||||
terrain * PairedMapLayer.RANGE + terrainDamage
|
terrain * PairedMapLayer.RANGE + terrainDamage
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getWallLowBits(x: Int, y: Int): Int? {
|
private fun getWallLowBits(x: Int, y: Int): Int? {
|
||||||
val (x, y) = coerceXY(x, y)
|
val (x, y) = coerceXY(x, y)
|
||||||
return layerWallLowBits.getData(x, y)
|
return layerWallLowBits.getData(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTerrainLowBits(x: Int, y: Int): Int? {
|
private fun getTerrainLowBits(x: Int, y: Int): Int? {
|
||||||
val (x, y) = coerceXY(x, y)
|
val (x, y) = coerceXY(x, y)
|
||||||
return layerTerrainLowBits.getData(x, y)
|
return layerTerrainLowBits.getData(x, y)
|
||||||
}
|
}
|
||||||
@@ -226,57 +226,49 @@ open class GameWorld {
|
|||||||
* *
|
* *
|
||||||
* @param y
|
* @param y
|
||||||
* *
|
* *
|
||||||
* @param combinedTilenum Item id of the wall block. Less-than-4096-value is permitted.
|
* @param tilenum Item id of the wall block. Less-than-4096-value is permitted.
|
||||||
*/
|
*/
|
||||||
fun setTileWall(x: Int, y: Int, combinedTilenum: Int) {
|
fun setTileWall(x: Int, y: Int, tilenum: Int) {
|
||||||
val (x, y) = coerceXY(x, y)
|
val (x, y) = coerceXY(x, y)
|
||||||
val combinedTilenum = combinedTilenum % GameWorld.TILES_SUPPORTED // does work without this, but to be safe...
|
val tilenum = tilenum % TILES_SUPPORTED // does work without this, but to be safe...
|
||||||
setTileWall(x, y, (combinedTilenum / PairedMapLayer.RANGE).toByte(), combinedTilenum % PairedMapLayer.RANGE)
|
|
||||||
|
val oldWall = getTileFromWall(x, y)
|
||||||
|
layerWall.setTile(x, y, (tilenum / PairedMapLayer.RANGE).toByte())
|
||||||
|
layerWallLowBits.setData(x, y, tilenum % PairedMapLayer.RANGE)
|
||||||
|
wallDamages.remove(LandUtil.getBlockAddr(this, x, y))
|
||||||
|
|
||||||
|
if (oldWall != null)
|
||||||
|
Terrarum.ingame?.queueWallChangedEvent(oldWall, tilenum, LandUtil.getBlockAddr(this, x, y))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the tile of wall as specified, with damage value of zero.
|
* Set the tile of wall as specified, with damage value of zero.
|
||||||
|
*
|
||||||
|
* Warning: this function alters fluid lists: be wary of call order!
|
||||||
|
*
|
||||||
* @param x
|
* @param x
|
||||||
* *
|
* *
|
||||||
* @param y
|
* @param y
|
||||||
* *
|
* *
|
||||||
* @param combinedTilenum Item id of the terrain block, <4096
|
* @param tilenum Item id of the terrain block, <4096
|
||||||
*/
|
*/
|
||||||
fun setTileTerrain(x: Int, y: Int, combinedTilenum: Int) {
|
fun setTileTerrain(x: Int, y: Int, tilenum: Int) {
|
||||||
val (x, y) = coerceXY(x, y)
|
val (x, y) = coerceXY(x, y)
|
||||||
setTileTerrain(x, y, (combinedTilenum / PairedMapLayer.RANGE).toByte(), combinedTilenum % PairedMapLayer.RANGE)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setTileWall(x: Int, y: Int, tile: Byte, damage: Int) {
|
|
||||||
val (x, y) = coerceXY(x, y)
|
|
||||||
val oldWall = getTileFromWall(x, y)
|
|
||||||
layerWall.setTile(x, y, tile)
|
|
||||||
layerWallLowBits.setData(x, y, damage)
|
|
||||||
wallDamages.remove(LandUtil.getBlockAddr(this, x, y))
|
|
||||||
|
|
||||||
if (oldWall != null)
|
|
||||||
Terrarum.ingame?.queueWallChangedEvent(oldWall, tile.toUint() * PairedMapLayer.RANGE + damage, LandUtil.getBlockAddr(this, x, y))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Warning: this function alters fluid lists: be wary of call order!
|
|
||||||
*/
|
|
||||||
fun setTileTerrain(x: Int, y: Int, tile: Byte, damage: Int) {
|
|
||||||
val (x, y) = coerceXY(x, y)
|
|
||||||
val oldTerrain = getTileFromTerrain(x, y)
|
val oldTerrain = getTileFromTerrain(x, y)
|
||||||
layerTerrain.setTile(x, y, tile)
|
layerTerrain.setTile(x, y, (tilenum / PairedMapLayer.RANGE).toByte())
|
||||||
layerTerrainLowBits.setData(x, y, damage)
|
layerTerrainLowBits.setData(x, y, tilenum % PairedMapLayer.RANGE)
|
||||||
val blockAddr = LandUtil.getBlockAddr(this, x, y)
|
val blockAddr = LandUtil.getBlockAddr(this, x, y)
|
||||||
terrainDamages.remove(blockAddr)
|
terrainDamages.remove(blockAddr)
|
||||||
|
|
||||||
if (BlockCodex[tile * PairedMapLayer.RANGE + damage].isSolid) {
|
if (BlockCodex[tilenum].isSolid) {
|
||||||
fluidFills.remove(blockAddr)
|
fluidFills.remove(blockAddr)
|
||||||
fluidTypes.remove(blockAddr)
|
fluidTypes.remove(blockAddr)
|
||||||
}
|
}
|
||||||
// fluid tiles-item should be modified so that they will also place fluid onto their respective map
|
// fluid tiles-item should be modified so that they will also place fluid onto their respective map
|
||||||
|
|
||||||
if (oldTerrain != null)
|
if (oldTerrain != null)
|
||||||
Terrarum.ingame?.queueTerrainChangedEvent(oldTerrain, tile.toUint() * PairedMapLayer.RANGE + damage, LandUtil.getBlockAddr(this, x, y))
|
Terrarum.ingame?.queueTerrainChangedEvent(oldTerrain, tilenum, LandUtil.getBlockAddr(this, x, y))
|
||||||
}
|
}
|
||||||
|
|
||||||
/*fun setTileWire(x: Int, y: Int, tile: Byte) {
|
/*fun setTileWire(x: Int, y: Int, tile: Byte) {
|
||||||
|
|||||||
@@ -404,7 +404,8 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
ItemCodex[itemOnGrip]?.endPrimaryUse(delta)
|
ItemCodex[itemOnGrip]?.endPrimaryUse(delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun worldSecondaryClickStart(delta: Float) {
|
// I have decided that left and right clicks must do the same thing, so no secondary use from now on. --Torvald on 2019-05-26
|
||||||
|
/*override fun worldSecondaryClickStart(delta: Float) {
|
||||||
val itemOnGrip = actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
|
val itemOnGrip = actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
|
||||||
val consumptionSuccessful = ItemCodex[itemOnGrip]?.startSecondaryUse(delta) ?: false
|
val consumptionSuccessful = ItemCodex[itemOnGrip]?.startSecondaryUse(delta) ?: false
|
||||||
if (consumptionSuccessful)
|
if (consumptionSuccessful)
|
||||||
@@ -414,7 +415,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
override fun worldSecondaryClickEnd(delta: Float) {
|
override fun worldSecondaryClickEnd(delta: Float) {
|
||||||
val itemOnGrip = actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
|
val itemOnGrip = actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
|
||||||
ItemCodex[itemOnGrip]?.endSecondaryUse(delta)
|
ItemCodex[itemOnGrip]?.endSecondaryUse(delta)
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,20 +42,27 @@ open class FixtureBase(val blockBox: BlockBox, val blockBoxProps: BlockBoxProps
|
|||||||
// posY: bottom of the blockBox
|
// posY: bottom of the blockBox
|
||||||
// using the actor's hitbox
|
// using the actor's hitbox
|
||||||
|
|
||||||
|
// TODO: obviously check for collision
|
||||||
|
|
||||||
for (x in posX until posX + blockBox.width) {
|
for (x in posX until posX + blockBox.width) {
|
||||||
for (y in posY until posY + blockBox.height) {
|
for (y in posY until posY + blockBox.height) {
|
||||||
world.setTileTerrain(x, y, blockBox.collisionType)
|
world.setTileTerrain(x, y, blockBox.collisionType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set the position of this actor
|
||||||
worldBlockPos = Point2i(posX, posY)
|
worldBlockPos = Point2i(posX, posY)
|
||||||
|
|
||||||
this.isVisible = true
|
this.isVisible = true
|
||||||
this.hitbox.setFromWidthHeight(posX * TSIZE, posY * TSIZE, blockBox.width * TSIZE, blockBox.height * TSIZE)
|
this.hitbox.setFromWidthHeight(posX * TSIZE, posY * TSIZE, blockBox.width * TSIZE, blockBox.height * TSIZE)
|
||||||
|
|
||||||
|
// actually add this actor into the world
|
||||||
|
Terrarum.ingame!!.addNewActor(this)
|
||||||
|
|
||||||
|
|
||||||
return true // TODO for the tests' sake, just get fucking spawned
|
return true // TODO for the tests' sake, just get fucking spawned
|
||||||
|
|
||||||
|
// TODO TESTING RESULTS SO FAR: tiki torch does emit lights, but its body cannot be seen
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -25,10 +25,17 @@ class TikiTorchTester(originalID: ItemID) : GameItem(originalID) {
|
|||||||
get() = AppLoader.resourcePool.getAsTextureRegion("itemplaceholder_48")
|
get() = AppLoader.resourcePool.getAsTextureRegion("itemplaceholder_48")
|
||||||
override var baseToolSize: Double? = baseMass
|
override var baseToolSize: Double? = baseMass
|
||||||
|
|
||||||
|
init {
|
||||||
|
equipPosition = EquipPosition.HAND_GRIP
|
||||||
|
}
|
||||||
|
|
||||||
override fun startPrimaryUse(delta: Float): Boolean {
|
override fun startPrimaryUse(delta: Float): Boolean {
|
||||||
val torch = FixtureTikiTorch()
|
val torch = FixtureTikiTorch()
|
||||||
|
|
||||||
|
//println("aroisetn")
|
||||||
|
|
||||||
return torch.spawn(Terrarum.mouseTileX, Terrarum.mouseTileY - torch.blockBox.height + 1)
|
return torch.spawn(Terrarum.mouseTileX, Terrarum.mouseTileY - torch.blockBox.height + 1)
|
||||||
// return true when placed, false when cannot be placed
|
// return true when placed, false when cannot be placed
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameworld
|
package net.torvald.terrarum.modulebasegame.gameworld
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import net.torvald.aa.KDHeapifiedTree
|
import net.torvald.aa.KDTree
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
@@ -52,7 +52,7 @@ object WorldSimulator {
|
|||||||
private val ingame = Terrarum.ingame!!
|
private val ingame = Terrarum.ingame!!
|
||||||
private val world = ingame.world
|
private val world = ingame.world
|
||||||
|
|
||||||
private var actorsKDTree: KDHeapifiedTree? = null
|
private var actorsKDTree: KDTree? = null
|
||||||
|
|
||||||
fun resetForThisFrame() {
|
fun resetForThisFrame() {
|
||||||
actorsKDTree = null
|
actorsKDTree = null
|
||||||
@@ -61,7 +61,7 @@ object WorldSimulator {
|
|||||||
operator fun invoke(player: ActorHumanoid?, delta: Float) {
|
operator fun invoke(player: ActorHumanoid?, delta: Float) {
|
||||||
// build the kdtree that will be used during a single frame of updating
|
// build the kdtree that will be used during a single frame of updating
|
||||||
if (actorsKDTree == null)
|
if (actorsKDTree == null)
|
||||||
actorsKDTree = KDHeapifiedTree(ingame.actorContainerActive.filter { it is ActorWBMovable })
|
actorsKDTree = KDTree(ingame.actorContainerActive.filter { it is ActorWBMovable })
|
||||||
|
|
||||||
//printdbg(this, "============================")
|
//printdbg(this, "============================")
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
<module type="JAVA_MODULE" version="4">
|
<module type="JAVA_MODULE" version="4">
|
||||||
<component name="FacetManager">
|
<component name="FacetManager">
|
||||||
<facet type="kotlin-language" name="Kotlin">
|
<facet type="kotlin-language" name="Kotlin">
|
||||||
<configuration version="3" platform="JVM 9">
|
<configuration version="3" platform="JVM 1.8">
|
||||||
<compilerSettings />
|
<compilerSettings />
|
||||||
<compilerArguments>
|
<compilerArguments>
|
||||||
<option name="jvmTarget" value="11" />
|
<option name="jvmTarget" value="1.8" />
|
||||||
</compilerArguments>
|
</compilerArguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</facet>
|
</facet>
|
||||||
|
|||||||
Reference in New Issue
Block a user