mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 12:04:06 +09:00
wip 2
This commit is contained in:
@@ -168,7 +168,7 @@ open class ActorHumanoid(
|
||||
|
||||
private var jumpJustPressedLatched = false
|
||||
|
||||
@Transient private val nullItem = object : GameItem(0) {
|
||||
@Transient private val nullItem = object : GameItem("item@basegame:0") {
|
||||
override val isUnique: Boolean = false
|
||||
override var baseMass: Double = 0.0
|
||||
override var baseToolSize: Double? = null
|
||||
|
||||
@@ -14,15 +14,15 @@ import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
open class DroppedItem(private val item: GameItem) : ActorWithBody(RenderOrder.MIDTOP, PhysProperties.PHYSICS_OBJECT) {
|
||||
|
||||
init {
|
||||
if (item.dynamicID >= ItemCodex.ACTORID_MIN)
|
||||
if (item.dynamicID.startsWith("actor@"))
|
||||
throw RuntimeException("Attempted to create DroppedItem actor of a real actor; the real actor must be dropped instead.")
|
||||
|
||||
isVisible = true
|
||||
|
||||
avBaseMass = if (item.dynamicID < BlockCodex.MAX_TERRAIN_TILES)
|
||||
BlockCodex[item.dynamicID].density / 1000.0
|
||||
else
|
||||
avBaseMass = if (item.dynamicID.startsWith("item@"))
|
||||
ItemCodex[item.dynamicID]!!.mass
|
||||
else
|
||||
BlockCodex[item.dynamicID].density / 1000.0 // block and wall
|
||||
|
||||
actorValue[AVKey.SCALE] = ItemCodex[item.dynamicID]!!.scale
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.PhysProperties
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
|
||||
@@ -201,7 +202,7 @@ inline class BlockBoxProps(val flags: Int) {
|
||||
* @param width Width of the block box, tile-wise
|
||||
* @param height Height of the block box, tile-wise
|
||||
*/
|
||||
data class BlockBox(val collisionType: Int, val width: Int, val height: Int) {
|
||||
data class BlockBox(val collisionType: ItemID, val width: Int, val height: Int) {
|
||||
|
||||
/*fun redefine(collisionType: Int, width: Int, height: Int) {
|
||||
redefine(collisionType)
|
||||
|
||||
@@ -27,7 +27,7 @@ open class HumanoidNPC(
|
||||
}
|
||||
|
||||
// we're having GameItem data so that this class could be somewhat universal
|
||||
override var itemData: GameItem = object : GameItem(referenceID) {//GameItem(referenceID ?: forceAssignRefID!!) {
|
||||
override var itemData: GameItem = object : GameItem("actor:"+referenceID) {//GameItem(referenceID ?: forceAssignRefID!!) {
|
||||
override val isUnique = true
|
||||
override var baseMass: Double
|
||||
get() = actorValue.getAsDouble(AVKey.BASEMASS)!!
|
||||
|
||||
@@ -77,12 +77,12 @@ interface Pocketed {
|
||||
}
|
||||
fun equipped(itemID: ItemID) = equipped(ItemCodex[itemID]!!)
|
||||
|
||||
fun addItem(itemID: Int, count: Int = 1) = inventory.add(ItemCodex[itemID]!!, count)
|
||||
fun addItem(itemID: ItemID, count: Int = 1) = inventory.add(ItemCodex[itemID]!!, count)
|
||||
fun addItem(item: GameItem, count: Int = 1) = inventory.add(item, count)
|
||||
fun removeItem(itemID: Int, count: Int = 1) = inventory.remove(ItemCodex[itemID]!!, count)
|
||||
fun removeItem(itemID: ItemID, count: Int = 1) = inventory.remove(ItemCodex[itemID]!!, count)
|
||||
fun removeItem(item: GameItem, count: Int = 1) = inventory.remove(item, count)
|
||||
|
||||
fun hasItem(item: GameItem) = inventory.contains(item.dynamicID)
|
||||
fun hasItem(id: Int) = inventory.contains(id)
|
||||
fun hasItem(id: ItemID) = inventory.contains(id)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user