mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 03:24:06 +09:00
new inventory category 'fixtures'; fixture code refactoring
This commit is contained in:
@@ -107,8 +107,7 @@ class EntryPoint : ModuleEntryPoint() {
|
||||
// }
|
||||
|
||||
init {
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
tags.addAll(tile.tags)
|
||||
tags.addAll(tile.tags)
|
||||
originalName =
|
||||
if (isWall && tags.contains("UNLIT")) "${tile.nameKey}>>=BLOCK_UNLIT_TEMPLATE>>=BLOCK_WALL_NAME_TEMPLATE"
|
||||
else if (isWall) "${tile.nameKey}>>=BLOCK_WALL_NAME_TEMPLATE"
|
||||
|
||||
@@ -39,10 +39,13 @@ open class FixtureItemBase(originalID: ItemID, val fixtureClassName: String) : G
|
||||
@Transient private var ghostInit = AtomicBoolean(false)
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override var baseMass = 1.0
|
||||
override var inventoryCategory = Category.MISC
|
||||
@Transient override var baseMass = 1.0
|
||||
@Transient override var inventoryCategory = Category.FIXTURE
|
||||
override val isDynamic = false
|
||||
override val materialId = ""
|
||||
@Transient override val materialId = ""
|
||||
|
||||
@Transient override var equipPosition: Int = EquipPosition.HAND_GRIP
|
||||
|
||||
|
||||
/**
|
||||
* Do not address the CommonResourcePool directly; just do it like this snippet:
|
||||
|
||||
@@ -12,18 +12,13 @@ class ItemLogicSignalEmitter(originalID: ItemID) : FixtureItemBase(originalID, "
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override var baseMass = FixtureLogicSignalEmitter.MASS
|
||||
override var inventoryCategory = Category.MISC
|
||||
override val isDynamic = false
|
||||
override val materialId = ""
|
||||
override val itemImage: TextureRegion
|
||||
get() = getItemImageFromSingleImage("basegame", "sprites/fixtures/signal_source.tga")
|
||||
|
||||
override var baseToolSize: Double? = baseMass
|
||||
|
||||
init {
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
originalName = "ITEM_LOGIC_SIGNAL_EMITTER"
|
||||
}
|
||||
override var originalName = "ITEM_LOGIC_SIGNAL_EMITTER"
|
||||
|
||||
override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) {
|
||||
super.effectWhileEquipped(actor, delta)
|
||||
|
||||
@@ -14,16 +14,11 @@ class ItemStorageChest(originalID: ItemID) : FixtureItemBase(originalID, "net.to
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override var baseMass = FixtureTikiTorch.MASS
|
||||
override var inventoryCategory = Category.MISC
|
||||
override val isDynamic = false
|
||||
override val materialId = ""
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_48")
|
||||
override var baseToolSize: Double? = baseMass
|
||||
|
||||
init {
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
originalName = "ITEM_STORAGE_CHEST"
|
||||
}
|
||||
override var originalName = "ITEM_STORAGE_CHEST"
|
||||
|
||||
}
|
||||
@@ -14,22 +14,12 @@ class ItemSwingingDoorOak(originalID: ItemID) :
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override var baseMass = 20.0 // 360[L] * 0.1 * 0.56[SpecificGravity], rounded to the nearest integer
|
||||
override var inventoryCategory = Category.MISC
|
||||
override val isDynamic = false
|
||||
override val materialId = ""
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(8,3)
|
||||
override var baseToolSize: Double? = baseMass
|
||||
|
||||
init {
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
originalName = "ITEM_DOOR_OAK"
|
||||
}
|
||||
|
||||
@Transient override val makeFixture: () -> FixtureBase = {
|
||||
FixtureSwingingDoorOak()
|
||||
}
|
||||
|
||||
override var originalName = "ITEM_DOOR_OAK"
|
||||
}
|
||||
|
||||
class ItemSwingingDoorEbony(originalID: ItemID) :
|
||||
@@ -37,22 +27,12 @@ class ItemSwingingDoorEbony(originalID: ItemID) :
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override var baseMass = 30.0 // 360[L] * 0.1 * 0.82[SpecificGravity], rounded to the nearest integer
|
||||
override var inventoryCategory = Category.MISC
|
||||
override val isDynamic = false
|
||||
override val materialId = ""
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(9,3)
|
||||
override var baseToolSize: Double? = baseMass
|
||||
|
||||
init {
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
originalName = "ITEM_DOOR_EBONY"
|
||||
}
|
||||
|
||||
@Transient override val makeFixture: () -> FixtureBase = {
|
||||
FixtureSwingingDoorEbony()
|
||||
}
|
||||
|
||||
override var originalName = "ITEM_DOOR_EBONY"
|
||||
}
|
||||
|
||||
class ItemSwingingDoorBirch(originalID: ItemID) :
|
||||
@@ -60,22 +40,12 @@ class ItemSwingingDoorBirch(originalID: ItemID) :
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override var baseMass = 17.0 // 360[L] * 0.1 * 0.48[SpecificGravity], rounded to the nearest integer
|
||||
override var inventoryCategory = Category.MISC
|
||||
override val isDynamic = false
|
||||
override val materialId = ""
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(10,3)
|
||||
override var baseToolSize: Double? = baseMass
|
||||
|
||||
init {
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
originalName = "ITEM_DOOR_BIRCH"
|
||||
}
|
||||
|
||||
@Transient override val makeFixture: () -> FixtureBase = {
|
||||
FixtureSwingingDoorBirch()
|
||||
}
|
||||
|
||||
override var originalName = "ITEM_DOOR_BIRCH"
|
||||
}
|
||||
|
||||
class ItemSwingingDoorRosewood(originalID: ItemID) :
|
||||
@@ -83,20 +53,10 @@ class ItemSwingingDoorRosewood(originalID: ItemID) :
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override var baseMass = 24.0 // 360[L] * 0.1 * 0.68[SpecificGravity], rounded to the nearest integer
|
||||
override var inventoryCategory = Category.MISC
|
||||
override val isDynamic = false
|
||||
override val materialId = ""
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(11,3)
|
||||
override var baseToolSize: Double? = baseMass
|
||||
|
||||
init {
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
originalName = "ITEM_DOOR_ROSEWOOD"
|
||||
}
|
||||
|
||||
@Transient override val makeFixture: () -> FixtureBase = {
|
||||
FixtureSwingingDoorRosewood()
|
||||
}
|
||||
|
||||
override var originalName = "ITEM_DOOR_ROSEWOOD"
|
||||
}
|
||||
|
||||
@@ -16,17 +16,12 @@ class ItemTapestry(originalID: ItemID) : FixtureItemBase(originalID, "net.torval
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override var baseMass = 6.0
|
||||
override var inventoryCategory = Category.MISC
|
||||
override val isDynamic = false
|
||||
override val materialId = ""
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_16")
|
||||
override var baseToolSize: Double? = baseMass
|
||||
|
||||
init {
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
originalName = "ITEM_TAPESTRY"
|
||||
}
|
||||
override var originalName = "ITEM_TAPESTRY"
|
||||
|
||||
@Transient override val makeFixture: () -> FixtureBase = {
|
||||
FixtureTapestry(
|
||||
|
||||
@@ -12,17 +12,12 @@ class ItemTikiTorch(originalID: ItemID) : FixtureItemBase(originalID, "net.torva
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override var baseMass = FixtureTikiTorch.MASS
|
||||
override var inventoryCategory = Category.MISC
|
||||
override val isDynamic = false
|
||||
override val materialId = ""
|
||||
override val itemImage: TextureRegion
|
||||
get() = getItemImageFromSheet("basegame", "sprites/fixtures/tiki_torch.tga", 16, 32)
|
||||
|
||||
override var baseToolSize: Double? = baseMass
|
||||
|
||||
init {
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
originalName = "ITEM_TIKI_TORCH"
|
||||
}
|
||||
override var originalName = "ITEM_TIKI_TORCH"
|
||||
|
||||
}
|
||||
@@ -12,17 +12,12 @@ class ItemTypewriter(originalID: ItemID) : FixtureItemBase(originalID, "net.torv
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override var baseMass = FixtureTikiTorch.MASS
|
||||
override var inventoryCategory = Category.MISC
|
||||
override val isDynamic = false
|
||||
override val materialId = ""
|
||||
override val itemImage: TextureRegion
|
||||
get() = getItemImageFromSheet("basegame", "sprites/fixtures/typewriter.tga", 32, 16)
|
||||
|
||||
override var baseToolSize: Double? = baseMass
|
||||
|
||||
init {
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
originalName = "ITEM_TYPEWRITER"
|
||||
}
|
||||
override var originalName = "ITEM_TYPEWRITER"
|
||||
|
||||
}
|
||||
@@ -11,17 +11,12 @@ class ItemWallCalendar(originalID: ItemID) : FixtureItemBase(originalID, "net.to
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override var baseMass = 1.0
|
||||
override var inventoryCategory = Category.MISC
|
||||
override val isDynamic = false
|
||||
override val materialId = ""
|
||||
override val itemImage: TextureRegion
|
||||
get() = getItemImageFromSingleImage("basegame", "sprites/fixtures/calendar.tga")
|
||||
|
||||
override var baseToolSize: Double? = baseMass
|
||||
|
||||
init {
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
originalName = "ITEM_CALENDAR"
|
||||
}
|
||||
override var originalName = "ITEM_CALENDAR"
|
||||
|
||||
}
|
||||
@@ -10,18 +10,12 @@ class ItemWorkbench(originalID: ItemID) : FixtureItemBase(originalID, "net.torva
|
||||
|
||||
|
||||
override var baseMass = 20.0
|
||||
override var inventoryCategory = Category.MISC
|
||||
override val isDynamic = false
|
||||
override val materialId = ""
|
||||
override val itemImage: TextureRegion
|
||||
get() = getItemImageFromSingleImage("basegame", "sprites/fixtures/workbench.tga")
|
||||
|
||||
override var baseToolSize: Double? = baseMass
|
||||
|
||||
init {
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
originalName = "ITEM_WORKBENCH"
|
||||
}
|
||||
|
||||
override var originalName = "ITEM_WORKBENCH"
|
||||
|
||||
}
|
||||
@@ -12,17 +12,11 @@ class ItemWorldPortal(originalID: ItemID) : FixtureItemBase(originalID, "net.tor
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override var baseMass = 6000.0
|
||||
override var inventoryCategory = Category.MISC
|
||||
override val isDynamic = false
|
||||
override val materialId = ""
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(3,3)
|
||||
|
||||
override var baseToolSize: Double? = baseMass
|
||||
|
||||
init {
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
originalName = "ITEM_WORLD_PORTAL"
|
||||
}
|
||||
|
||||
override var originalName = "ITEM_WORLD_PORTAL"
|
||||
}
|
||||
@@ -72,7 +72,7 @@ internal class UIInventoryCells(
|
||||
fun rebuildList() {
|
||||
// App.printdbg(this, "rebuilding list")
|
||||
|
||||
itemList.rebuild(full.catBar.catIconsMeaning[full.catBar.selectedIcon])
|
||||
itemList.rebuild(full.catBar.catIconsMeaning[full.catBar.selectedIndex])
|
||||
equipped.rebuild()
|
||||
|
||||
encumbrancePerc = full.actor.inventory.encumberment.toFloat()
|
||||
@@ -81,7 +81,7 @@ internal class UIInventoryCells(
|
||||
|
||||
fun resetStatusAsCatChanges(oldcat: Int?, newcat: Int) {
|
||||
itemList.itemPage = 0 // set scroll to zero
|
||||
itemList.rebuild(full.catBar.catIconsMeaning[full.catBar.catArrangement[newcat]]) // have to manually rebuild, too!
|
||||
itemList.rebuild(full.catBar.catIconsMeaning[newcat]) // have to manually rebuild, too!
|
||||
}
|
||||
|
||||
override fun updateUI(delta: Float) {
|
||||
|
||||
@@ -176,6 +176,7 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
|
||||
|
||||
val ingame = TerrarumIngame(App.batch)
|
||||
val playerDisk = existingPlayer ?: App.savegamePlayers[UILoadGovernor.playerUUID]!!.loadable()
|
||||
playerDisk.rebuild()
|
||||
val player = ReadActor.invoke(
|
||||
playerDisk,
|
||||
ByteArray64Reader(playerDisk.getFile(SAVEGAMEINFO)!!.bytes, Common.CHARSET)
|
||||
|
||||
@@ -131,8 +131,8 @@ internal class UIStorageChest : UICanvas(
|
||||
}
|
||||
|
||||
private fun itemListUpdate() {
|
||||
itemListChest.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
|
||||
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
|
||||
itemListChest.rebuild(catBar.catIconsMeaning[catBar.selectedIndex])
|
||||
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIndex])
|
||||
|
||||
encumbrancePerc = getPlayerInventory().capacity.toFloat() / getPlayerInventory().maxCapacity
|
||||
isEncumbered = getPlayerInventory().isEncumbered
|
||||
@@ -143,13 +143,13 @@ internal class UIStorageChest : UICanvas(
|
||||
itemListChest.navRemoCon.gridModeButtons[0].highlighted = !yes
|
||||
itemListChest.navRemoCon.gridModeButtons[1].highlighted = yes
|
||||
itemListChest.itemPage = 0
|
||||
itemListChest.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
|
||||
itemListChest.rebuild(catBar.catIconsMeaning[catBar.selectedIndex])
|
||||
|
||||
itemListPlayer.isCompactMode = yes
|
||||
itemListPlayer.navRemoCon.gridModeButtons[0].highlighted = !yes
|
||||
itemListPlayer.navRemoCon.gridModeButtons[1].highlighted = yes
|
||||
itemListPlayer.itemPage = 0
|
||||
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
|
||||
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIndex])
|
||||
|
||||
itemListUpdate()
|
||||
}
|
||||
|
||||
@@ -123,8 +123,8 @@ class UIWorldPortalCargo(val full: UIWorldPortal) : UICanvas(), HasInventory {
|
||||
}
|
||||
|
||||
private fun itemListUpdate() {
|
||||
itemListChest.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
|
||||
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
|
||||
itemListChest.rebuild(catBar.catIconsMeaning[catBar.selectedIndex])
|
||||
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIndex])
|
||||
|
||||
encumbrancePerc = getPlayerInventory().capacity.toFloat() / getPlayerInventory().maxCapacity
|
||||
isEncumbered = getPlayerInventory().isEncumbered
|
||||
@@ -135,13 +135,13 @@ class UIWorldPortalCargo(val full: UIWorldPortal) : UICanvas(), HasInventory {
|
||||
itemListChest.navRemoCon.gridModeButtons[0].highlighted = !yes
|
||||
itemListChest.navRemoCon.gridModeButtons[1].highlighted = yes
|
||||
itemListChest.itemPage = 0
|
||||
itemListChest.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
|
||||
itemListChest.rebuild(catBar.catIconsMeaning[catBar.selectedIndex])
|
||||
|
||||
itemListPlayer.isCompactMode = yes
|
||||
itemListPlayer.navRemoCon.gridModeButtons[0].highlighted = !yes
|
||||
itemListPlayer.navRemoCon.gridModeButtons[1].highlighted = yes
|
||||
itemListPlayer.itemPage = 0
|
||||
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
|
||||
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIndex])
|
||||
|
||||
itemListUpdate()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user