From 43e16bf785d60ea7cd2f07a7c85752e890d55f67 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Fri, 1 Mar 2024 15:29:11 +0900 Subject: [PATCH] copper bulbs --- assets/mods/basegame/crafting/wires.json | 7 +++ assets/mods/basegame/items/itemid.csv | 1 + assets/mods/basegame/items/items.tga | 2 +- assets/mods/basegame/locales/en/items.json | 1 + assets/mods/basegame/locales/koKR/items.json | 1 + .../basegame/sprites/fixtures/copper_bulb.tga | 3 + .../sprites/fixtures/copper_bulb_emissive.tga | 3 + .../gameactors/FixtureSignalBulb.kt | 58 +++++++++++++++++++ .../gameitems/ItemSignalBulb.kt | 36 ++++++++++++ .../gameitems/ItemSignalSwitchManual.kt | 1 - work_files/graphics/items/basegame_items.kra | 4 +- .../graphics/sprites/fixtures/copper_bulb.kra | 3 + 12 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 assets/mods/basegame/sprites/fixtures/copper_bulb.tga create mode 100644 assets/mods/basegame/sprites/fixtures/copper_bulb_emissive.tga create mode 100644 src/net/torvald/terrarum/modulebasegame/gameactors/FixtureSignalBulb.kt create mode 100644 src/net/torvald/terrarum/modulebasegame/gameitems/ItemSignalBulb.kt create mode 100644 work_files/graphics/sprites/fixtures/copper_bulb.kra diff --git a/assets/mods/basegame/crafting/wires.json b/assets/mods/basegame/crafting/wires.json index b831a7855..27278c9f4 100644 --- a/assets/mods/basegame/crafting/wires.json +++ b/assets/mods/basegame/crafting/wires.json @@ -18,5 +18,12 @@ [10, 1, "item@basegame:112"], /* 1 copper */ [1, 1, "$SIGNALWIRE"] /* 1 other signal wire */ ] + }, + + "item@basegame:35": { /* copper bulb */ + "workbench": "basiccrafting", + "ingredients": [ + [2, 1, "item@basegame:112", 1, "item@basegame:113"] /* 1 copper, 1 iron */ + ] } } \ No newline at end of file diff --git a/assets/mods/basegame/items/itemid.csv b/assets/mods/basegame/items/itemid.csv index 40709ba18..5ff243235 100644 --- a/assets/mods/basegame/items/itemid.csv +++ b/assets/mods/basegame/items/itemid.csv @@ -33,6 +33,7 @@ id;classname;tags 32;net.torvald.terrarum.modulebasegame.gameitems.ItemCherryBomb;EXPLOSIVE,THROWABLE 33;net.torvald.terrarum.modulebasegame.gameitems.ItemTorch;FIXTURE,LIGHT 34;net.torvald.terrarum.modulebasegame.gameitems.ItemSignalSwitchManual;FIXTURE,SIGNAL +35;net.torvald.terrarum.modulebasegame.gameitems.ItemSignalBulb;FIXTURE,SIGNAL # ingots 26;net.torvald.terrarum.modulebasegame.gameitems.IngotSteel;INGOT diff --git a/assets/mods/basegame/items/items.tga b/assets/mods/basegame/items/items.tga index 5373420f4..7e0e5b5a8 100644 --- a/assets/mods/basegame/items/items.tga +++ b/assets/mods/basegame/items/items.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0e4b734e18388dcff87c3607a90668a9b05eedb05e08d72eb4724b973a8f22c7 +oid sha256:f71a997469ceccc9ecf7f9fcc2f497d4a2510cb220d5c2d8b6c52bd980ab42d8 size 2408466 diff --git a/assets/mods/basegame/locales/en/items.json b/assets/mods/basegame/locales/en/items.json index c29c2e207..56bd11d74 100644 --- a/assets/mods/basegame/locales/en/items.json +++ b/assets/mods/basegame/locales/en/items.json @@ -3,6 +3,7 @@ "ITEM_CHARCOAL": "Charcoal", "ITEM_CHERRY_BOMB": "Bomb", "ITEM_COAL_COKE": "Coal Coke", + "ITEM_COPPER_BULB": "Copper Bulb", "ITEM_DOOR_OAK": "Oak Door", "ITEM_DOOR_EBONY": "Ebony Door", "ITEM_DOOR_BIRCH": "Birch Door", diff --git a/assets/mods/basegame/locales/koKR/items.json b/assets/mods/basegame/locales/koKR/items.json index 81d8c5802..7a9bb5d02 100644 --- a/assets/mods/basegame/locales/koKR/items.json +++ b/assets/mods/basegame/locales/koKR/items.json @@ -3,6 +3,7 @@ "ITEM_CHARCOAL": "목탄", "ITEM_CHERRY_BOMB": "폭탄", "ITEM_COAL_COKE": "코크스", + "ITEM_COPPER_BULB": "구리 전구", "ITEM_DOOR_OAK": "나무 문", "ITEM_DOOR_EBONY": "흑단 문", "ITEM_DOOR_BIRCH": "백단 문", diff --git a/assets/mods/basegame/sprites/fixtures/copper_bulb.tga b/assets/mods/basegame/sprites/fixtures/copper_bulb.tga new file mode 100644 index 000000000..82a45d4d4 --- /dev/null +++ b/assets/mods/basegame/sprites/fixtures/copper_bulb.tga @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:befaa0fdf65e5d07543f262820e0a7204c7e38ebac785af6430a1e1827ef75e7 +size 2066 diff --git a/assets/mods/basegame/sprites/fixtures/copper_bulb_emissive.tga b/assets/mods/basegame/sprites/fixtures/copper_bulb_emissive.tga new file mode 100644 index 000000000..cfe16a3bc --- /dev/null +++ b/assets/mods/basegame/sprites/fixtures/copper_bulb_emissive.tga @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:abedacbbae73aec458ea066f67dcdaa5cc7dd30775ba10dfdd9be9c6717eea70 +size 2066 diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureSignalBulb.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureSignalBulb.kt new file mode 100644 index 000000000..f2431c2a0 --- /dev/null +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureSignalBulb.kt @@ -0,0 +1,58 @@ +package net.torvald.terrarum.modulebasegame.gameactors + +import net.torvald.spriteanimation.SheetSpriteAnimation +import net.torvald.terrarum.TerrarumAppConfiguration +import net.torvald.terrarum.gameactors.AVKey +import net.torvald.terrarum.langpack.Lang +import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase +import net.torvald.terrarum.toInt +import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack + +/** + * Created by minjaesong on 2024-03-01. + */ +class FixtureSignalBulb : Electric { + + @Transient override val spawnNeedsFloor = false + + constructor() : super( + BlockBox(BlockBox.NO_COLLISION, 1, 1), + nameFun = { Lang["ITEM_COPPER_BULB"] } + ) + + init { + val itemImage = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/copper_bulb.tga") + val itemImage2 = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/copper_bulb_emissive.tga") + + density = 1400.0 + setHitboxDimension(TerrarumAppConfiguration.TILE_SIZE, TerrarumAppConfiguration.TILE_SIZE, 0, 1) + + makeNewSprite(TextureRegionPack(itemImage.texture, TerrarumAppConfiguration.TILE_SIZE, TerrarumAppConfiguration.TILE_SIZE)).let { + it.setRowsAndFrames(2,1) + it.delays = floatArrayOf(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY) + } + + makeNewSpriteEmissive(TextureRegionPack(itemImage2.texture, TerrarumAppConfiguration.TILE_SIZE, TerrarumAppConfiguration.TILE_SIZE)).let { + it.setRowsAndFrames(2,1) + it.delays = floatArrayOf(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY) + } + + actorValue[AVKey.BASEMASS] = FixtureLogicSignalEmitter.MASS + + + setWireSinkAt(0, 0, "digital_bit") + } + + private fun light(state: Boolean) { + (sprite as SheetSpriteAnimation).currentRow = state.toInt() + (spriteEmissive as SheetSpriteAnimation).currentRow = state.toInt() + } + + override fun onSignalHigh(readFrom: BlockBoxIndex) { + light(true) + } + + override fun onSignalLow(readFrom: BlockBoxIndex) { + light(false) + } +} \ No newline at end of file diff --git a/src/net/torvald/terrarum/modulebasegame/gameitems/ItemSignalBulb.kt b/src/net/torvald/terrarum/modulebasegame/gameitems/ItemSignalBulb.kt new file mode 100644 index 000000000..fe8f7757a --- /dev/null +++ b/src/net/torvald/terrarum/modulebasegame/gameitems/ItemSignalBulb.kt @@ -0,0 +1,36 @@ +package net.torvald.terrarum.modulebasegame.gameitems + +import com.badlogic.gdx.graphics.g2d.TextureRegion +import net.torvald.terrarum.CommonResourcePool +import net.torvald.terrarum.Terrarum +import net.torvald.terrarum.gameactors.ActorWithBody +import net.torvald.terrarum.gameitems.ItemID +import net.torvald.terrarum.modulebasegame.TerrarumIngame +import net.torvald.terrarum.modulebasegame.gameactors.FixtureLogicSignalEmitter + +/** + * Created by minjaesong on 2024-03-01. + */ +class ItemSignalBulb(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureSignalBulb") { + + override var dynamicID: ItemID = originalID + override var baseMass = FixtureLogicSignalEmitter.MASS + override val canBeDynamic = false + override val materialId = "" + override val itemImage: TextureRegion + get() = CommonResourcePool.getAsItemSheet("basegame.items").get(9, 3) + + override var baseToolSize: Double? = baseMass + override var originalName = "ITEM_COPPER_BULB" + + override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) { + super.effectWhileEquipped(actor, delta) + (Terrarum.ingame!! as TerrarumIngame).selectedWireRenderClass = "signal" + } + + override fun effectOnUnequip(actor: ActorWithBody) { + super.effectOnUnequip(actor) + (Terrarum.ingame!! as TerrarumIngame).selectedWireRenderClass = "" + } + +} \ No newline at end of file diff --git a/src/net/torvald/terrarum/modulebasegame/gameitems/ItemSignalSwitchManual.kt b/src/net/torvald/terrarum/modulebasegame/gameitems/ItemSignalSwitchManual.kt index 4f2d30915..80b416c43 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameitems/ItemSignalSwitchManual.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameitems/ItemSignalSwitchManual.kt @@ -22,7 +22,6 @@ class ItemSignalSwitchManual(originalID: ItemID) : FixtureItemBase(originalID, " override var baseToolSize: Double? = baseMass override var originalName = "ITEM_LOGIC_SIGNAL_SWITCH" - override var inventoryCategory = Category.MISC override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) { super.effectWhileEquipped(actor, delta) diff --git a/work_files/graphics/items/basegame_items.kra b/work_files/graphics/items/basegame_items.kra index b23362d1d..3a66ad2da 100644 --- a/work_files/graphics/items/basegame_items.kra +++ b/work_files/graphics/items/basegame_items.kra @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ae02c2eda70f66a82c75dd7a7f505123cc77d3f9dd2dde4176f6454ed34e8562 -size 1377341 +oid sha256:bf1df5457025b68f8baca2d65ee9025b99953755d8a64db13fdd169dee72ae4b +size 1426611 diff --git a/work_files/graphics/sprites/fixtures/copper_bulb.kra b/work_files/graphics/sprites/fixtures/copper_bulb.kra new file mode 100644 index 000000000..9038c4cc3 --- /dev/null +++ b/work_files/graphics/sprites/fixtures/copper_bulb.kra @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8d5c989fce637a2dd878a0a33d725bafca2a76e9991b4c1bcac08661244aeab9 +size 316370