mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
pickaxe ore tooltip; working item pickup and throw effects
This commit is contained in:
@@ -1 +1,2 @@
|
||||
gameplay_max_crafting->Lang:MENU_OPTIONS_MAX_CRAFTING->spinner,100,1000,100
|
||||
showpickaxetooltip->Lang:MENU_OPTIONS_SHOW_ORES_TOOLTIP_WHEN_MINING->toggle
|
||||
|
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"gameplay_max_crafting": 100
|
||||
"gameplay_max_crafting": 100,
|
||||
"showpickaxetooltip": true
|
||||
}
|
||||
@@ -14,6 +14,8 @@
|
||||
"MENU_LABEL_USE_CODE": "Use Code",
|
||||
"MENU_MODE_BUILDINGMAKER": "POI Editor",
|
||||
"MENU_MONITOR_CALI_TITLE": "Check Monitor",
|
||||
"MENU_OPTIONS_SHOW_ORES_TOOLTIP_WHEN_MINING": "Show Ores Tooltip When Mining",
|
||||
"MENU_OPTIONS_MAX_CRAFTING": "Max Number of Items For Crafting",
|
||||
"MENU_UPDATE_UPDATE_AVAILABLE": "Update Available!",
|
||||
"GAME_ACTION_GRAPPLE": "Grapple",
|
||||
"GAME_ACTION_QUICKSEL": "Quick Select",
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
"MENU_LABEL_RENAME": "이름 바꾸기",
|
||||
"MENU_LABEL_USE_CODE": "코드 사용",
|
||||
"MENU_MONITOR_CALI_TITLE": "모니터 확인",
|
||||
"MENU_OPTIONS_SHOW_ORES_TOOLTIP_WHEN_MINING": "채굴 시 광석 툴팁 보이기",
|
||||
"MENU_OPTIONS_MAX_CRAFTING": "한번에 제작할 최대 아이템 수",
|
||||
"MENU_UPDATE_UPDATE_AVAILABLE": "새 업데이트가 있습니다!",
|
||||
"GAME_ACTION_GRAPPLE": "매달리기",
|
||||
"GAME_ACTION_QUICKSEL": "빠른 선택",
|
||||
|
||||
@@ -158,4 +158,11 @@ object AVKey {
|
||||
* This value is only used for IngamePlayers
|
||||
*/
|
||||
const val GAMEMODE = "gamemode"
|
||||
|
||||
/** String
|
||||
* Comma-separated ItemIDs for the item the ore drops (`item@basegame:128` instead of `ores@basegame:1`)
|
||||
*
|
||||
* When the player gets the ore item, its itemID is appended to this actorvalue.
|
||||
*/
|
||||
const val ORE_DICT = "oredict"
|
||||
}
|
||||
@@ -198,6 +198,8 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
|
||||
).let { drop ->
|
||||
INGAME.queueActorAddition(drop)
|
||||
}
|
||||
// apply item effect
|
||||
ItemCodex[item]!!.effectOnThrow(player)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
||||
/**
|
||||
* Effects applied immediately only once when picked up
|
||||
*/
|
||||
open fun effectOnPickup(actor: ActorWithBody, delta: Float) { }
|
||||
open fun effectOnPickup(actor: ActorWithBody) { }
|
||||
|
||||
/**
|
||||
* Apply effects (continuously or not) while primary button is down.
|
||||
@@ -249,7 +249,7 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
||||
/**
|
||||
* Effects applied immediately only once when thrown (discarded) from pocket
|
||||
*/
|
||||
open fun effectOnThrow(actor: ActorWithBody, delta: Float) { }
|
||||
open fun effectOnThrow(actor: ActorWithBody) { }
|
||||
|
||||
/**
|
||||
* Effects applied (continuously or not) while being equipped (drawn/pulled out)
|
||||
@@ -259,7 +259,7 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
||||
/**
|
||||
* Effects applied only once when unequipped
|
||||
*/
|
||||
open fun effectOnUnequip(actor: ActorWithBody, delta: Float) { }
|
||||
open fun effectOnUnequip(actor: ActorWithBody) { }
|
||||
|
||||
|
||||
override fun toString(): String {
|
||||
|
||||
@@ -151,6 +151,7 @@ object WorldSimulator {
|
||||
if (result.distance < pickupDistSqr) {
|
||||
droppedItem.flagDespawn = true
|
||||
(actor as Pocketed).inventory.add(droppedItem.itemID, droppedItem.itemCount)
|
||||
ItemCodex[droppedItem.itemID]!!.effectOnPickup(actor)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ interface Pocketed {
|
||||
// Relevant Actorvalue is NOT being updated on time
|
||||
// They're being safely handled by UIItemInventoryElem*.touchDown() and ActorInventory.remove
|
||||
|
||||
item.effectOnUnequip(this as ActorWithBody, App.UPDATE_RATE)
|
||||
item.effectOnUnequip(this as ActorWithBody)
|
||||
}
|
||||
|
||||
fun unequipItem(itemID: ItemID?) {
|
||||
|
||||
@@ -205,7 +205,7 @@ object BlockBase {
|
||||
(Terrarum.ingame!! as TerrarumIngame).selectedWireRenderClass = WireCodex[itemID].renderClass
|
||||
}
|
||||
|
||||
fun wireEffectWhenUnequipped(gameItem: GameItem, delta: Float) {
|
||||
fun wireEffectWhenUnequipped(gameItem: GameItem) {
|
||||
(Terrarum.ingame!! as TerrarumIngame).selectedWireRenderClass = ""
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ open class FixtureItemBase(originalID: ItemID, val fixtureClassName: String) : G
|
||||
}
|
||||
}
|
||||
|
||||
override fun effectOnUnequip(actor: ActorWithBody, delta: Float) {
|
||||
override fun effectOnUnequip(actor: ActorWithBody) {
|
||||
// ghostInit = false
|
||||
|
||||
(INGAME as TerrarumIngame).blockMarkingActor.let {
|
||||
|
||||
@@ -26,8 +26,8 @@ class ItemLogicSignalEmitter(originalID: ItemID) : FixtureItemBase(originalID, "
|
||||
(Terrarum.ingame!! as TerrarumIngame).selectedWireRenderClass = "signal"
|
||||
}
|
||||
|
||||
override fun effectOnUnequip(actor: ActorWithBody, delta: Float) {
|
||||
super.effectOnUnequip(actor, delta)
|
||||
override fun effectOnUnequip(actor: ActorWithBody) {
|
||||
super.effectOnUnequip(actor)
|
||||
(Terrarum.ingame!! as TerrarumIngame).selectedWireRenderClass = ""
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
|
||||
@@ -15,6 +17,16 @@ open class OreItemBase(originalID: ItemID) : GameItem(originalID) {
|
||||
override val isDynamic = false
|
||||
override val materialId = "OORE"
|
||||
override var equipPosition = EquipPosition.HAND_GRIP
|
||||
|
||||
override fun effectOnPickup(actor: ActorWithBody) {
|
||||
val playerCodex = (actor.actorValue.getAsString(AVKey.ORE_DICT) ?: "").split(',').filter { it.isNotBlank() }.toMutableList()
|
||||
|
||||
if (playerCodex.binarySearch(originalID) < 0) {
|
||||
playerCodex.add(originalID)
|
||||
playerCodex.sort()
|
||||
actor.actorValue[AVKey.ORE_DICT] = playerCodex.joinToString(",")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Wooden Log is a block */
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarum.gameitems.mouseInInteractableRangeTools
|
||||
import net.torvald.terrarum.gameparticles.createRandomBlockParticle
|
||||
import net.torvald.terrarum.itemproperties.Calculate
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.DroppedItem
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore.BASE_MASS_AND_SIZE
|
||||
@@ -160,6 +161,30 @@ object PickaxeCore {
|
||||
|
||||
const val BASE_MASS_AND_SIZE = 10.0 // of iron pick
|
||||
const val TOOL_DURABILITY_BASE = 350 // of iron pick
|
||||
|
||||
fun showOresTooltip(actor: ActorWithBody, tool: GameItem, mx: Int, my: Int): Unit {
|
||||
if (App.getConfigBoolean("basegame:showpickaxetooltip")) {
|
||||
var tooltipSet = false
|
||||
mouseInInteractableRangeTools(actor, tool) {
|
||||
val tileUnderCursor = INGAME.world.getTileFromOre(mx, my).item
|
||||
val playerCodex = (actor.actorValue.getAsString(AVKey.ORE_DICT) ?: "").split(',').filter { it.isNotBlank() }
|
||||
|
||||
|
||||
if (tileUnderCursor != Block.AIR) {
|
||||
val itemForOre = OreCodex[tileUnderCursor].item
|
||||
val tileName = if (playerCodex.binarySearch(itemForOre) >= 0)
|
||||
Lang[ItemCodex[itemForOre]!!.originalName]
|
||||
else "???"
|
||||
INGAME.setTooltipMessage(tileName)
|
||||
tooltipSet = true
|
||||
}
|
||||
|
||||
true // just a placeholder
|
||||
}
|
||||
|
||||
if (!tooltipSet) INGAME.setTooltipMessage(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,6 +212,8 @@ class PickaxeCopper(originalID: ItemID) : GameItem(originalID) {
|
||||
override fun startPrimaryUse(actor: ActorWithBody, delta: Float) =
|
||||
if (PickaxeCore.startPrimaryUse(actor, delta, this, Terrarum.mouseTileX, Terrarum.mouseTileY)) 0L else -1L
|
||||
override fun endPrimaryUse(actor: ActorWithBody, delta: Float) = PickaxeCore.endPrimaryUse(actor, delta, this)
|
||||
override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) = PickaxeCore.showOresTooltip(actor, this, Terrarum.mouseTileX, Terrarum.mouseTileY)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,6 +241,8 @@ class PickaxeIron(originalID: ItemID) : GameItem(originalID) {
|
||||
override fun startPrimaryUse(actor: ActorWithBody, delta: Float) =
|
||||
if (PickaxeCore.startPrimaryUse(actor , delta, this, Terrarum.mouseTileX, Terrarum.mouseTileY)) 0L else -1L
|
||||
override fun endPrimaryUse(actor: ActorWithBody, delta: Float) = PickaxeCore.endPrimaryUse(actor, delta, this)
|
||||
override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) = PickaxeCore.showOresTooltip(actor, this, Terrarum.mouseTileX, Terrarum.mouseTileY)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,6 +270,8 @@ class PickaxeSteel(originalID: ItemID) : GameItem(originalID) {
|
||||
override fun startPrimaryUse(actor: ActorWithBody, delta: Float) =
|
||||
if (PickaxeCore.startPrimaryUse(actor, delta, this, Terrarum.mouseTileX, Terrarum.mouseTileY)) 0L else -1L
|
||||
override fun endPrimaryUse(actor: ActorWithBody, delta: Float) = PickaxeCore.endPrimaryUse(actor, delta, this)
|
||||
override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) = PickaxeCore.showOresTooltip(actor, this, Terrarum.mouseTileX, Terrarum.mouseTileY)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,4 +299,6 @@ class PickaxeWood(originalID: ItemID) : GameItem(originalID) {
|
||||
override fun startPrimaryUse(actor: ActorWithBody, delta: Float) =
|
||||
if (PickaxeCore.startPrimaryUse(actor, delta, this, Terrarum.mouseTileX, Terrarum.mouseTileY)) 0L else -1L
|
||||
override fun endPrimaryUse(actor: ActorWithBody, delta: Float) = PickaxeCore.endPrimaryUse(actor, delta, this)
|
||||
override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) = PickaxeCore.showOresTooltip(actor, this, Terrarum.mouseTileX, Terrarum.mouseTileY)
|
||||
|
||||
}
|
||||
@@ -107,7 +107,7 @@ class WireCutterAll(originalID: ItemID) : GameItem(originalID) {
|
||||
(Terrarum.ingame!! as TerrarumIngame).selectedWireRenderClass = "wire_render_all"
|
||||
}
|
||||
|
||||
override fun effectOnUnequip(actor: ActorWithBody, delta: Float) {
|
||||
override fun effectOnUnequip(actor: ActorWithBody) {
|
||||
(Terrarum.ingame!! as TerrarumIngame).selectedWireRenderClass = ""
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ class WireGraphDebugger(originalID: ItemID) : GameItem(originalID) {
|
||||
}
|
||||
}
|
||||
|
||||
override fun effectOnUnequip(actor: ActorWithBody, delta: Float) {
|
||||
override fun effectOnUnequip(actor: ActorWithBody) {
|
||||
(Terrarum.ingame!! as TerrarumIngame).selectedWireRenderClass = ""
|
||||
(Terrarum.ingame!! as TerrarumIngame).setTooltipMessage(null)
|
||||
blockMarker.isVisible = false
|
||||
|
||||
@@ -36,7 +36,7 @@ class WirePieceSignalWire(originalID: ItemID, private val atlasID: String, priva
|
||||
BlockBase.wireEffectWhenEquipped(this, delta)
|
||||
}
|
||||
|
||||
override fun effectOnUnequip(actor: ActorWithBody, delta: Float) {
|
||||
BlockBase.wireEffectWhenUnequipped(this, delta)
|
||||
override fun effectOnUnequip(actor: ActorWithBody) {
|
||||
BlockBase.wireEffectWhenUnequipped(this)
|
||||
}
|
||||
}
|
||||
@@ -102,6 +102,8 @@ internal class UIInventoryCells(
|
||||
).let { drop ->
|
||||
INGAME.queueActorAddition(drop)
|
||||
}
|
||||
// apply item effect
|
||||
item.effectOnThrow(player)
|
||||
// update inventory
|
||||
rebuildList()
|
||||
} }
|
||||
|
||||
@@ -21,7 +21,7 @@ object UITitleRemoConYaml {
|
||||
- MENU_LABEL_SOUND : net.torvald.terrarum.modulebasegame.ui.UISoundControlPanel
|
||||
- MENU_LABEL_LANGUAGE : net.torvald.terrarum.modulebasegame.ui.UITitleLanguage
|
||||
- GAME_GENRE_MISC : net.torvald.terrarum.modulebasegame.ui.UIPerformanceControlPanel
|
||||
- MENU_MODULES : net.torvald.terrarum.ModOptionsHost
|
||||
- CREDITS_GAME : net.torvald.terrarum.ModOptionsHost
|
||||
- MENU_LABEL_RETURN+WRITETOCONFIG
|
||||
- MENU_MODULES : net.torvald.terrarum.modulebasegame.ui.UITitleModules
|
||||
- MENU_LABEL_RETURN
|
||||
|
||||
@@ -38,16 +38,26 @@ object Worldgen {
|
||||
|
||||
private val oreRegistry = ArrayList<OregenParams>()
|
||||
|
||||
fun getJobs(tags: List<String> = emptyList()): List<Work> {
|
||||
val tagFilter = if (tags.isEmpty()) { { work: Work -> true } }
|
||||
else {
|
||||
{ work: Work ->
|
||||
(work.tags union tags).isNotEmpty()
|
||||
}
|
||||
}
|
||||
return listOf(
|
||||
Work("Reticulating Splines", Terragen(world, highlandLowlandSelectCache, params.seed, params.terragenParams), listOf("TERRAIN")),
|
||||
Work("Adding Rocks", Oregen(world, caveAttenuateBiasScaled, params.seed, oreRegistry), listOf("ORES")),
|
||||
Work("Positioning Rocks", OregenAutotiling(world, params.seed), listOf("ORES")),
|
||||
Work("Adding Vegetations", Biomegen(world, params.seed, params.biomegenParams), listOf("BIOME")),
|
||||
).filter(tagFilter)
|
||||
}
|
||||
|
||||
fun generateMap() {
|
||||
highlandLowlandSelectCache = getHighlandLowlandSelectCache(params.terragenParams, params.seed)
|
||||
caveAttenuateBiasScaled = getCaveAttenuateBiasScaled(highlandLowlandSelectCache, params.terragenParams)
|
||||
|
||||
val jobs = listOf(
|
||||
Work("Reticulating Splines", Terragen(world, highlandLowlandSelectCache, params.seed, params.terragenParams)),
|
||||
Work("Adding Rocks", Oregen(world, caveAttenuateBiasScaled, params.seed, oreRegistry)),
|
||||
Work("Positioning Rocks", OregenAutotiling(world, params.seed)),
|
||||
Work("Adding Vegetations", Biomegen(world, params.seed, params.biomegenParams)),
|
||||
)
|
||||
val jobs = getJobs()
|
||||
|
||||
|
||||
for (i in jobs.indices) {
|
||||
@@ -80,10 +90,10 @@ object Worldgen {
|
||||
|
||||
}
|
||||
|
||||
private data class Work(val loadingScreenName: String, val theWork: Gen)
|
||||
data class Work(val loadingScreenName: String, val theWork: Gen, val tags: List<String>)
|
||||
|
||||
fun getEstimationSec(width: Int, height: Int): Long {
|
||||
return (23.05 * 1.25 * (48600000.0 / bogoflops) * ((width * height) / 40095000.0) * (32.0 / THREAD_COUNT)).roundToLong()
|
||||
return (23.15 * 1.25 * (48600000.0 / bogoflops) * ((width * height) / 40095000.0) * (32.0 / THREAD_COUNT)).roundToLong()
|
||||
}
|
||||
|
||||
private fun getHighlandLowlandSelectCache(params: TerragenParams, seed: Long): ModuleCache {
|
||||
|
||||
Reference in New Issue
Block a user