mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-12 14:51:51 +09:00
fixme: picking up a fixture clones it
This commit is contained in:
@@ -48,7 +48,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
* e.g. 0x02010034 will be translated as 2.1.52
|
* e.g. 0x02010034 will be translated as 2.1.52
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const val VERSION_RAW = 0x000206D3
|
const val VERSION_RAW = 0x00030001
|
||||||
|
// Commit counts up to the Release 0.3: 2251 (plz update!)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////
|
||||||
// CONFIGURATION FOR TILE MAKER //
|
// CONFIGURATION FOR TILE MAKER //
|
||||||
|
|||||||
@@ -1235,7 +1235,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
if (fixturesUnderHand.size > 0 && fixturesUnderHand[0].canBeDespawned) {
|
if (fixturesUnderHand.size > 0 && fixturesUnderHand[0].canBeDespawned) {
|
||||||
val fixture = fixturesUnderHand[0]
|
val fixture = fixturesUnderHand[0]
|
||||||
val fixtureItem = ItemCodex.fixtureToItemID(fixture)
|
val fixtureItem = ItemCodex.fixtureToItemID(fixture)
|
||||||
printdbg(this, "Fixture pickup: ${fixture.javaClass.canonicalName} -> $fixtureItem")
|
printdbg(this, "Fixture pickup at F${WORLD_UPDATE_TIMER}: ${fixture.javaClass.canonicalName} -> $fixtureItem")
|
||||||
// 1. put the fixture to the inventory
|
// 1. put the fixture to the inventory
|
||||||
fixture.flagDespawn()
|
fixture.flagDespawn()
|
||||||
// 2. register this item(fixture) to the quickslot
|
// 2. register this item(fixture) to the quickslot
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import net.torvald.terrarum.gameactors.ActorWithBody
|
|||||||
import net.torvald.terrarum.gameactors.PhysProperties
|
import net.torvald.terrarum.gameactors.PhysProperties
|
||||||
import net.torvald.terrarum.gameitems.ItemID
|
import net.torvald.terrarum.gameitems.ItemID
|
||||||
import net.torvald.terrarum.gameworld.fmod
|
import net.torvald.terrarum.gameworld.fmod
|
||||||
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
|
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
import org.dyn4j.geometry.Vector2
|
import org.dyn4j.geometry.Vector2
|
||||||
|
|
||||||
@@ -158,7 +157,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
|||||||
*/
|
*/
|
||||||
open fun despawn() {
|
open fun despawn() {
|
||||||
if (canBeDespawned) {
|
if (canBeDespawned) {
|
||||||
printdbg(this, "despawn ${nameFun()}")
|
printdbg(this, "despawn at T${INGAME.WORLD_UPDATE_TIMER}: ${nameFun()}")
|
||||||
|
|
||||||
// remove filler block
|
// remove filler block
|
||||||
forEachBlockbox { x, y ->
|
forEachBlockbox { x, y ->
|
||||||
@@ -176,8 +175,10 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
|||||||
wireConsumption.clear()
|
wireConsumption.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
val drop = ItemCodex.fixtureToItemID(this)
|
if (flagDespawn) {
|
||||||
INGAME.queueActorAddition(DroppedItem(drop, hitbox.startX, hitbox.startY - 1.0))
|
val drop = ItemCodex.fixtureToItemID(this)
|
||||||
|
INGAME.queueActorAddition(DroppedItem(drop, hitbox.startX, hitbox.startY - 1.0))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printdbg(this, "cannot despawn a fixture with non-empty inventory")
|
printdbg(this, "cannot despawn a fixture with non-empty inventory")
|
||||||
@@ -195,7 +196,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
|||||||
|
|
||||||
}
|
}
|
||||||
if (!canBeDespawned) flagDespawn = false
|
if (!canBeDespawned) flagDespawn = false
|
||||||
else if (flagDespawn) despawn()
|
if (canBeDespawned && flagDespawn) despawn()
|
||||||
// actual actor removal is performed by the TerrarumIngame.killOrKnockdownActors
|
// actual actor removal is performed by the TerrarumIngame.killOrKnockdownActors
|
||||||
super.update(delta)
|
super.update(delta)
|
||||||
}
|
}
|
||||||
@@ -276,4 +277,4 @@ data class BlockBox(
|
|||||||
|
|
||||||
val NULL = BlockBox()
|
val NULL = BlockBox()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user