mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
item and sprite for 'document' type items
This commit is contained in:
@@ -9,6 +9,7 @@ import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.FileRefItemPrimaryUseHandler
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.ItemFileRef
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.ItemPlainDocument
|
||||
import net.torvald.terrarum.serialise.Common
|
||||
import java.util.*
|
||||
import kotlin.math.roundToInt
|
||||
@@ -40,7 +41,7 @@ class FixtureTypewriter : FixtureBase {
|
||||
setHitboxDimension(16, 16, 8, 0)
|
||||
|
||||
makeNewSprite(FixtureBase.getSpritesheet("basegame", "sprites/fixtures/typewriter.tga", 32, 16)).let {
|
||||
it.setRowsAndFrames(1,1)
|
||||
it.setRowsAndFrames(12,1)
|
||||
}
|
||||
|
||||
actorValue[AVKey.BASEMASS] = 3.6
|
||||
@@ -49,7 +50,7 @@ class FixtureTypewriter : FixtureBase {
|
||||
override fun updateImpl(delta: Float) {
|
||||
super.updateImpl(delta)
|
||||
|
||||
//(sprite as SheetSpriteAnimation).currentRow = 1 + (carriagePosition.toFloat() / TYPEWRITER_COLUMNS * 10).roundToInt()
|
||||
(sprite as SheetSpriteAnimation).currentRow = 1 + (carriagePosition.toFloat() / TYPEWRITER_COLUMNS * 10).roundToInt()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@@ -73,16 +74,18 @@ class FixtureTypewriter : FixtureBase {
|
||||
|
||||
// DON'T create an anonymous class here: they won't be serialised
|
||||
INGAME.actorNowPlaying?.inventory?.let { inventory ->
|
||||
val newItem = ItemFileRef("item@basegame:33536").makeDynamic(inventory).also { it0 ->
|
||||
val newItem = ItemPlainDocument("item@basegame:33536").makeDynamic(inventory).also { it0 ->
|
||||
val it = it0 as ItemFileRef
|
||||
|
||||
it.refIsShared = true
|
||||
it.uuid = newUUID
|
||||
if (INGAME.actorNowPlaying is IngamePlayer)
|
||||
it.authorUUID = (INGAME.actorNowPlaying as IngamePlayer).uuid
|
||||
it.refPath = newUUID.toString()
|
||||
it.mediumIdentifier = "text/typewriter"
|
||||
it.useItemHandler = "net.torvald.terrarum.modulebasegame.gameactors.TestLeafletPrimaryUseHandler"
|
||||
it.name = "Testification"
|
||||
it.author = "Author Name Here"
|
||||
it.author = INGAME.actorNowPlaying?.actorValue?.getAsString(AVKey.NAME) ?: ""
|
||||
}
|
||||
|
||||
inventory.add(newItem)
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
@@ -24,6 +25,7 @@ open class ItemFileRef(originalID: ItemID) : GameItem(originalID) {
|
||||
var collection = ""
|
||||
|
||||
open var uuid: UUID = UUID(0, 0)
|
||||
open var authorUUID: UUID = UUID(0, 0)
|
||||
|
||||
/**
|
||||
* String of path within the module (if not refIsShared), or path under savedir/Shared/
|
||||
@@ -127,4 +129,32 @@ interface FileRefItemPrimaryUseHandler {
|
||||
/** If this item must be consumed, return 1; if this item must not be consumed, return 0; if this item
|
||||
* was failed to be used (for some reason), return -1. */
|
||||
fun use(item: ItemFileRef): Long
|
||||
}
|
||||
|
||||
class ItemPlainDocument(originalID: ItemID) : ItemFileRef(originalID) {
|
||||
private constructor() : this("")
|
||||
init {
|
||||
itemImage = CommonResourcePool.getAsItemSheet("basegame.items").get(2,14)
|
||||
}
|
||||
}
|
||||
|
||||
class ItemUnsealedLetter(originalID: ItemID) : ItemFileRef(originalID) {
|
||||
private constructor() : this("")
|
||||
init {
|
||||
itemImage = CommonResourcePool.getAsItemSheet("basegame.items").get(3,14)
|
||||
}
|
||||
}
|
||||
|
||||
class ItemSealedLetter(originalID: ItemID) : ItemFileRef(originalID) {
|
||||
private constructor() : this("")
|
||||
init {
|
||||
itemImage = CommonResourcePool.getAsItemSheet("basegame.items").get(4,14)
|
||||
}
|
||||
}
|
||||
|
||||
class ItemPostParcel(originalID: ItemID) : ItemFileRef(originalID) {
|
||||
private constructor() : this("")
|
||||
init {
|
||||
itemImage = CommonResourcePool.getAsItemSheet("basegame.items").get(5,14)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user