From 75249bc44b75af6610580c7a534311fa0e758ef1 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Thu, 10 Oct 2024 02:58:35 +0900 Subject: [PATCH] wrench axle wip --- assets/mods/basegame/locales/en/game.json | 1 + assets/mods/basegame/locales/en/itemdesc.json | 5 +-- .../torvald/terrarum/gameactors/WireActor.kt | 6 ++-- .../modulebasegame/gameitems/ItemWrench.kt | 31 +++++++++++++++++++ 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/assets/mods/basegame/locales/en/game.json b/assets/mods/basegame/locales/en/game.json index c854588ed..addf265c2 100644 --- a/assets/mods/basegame/locales/en/game.json +++ b/assets/mods/basegame/locales/en/game.json @@ -15,6 +15,7 @@ "MENU_LABEL_USE_CODE": "Use Code", "MENU_MODE_BUILDINGMAKER": "POI Editor", "MENU_UPDATE_UPDATE_AVAILABLE": "Update Available!", + "GAME_ACTION_DISMANTLE": "Dismantle", "GAME_ACTION_GRAPPLE": "Grapple", "GAME_ACTION_QUICKSEL": "Quick Select", "GAME_ACTION_SELECT_SLOT": "Select Slot", diff --git a/assets/mods/basegame/locales/en/itemdesc.json b/assets/mods/basegame/locales/en/itemdesc.json index 27d9a3fa5..e31022a21 100644 --- a/assets/mods/basegame/locales/en/itemdesc.json +++ b/assets/mods/basegame/locales/en/itemdesc.json @@ -1,5 +1,5 @@ { - "TOOLTIP_basegame:256": "Provides stable light", + "TOOLTIP_basegame:256": "Provides a stable light", "TOOLTIP_basegame:257": "Provides a light equal to the sun", /* it literally does -- provides the sunlight of the exact hour (emits "moonlight" at night time) */ "TOOLTIP_basegame:258": "Provides a light equal to the sun at noon", @@ -11,6 +11,7 @@ "TOOLTIP_wire@basegame:1": "Carries power", "TOOLTIP_wire@basegame:2": "Carries power", "TOOLTIP_wire@basegame:16": "Carries information", + "TOOLTIP_wire@basegame:256": "Carries rotational force", "TOOLTIP_item@basegame:1": "Breaks rocks", "TOOLTIP_item@basegame:2": "Breaks rocks", @@ -44,7 +45,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 gadgets", + "TOOLTIP_item@basegame:47": "Reorients gadgets and axles", "TOOLTIP_item@basegame:48": "Melts two metal ingots to make a bar of alloy", "TOOLTIP_item@basegame:50": "Use it on the Electronics Workbench", diff --git a/src/net/torvald/terrarum/gameactors/WireActor.kt b/src/net/torvald/terrarum/gameactors/WireActor.kt index 2f3bd2743..a7c98f870 100644 --- a/src/net/torvald/terrarum/gameactors/WireActor.kt +++ b/src/net/torvald/terrarum/gameactors/WireActor.kt @@ -34,9 +34,9 @@ class WireActor : ActorWithBody, NoSerialise, InternalActor { setHitboxDimension(TILE_SIZE, TILE_SIZE, 0, 0) } - private var wireID = "" - private var worldX = 0 - private var worldY = 0 + var wireID = ""; private set + var worldX = 0; private set + var worldY = 0; private set /** * @param itemID must start with "wire@" diff --git a/src/net/torvald/terrarum/modulebasegame/gameitems/ItemWrench.kt b/src/net/torvald/terrarum/modulebasegame/gameitems/ItemWrench.kt index 7697549c0..69ea50848 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameitems/ItemWrench.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameitems/ItemWrench.kt @@ -1,22 +1,34 @@ package net.torvald.terrarum.modulebasegame.gameitems import com.badlogic.gdx.graphics.g2d.TextureRegion +import net.torvald.terrarum.App 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.gameactors.WireActor 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.langpack.Lang import net.torvald.terrarum.modulebasegame.TerrarumIngame import net.torvald.terrarum.modulebasegame.gameactors.Reorientable +import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes.tooltipShowing +import net.torvald.unicode.getMouseButton /** * Created by minjaesong on 2024-03-08. */ class ItemWrench(originalID: ItemID) : GameItem(originalID), FixtureInteractionBlocked { + companion object { + private val tooltipHash = 10003L + private val SP = "\u3000" + private val ML = getMouseButton(App.getConfigInt("config_mouseprimary")) + private val MR = getMouseButton(App.getConfigInt("config_mousesecondary")) + } + override val disallowToolDragging = true override var dynamicID: ItemID = originalID override var baseMass = 0.1 @@ -35,6 +47,25 @@ class ItemWrench(originalID: ItemID) : GameItem(originalID), FixtureInteractionB originalName = "ITEM_WRENCH" } + override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) { + // flipping 'eck this was annoying + /*var q = -1L + q = mouseInInteractableRange(actor) { mwx, mwy, mtx, mty -> + (INGAME as TerrarumIngame).world.getWireGraphOf(mtx, mty, "wire@basegame:256").let { cnx -> + if (cnx != null) { + INGAME.setTooltipMessage("$ML ${Lang["GAME_ACTION_DISMANTLE"]}\n$MR ${Lang["MENU_CONTROLS_ROTATE"]}") + tooltipShowing[tooltipHash] = true + } + else { + tooltipShowing[tooltipHash] = false + } + } + 0L + } + if (q == -1L) + tooltipShowing[tooltipHash] = false*/ + } + override fun startPrimaryUse(actor: ActorWithBody, delta: Float) = mouseInInteractableRange(actor) { mwx, mwy, mtx, mty -> (INGAME as TerrarumIngame).getActorsUnderMouse(mwx, mwy).filterIsInstance().firstOrNull()?.let { fixture -> fixture.orientClockwise()