mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-10 05:41:51 +09:00
mining sounds
This commit is contained in:
@@ -24,6 +24,7 @@ class AudioCodex {
|
||||
}
|
||||
|
||||
fun getRandomFootstep(materialID: String) = getRandomAudio("effects.steps.$materialID")
|
||||
fun getRandomMining(materialID: String) = getRandomAudio("effects.mining.$materialID")
|
||||
|
||||
/**
|
||||
* @param identifier
|
||||
|
||||
@@ -9,7 +9,6 @@ import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore
|
||||
import net.torvald.terrarum.realestate.LandUtil
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import org.dyn4j.geometry.Vector2
|
||||
@@ -371,8 +370,8 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
}
|
||||
|
||||
when (soundSource) {
|
||||
1 -> PickaxeCore.makeNoise(this, wallTile)
|
||||
0 -> PickaxeCore.makeNoise(this, terrTile)
|
||||
1 -> PickaxeCore.makeNoiseTileBurst(this, wallTile)
|
||||
0 -> PickaxeCore.makeNoiseTileBurst(this, terrTile)
|
||||
}
|
||||
|
||||
// make some dust
|
||||
|
||||
@@ -168,8 +168,8 @@ open class FixtureSwingingDoorBase : FixtureBase {
|
||||
}
|
||||
|
||||
when (soundSource) {
|
||||
1 -> PickaxeCore.makeNoise(this, wallTile)
|
||||
0 -> PickaxeCore.makeNoise(this, terrTile)
|
||||
1 -> PickaxeCore.makeNoiseTileBurst(this, wallTile)
|
||||
0 -> PickaxeCore.makeNoiseTileBurst(this, terrTile)
|
||||
}
|
||||
|
||||
// make some dust
|
||||
|
||||
@@ -1,25 +1,17 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
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.itemproperties.Item
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.DroppedItem
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.AxeCore.BASE_MASS_AND_SIZE
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.AxeCore.TOOL_DURABILITY_BASE
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
@@ -77,6 +69,10 @@ object AxeCore {
|
||||
val actionInterval = actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!!
|
||||
val swingDmgToFrameDmg = delta.toDouble() / actionInterval
|
||||
|
||||
if (INGAME.WORLD_UPDATE_TIMER % 11 == (Math.random() * 3).toInt()) {
|
||||
PickaxeCore.makeNoiseTileTouching(actor, tile)
|
||||
}
|
||||
|
||||
INGAME.world.inflictTerrainDamage(
|
||||
x, y,
|
||||
Calculate.hatchetPower(actor, item?.material) * swingDmgToFrameDmg,
|
||||
@@ -99,6 +95,10 @@ object AxeCore {
|
||||
val actionInterval = actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!!
|
||||
val swingDmgToFrameDmg = delta.toDouble() / actionInterval
|
||||
|
||||
if (INGAME.WORLD_UPDATE_TIMER % 11 == (Math.random() * 3).toInt()) {
|
||||
PickaxeCore.makeNoiseTileTouching(actor, tile)
|
||||
}
|
||||
|
||||
INGAME.world.inflictTerrainDamage(
|
||||
x, y,
|
||||
Calculate.hatchetPower(actor, item?.material) * swingDmgToFrameDmg,
|
||||
@@ -110,7 +110,7 @@ object AxeCore {
|
||||
PickaxeCore.dropItem(drop, x, y)
|
||||
|
||||
PickaxeCore.makeDust(tile, x, y, 9)
|
||||
PickaxeCore.makeNoise(actor, tile)
|
||||
PickaxeCore.makeNoiseTileBurst(actor, tile)
|
||||
}
|
||||
// tile not busted
|
||||
if (Math.random() < actionInterval) {
|
||||
@@ -125,6 +125,10 @@ object AxeCore {
|
||||
val actionInterval = actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!!
|
||||
val swingDmgToFrameDmg = delta.toDouble() / actionInterval
|
||||
|
||||
if (INGAME.WORLD_UPDATE_TIMER % 11 == (Math.random() * 3).toInt()) {
|
||||
PickaxeCore.makeNoiseTileTouching(actor, tile)
|
||||
}
|
||||
|
||||
INGAME.world.inflictTerrainDamage(
|
||||
x, y,
|
||||
Calculate.hatchetPower(actor, item?.material) * swingDmgToFrameDmg,
|
||||
@@ -207,7 +211,7 @@ object AxeCore {
|
||||
// drop the item under cursor
|
||||
PickaxeCore.dropItem(BlockCodex[tileBroken].drop, x, y) // todo use log item if applicable
|
||||
PickaxeCore.makeDust(tile, x, y, 9)
|
||||
PickaxeCore.makeNoise(actor, tile)
|
||||
PickaxeCore.makeNoiseTileBurst(actor, tile)
|
||||
}
|
||||
// tile not busted
|
||||
if (Math.random() < actionInterval) {
|
||||
|
||||
@@ -70,7 +70,7 @@ object BlockBase {
|
||||
false
|
||||
)
|
||||
}
|
||||
PickaxeCore.makeNoise(actor, itemID)
|
||||
PickaxeCore.makeNoiseTileBurst(actor, itemID)
|
||||
|
||||
1L
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package net.torvald.terrarum.modulebasegame.gameitems
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
@@ -91,6 +90,10 @@ object PickaxeCore {
|
||||
val actionInterval = actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!!
|
||||
val swingDmgToFrameDmg = delta.toDouble() / actionInterval
|
||||
|
||||
if (INGAME.WORLD_UPDATE_TIMER % 11 == (Math.random() * 3).toInt()) {
|
||||
makeNoiseTileTouching(actor, tile)
|
||||
}
|
||||
|
||||
INGAME.world.inflictTerrainDamage(
|
||||
x, y,
|
||||
Calculate.pickaxePower(actor, item?.material) * swingDmgToFrameDmg,
|
||||
@@ -125,9 +128,9 @@ object PickaxeCore {
|
||||
// make dust
|
||||
if (tileBroken != null || oreBroken != null) {
|
||||
makeDust(tile, x, y, 9)
|
||||
makeNoise(actor, tile)
|
||||
makeNoiseTileBurst(actor, tile)
|
||||
}
|
||||
else {
|
||||
else if (Math.random() < actionInterval) {
|
||||
makeDust(tile, x, y, 1)
|
||||
}
|
||||
}
|
||||
@@ -196,7 +199,13 @@ object PickaxeCore {
|
||||
}
|
||||
}
|
||||
|
||||
fun makeNoise(actor: ActorWithBody, tile: ItemID) {
|
||||
fun makeNoiseTileTouching(actor: ActorWithBody, tile: ItemID) {
|
||||
Terrarum.audioCodex.getRandomMining(BlockCodex[tile].material)?.let {
|
||||
actor.startAudio(it, 1.0)
|
||||
}
|
||||
}
|
||||
|
||||
fun makeNoiseTileBurst(actor: ActorWithBody, tile: ItemID) {
|
||||
Terrarum.audioCodex.getRandomFootstep(BlockCodex[tile].material)?.let {
|
||||
actor.startAudio(it, 2.0)
|
||||
}
|
||||
|
||||
@@ -2,23 +2,16 @@ package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
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.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.DroppedItem
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.SledgehammerCore.BASE_MASS_AND_SIZE
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.SledgehammerCore.TOOL_DURABILITY_BASE
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.Companion.WALL_OVERLAY_COLOUR
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
@@ -51,13 +44,10 @@ object SledgehammerCore {
|
||||
|
||||
var usageStatus = false
|
||||
|
||||
|
||||
|
||||
for (oy in 0 until mh) for (ox in 0 until mw) {
|
||||
val x = mx + xoff + ox
|
||||
val y = my + yoff + oy
|
||||
|
||||
val mousePoint = Point2d(x.toDouble(), y.toDouble())
|
||||
val actorvalue = actor.actorValue
|
||||
val wall = INGAME.world.getTileFromWall(x, y)
|
||||
val tileTerrain = INGAME.world.getTileFromTerrain(x, y)
|
||||
@@ -92,6 +82,10 @@ object SledgehammerCore {
|
||||
val actionInterval = actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!!
|
||||
val swingDmgToFrameDmg = delta.toDouble() / actionInterval
|
||||
|
||||
if (INGAME.WORLD_UPDATE_TIMER % 11 == (Math.random() * 3).toInt()) {
|
||||
PickaxeCore.makeNoiseTileTouching(actor, wall)
|
||||
}
|
||||
|
||||
INGAME.world.inflictWallDamage(
|
||||
x, y,
|
||||
Calculate.pickaxePower(actor, item?.material) * swingDmgToFrameDmg,
|
||||
@@ -104,7 +98,7 @@ object SledgehammerCore {
|
||||
PickaxeCore.dropItem("wall@$drop", x, y)
|
||||
|
||||
PickaxeCore.makeDust(wall, x, y, 9, WALL_OVERLAY_COLOUR)
|
||||
PickaxeCore.makeNoise(actor, wall)
|
||||
PickaxeCore.makeNoiseTileBurst(actor, wall)
|
||||
}
|
||||
}
|
||||
// tile not busted
|
||||
|
||||
Reference in New Issue
Block a user