mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-06 08:38:30 +09:00
wrench
This commit is contained in:
@@ -61,5 +61,9 @@
|
||||
"item@basegame:9": { /* wire cutter */
|
||||
"workbench": "basiccrafting,metalworking",
|
||||
"ingredients": [[1, 1, "item@basegame:112", 1, "item@basegame:113"]] /* 1 copper ingot, 1 iron ingot */
|
||||
},
|
||||
"item@basegame:47": { /* wrench */
|
||||
"workbench": "basiccrafting,metalworking",
|
||||
"ingredients": [[1, 4, "item@basegame:113"]] /* 4 iron ingots */
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ id;classname;tags
|
||||
44;net.torvald.terrarum.modulebasegame.gameitems.ItemLogicSignalBlocker;FIXTURE,SIGNAL
|
||||
45;net.torvald.terrarum.modulebasegame.gameitems.ItemLogicSignalLatch;FIXTURE,SIGNAL
|
||||
46;net.torvald.terrarum.modulebasegame.gameitems.ItemLogicSignalRepeaterHorz;FIXTURE,SIGNAL
|
||||
47;net.torvald.terrarum.modulebasegame.gameitems.ItemWrench;TOOL,WRENCH
|
||||
|
||||
# ingots
|
||||
26;net.torvald.terrarum.modulebasegame.gameitems.IngotSteel;INGOT
|
||||
|
||||
|
Binary file not shown.
@@ -42,6 +42,7 @@
|
||||
"TOOLTIP_item@basegame:28": "A music vending machine (free to play)",
|
||||
"TOOLTIP_item@basegame:29": "A coal lookalike that burns just as well and is renewable",
|
||||
"TOOLTIP_item@basegame:36": "Creates wires from metal ingots",
|
||||
"TOOLTIP_item@basegame:47": "Reorients electronic components",
|
||||
|
||||
"TOOLTIP_item@basegame:114": "A precious fuel for the steel production",
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
"ITEM_WOODEN_MALLET": "Wooden Mallet",
|
||||
"ITEM_WORKBENCH": "Workbench",
|
||||
"ITEM_WORLD_PORTAL": "Teleportation Station",
|
||||
"ITEM_WRENCH": "Wrench",
|
||||
|
||||
"ACTORBLOCK_ALLOW_MOVE_DOWN": "Urist Arôlcustith",
|
||||
"ACTORBLOCK_FULL_COLLISION": "Urist Berdanrifot",
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
"TOOLTIP_item@basegame:28": "음악 자판기입이다 (무료 플레이)",
|
||||
"TOOLTIP_item@basegame:29": "석탄과 비슷하고 똑같이 잘 타지만 재생 가능합니다",
|
||||
"TOOLTIP_item@basegame:36": "금속 주괴를 사용해 철사를 뽑아냅니다",
|
||||
"TOOLTIP_item@basegame:47": "전자 장치의 방향을 바꿉니다",
|
||||
|
||||
"TOOLTIP_item@basegame:114": "강철 생산의 소중한 연료입니다",
|
||||
|
||||
@@ -51,5 +52,5 @@
|
||||
"TOOLTIP_item@basegame:35": "신호의 상태를 보여줍니다",
|
||||
"TOOLTIP_item@basegame:44": "지나가는 신호를 자르기 신호에 따라 자릅니다",
|
||||
"TOOLTIP_item@basegame:45": "들어오는 신호를 걸쇠 신호에 따라 잠시 저장합니다",
|
||||
"TOOLTIP_item@basegame:46": "들어오는 신호를 짧게 잠시 지연시킵니다"
|
||||
"TOOLTIP_item@basegame:46": "들어오는 신호를 살짝 지연시킵니다"
|
||||
}
|
||||
@@ -83,5 +83,6 @@
|
||||
"ITEM_WOOD_STICK": "막대기",
|
||||
"ITEM_WOODEN_MALLET": "나무 망치",
|
||||
"ITEM_WORKBENCH": "작업대",
|
||||
"ITEM_WORLD_PORTAL": "텔레포트 스테이션"
|
||||
"ITEM_WORLD_PORTAL": "텔레포트 스테이션",
|
||||
"ITEM_WRENCH": "렌치"
|
||||
}
|
||||
@@ -691,6 +691,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
|
||||
private var worldPrimaryClickLatch = false
|
||||
private var worldSecondaryClickLatch = false
|
||||
|
||||
private fun fireFixtureInteractEvent(fixture: FixtureBase, mwx: Double, mwy: Double) {
|
||||
if (fixture.mouseUp) {
|
||||
@@ -719,6 +720,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
// don't want to open the UI and use the item at the same time, would ya?
|
||||
if (itemOnGrip?.isConsumable == true) {
|
||||
// click filtering (latch stuff) is handled by IngameController (see inventoryCategoryAllowClickAndDrag)
|
||||
// To disable click dragging for tool/block/etc., put `override val disallowToolDragging = true` to the item's code
|
||||
val consumptionSuccessful = itemOnGrip.startPrimaryUse(actor, delta)
|
||||
if (consumptionSuccessful > -1)
|
||||
(actor as Pocketed).inventory.consumeItem(itemOnGrip, consumptionSuccessful)
|
||||
@@ -757,6 +759,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
// #3. If no fixture under mouse or FixtureInteractionBlocked, use the item
|
||||
else if (itemOnGrip != null) {
|
||||
// click filtering (latch stuff) is handled by IngameController (see inventoryCategoryAllowClickAndDrag)
|
||||
// To disable click dragging for tool/block/etc., put `override val disallowToolDragging = true` to the item's code
|
||||
val consumptionSuccessful = itemOnGrip.startPrimaryUse(actor, delta)
|
||||
if (consumptionSuccessful > -1)
|
||||
(actor as Pocketed).inventory.consumeItem(itemOnGrip, consumptionSuccessful)
|
||||
@@ -790,22 +793,25 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
override fun worldSecondaryClickStart(actor: ActorWithBody, delta: Float) {
|
||||
val itemOnGrip = ItemCodex[(actor as Pocketed).inventory.itemEquipped.get(GameItem.EquipPosition.HAND_GRIP)]
|
||||
|
||||
// #1. Perform item's secondaryUse
|
||||
// don't want to open the UI and use the item at the same time, would ya?
|
||||
val consumptionSuccessful = itemOnGrip?.startSecondaryUse(actor, delta) ?: -1
|
||||
if (consumptionSuccessful > -1)
|
||||
(actor as Pocketed).inventory.consumeItem(itemOnGrip!!, consumptionSuccessful)
|
||||
// #2. If #1 failed, try to pick up the fixture
|
||||
else {
|
||||
mouseInInteractableRange(actor) { mwx, mwy, mtx, mty ->
|
||||
pickupFixture(actor, delta, mwx, mwy, mtx, mty)
|
||||
0L
|
||||
if (!worldSecondaryClickLatch) {
|
||||
// #1. Perform item's secondaryUse
|
||||
val consumptionSuccessful = itemOnGrip?.startSecondaryUse(actor, delta) ?: -1
|
||||
if (consumptionSuccessful > -1)
|
||||
(actor as Pocketed).inventory.consumeItem(itemOnGrip!!, consumptionSuccessful)
|
||||
// #2. If #1 failed, try to pick up the fixture
|
||||
else {
|
||||
mouseInInteractableRange(actor) { mwx, mwy, mtx, mty ->
|
||||
pickupFixture(actor, delta, mwx, mwy, mtx, mty)
|
||||
0L
|
||||
}
|
||||
}
|
||||
|
||||
worldSecondaryClickLatch = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun worldSecondaryClickEnd(actor: ActorWithBody, delta: Float) {
|
||||
// println("Secondary click start!")
|
||||
worldSecondaryClickLatch = false
|
||||
}
|
||||
|
||||
|
||||
@@ -1673,7 +1679,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getActorsUnderMouse(mwx: Double, mwy: Double): List<ActorWithBody> {
|
||||
fun getActorsUnderMouse(mwx: Double, mwy: Double): List<ActorWithBody> {
|
||||
val actorsUnderMouse: List<ActorWithBody> = getActorsAt(mwx, mwy).filter { it !is InternalActor }.sortedBy {
|
||||
(mwx - it.hitbox.centeredX).sqr() + (mwy - it.hitbox.centeredY).sqr()
|
||||
} // sorted by the distance from the mouse
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.spriteanimation.SheetSpriteAnimation
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
|
||||
import net.torvald.terrarum.toInt
|
||||
@@ -70,17 +71,18 @@ class FixtureLogicSignalBlocker : Electric, Reorientable {
|
||||
}
|
||||
}
|
||||
|
||||
override fun orientClockwise() {
|
||||
orientation = (orientation + 1) % 4
|
||||
private fun reorient() {
|
||||
(sprite as SheetSpriteAnimation).currentFrame = orientation
|
||||
(spriteEmissive as SheetSpriteAnimation).currentFrame = orientation
|
||||
setEmitterAndSink(); updateK()
|
||||
}
|
||||
|
||||
override fun orientClockwise() {
|
||||
orientation = (orientation + 1) fmod 4
|
||||
reorient(); setEmitterAndSink(); updateK()
|
||||
}
|
||||
override fun orientAnticlockwise() {
|
||||
orientation = (orientation - 1) % 4
|
||||
(sprite as SheetSpriteAnimation).currentFrame = orientation
|
||||
(spriteEmissive as SheetSpriteAnimation).currentFrame = orientation
|
||||
setEmitterAndSink(); updateK()
|
||||
orientation = (orientation - 1) fmod 4
|
||||
reorient(); setEmitterAndSink(); updateK()
|
||||
}
|
||||
|
||||
init {
|
||||
@@ -104,6 +106,7 @@ class FixtureLogicSignalBlocker : Electric, Reorientable {
|
||||
|
||||
override fun reload() {
|
||||
super.reload()
|
||||
reorient()
|
||||
setEmitterAndSink()
|
||||
updateK()
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.spriteanimation.SheetSpriteAnimation
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
|
||||
import net.torvald.terrarum.toInt
|
||||
@@ -38,7 +39,7 @@ class FixtureLogicSignalLatch : Electric, Reorientable {
|
||||
2 -> {
|
||||
setWireSinkAt(1, 0, "digital_bit") // D
|
||||
setWireEmitterAt(0, 0, "digital_bit") // Q
|
||||
setWireSinkAt(1, 0, "digital_bit") // CLK
|
||||
setWireSinkAt(1, 1, "digital_bit") // CLK
|
||||
setWireSinkAt(1, 2, "digital_bit") // S
|
||||
setWireSinkAt(0, 2, "digital_bit") // R
|
||||
}
|
||||
@@ -46,18 +47,18 @@ class FixtureLogicSignalLatch : Electric, Reorientable {
|
||||
}
|
||||
}
|
||||
|
||||
private fun reorient() {
|
||||
(sprite as SheetSpriteAnimation).currentFrame = orientation / 2
|
||||
(spriteEmissive as SheetSpriteAnimation).currentFrame = orientation / 2
|
||||
}
|
||||
|
||||
override fun orientClockwise() {
|
||||
orientation = (orientation + 2) % 4
|
||||
(sprite as SheetSpriteAnimation).currentFrame = orientation / 2
|
||||
(spriteEmissive as SheetSpriteAnimation).currentFrame = orientation / 2
|
||||
setEmitterAndSink(); updateQ()
|
||||
orientation = (orientation + 2) fmod 4
|
||||
reorient(); setEmitterAndSink(); updateQ()
|
||||
}
|
||||
override fun orientAnticlockwise() {
|
||||
orientation = (orientation - 2) % 4
|
||||
(sprite as SheetSpriteAnimation).currentFrame = orientation / 2
|
||||
(spriteEmissive as SheetSpriteAnimation).currentFrame = orientation / 2
|
||||
setEmitterAndSink(); updateQ()
|
||||
orientation = (orientation - 2) fmod 4
|
||||
reorient(); setEmitterAndSink(); updateQ()
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +83,7 @@ class FixtureLogicSignalLatch : Electric, Reorientable {
|
||||
|
||||
override fun reload() {
|
||||
super.reload()
|
||||
reorient()
|
||||
setEmitterAndSink()
|
||||
updateQ()
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
import net.torvald.spriteanimation.SheetSpriteAnimation
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
|
||||
import net.torvald.terrarum.toInt
|
||||
@@ -40,18 +41,18 @@ class FixtureLogicSignalRepeaterHorz : Electric, Reorientable {
|
||||
}
|
||||
}
|
||||
|
||||
private fun reorient() {
|
||||
(sprite as SheetSpriteAnimation).currentFrame = orientation / 2
|
||||
(spriteEmissive as SheetSpriteAnimation).currentFrame = orientation / 2
|
||||
}
|
||||
|
||||
override fun orientClockwise() {
|
||||
orientation = (orientation + 2) % 4
|
||||
(sprite as SheetSpriteAnimation).currentFrame = orientation / 2
|
||||
(spriteEmissive as SheetSpriteAnimation).currentFrame = orientation / 2
|
||||
setEmitterAndSink(); updateQ()
|
||||
orientation = (orientation + 2) fmod 4
|
||||
reorient(); setEmitterAndSink(); updateQ()
|
||||
}
|
||||
override fun orientAnticlockwise() {
|
||||
orientation = (orientation - 2) % 4
|
||||
(sprite as SheetSpriteAnimation).currentFrame = orientation / 2
|
||||
(spriteEmissive as SheetSpriteAnimation).currentFrame = orientation / 2
|
||||
setEmitterAndSink(); updateQ()
|
||||
orientation = (orientation - 2) fmod 4
|
||||
reorient(); setEmitterAndSink(); updateQ()
|
||||
}
|
||||
|
||||
init {
|
||||
@@ -76,6 +77,7 @@ class FixtureLogicSignalRepeaterHorz : Electric, Reorientable {
|
||||
|
||||
override fun reload() {
|
||||
super.reload()
|
||||
reorient()
|
||||
setEmitterAndSink()
|
||||
updateQ()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.INGAME
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameitems.FixtureInteractionBlocked
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarum.gameitems.mouseInInteractableRange
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.Reorientable
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2024-03-08.
|
||||
*/
|
||||
class ItemWrench(originalID: ItemID) : GameItem(originalID), FixtureInteractionBlocked {
|
||||
|
||||
override val disallowToolDragging = true
|
||||
override var dynamicID: ItemID = originalID
|
||||
override var baseMass = 0.1
|
||||
override var baseToolSize: Double? = baseMass
|
||||
override var inventoryCategory = Category.TOOL
|
||||
override val canBeDynamic = false
|
||||
override val materialId = "STAL" // this is to just increase the reach
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(5, 2)
|
||||
|
||||
init {
|
||||
stackable = false
|
||||
isUnique = true
|
||||
equipPosition = GameItem.EquipPosition.HAND_GRIP
|
||||
originalName = "ITEM_WRENCH"
|
||||
}
|
||||
|
||||
override fun startPrimaryUse(actor: ActorWithBody, delta: Float) = mouseInInteractableRange(actor) { mwx, mwy, mtx, mty ->
|
||||
(INGAME as TerrarumIngame).getActorsUnderMouse(mwx, mwy).filterIsInstance<Reorientable>().firstOrNull()?.let { fixture ->
|
||||
fixture.orientClockwise()
|
||||
0L
|
||||
} ?: -1L
|
||||
}
|
||||
|
||||
override fun startSecondaryUse(actor: ActorWithBody, delta: Float) = mouseInInteractableRange(actor) { mwx, mwy, mtx, mty ->
|
||||
(INGAME as TerrarumIngame).getActorsUnderMouse(mwx, mwy).filterIsInstance<Reorientable>().firstOrNull()?.let { fixture ->
|
||||
fixture.orientAnticlockwise()
|
||||
0L
|
||||
} ?: -1L
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user