mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 04:24:05 +09:00
item throwing sounds and better linter
This commit is contained in:
@@ -19,7 +19,7 @@ class AudioBankMusicBox(override var songFinishedHook: (AudioBank) -> Unit = {})
|
||||
}
|
||||
|
||||
override val name = "spieluhr"
|
||||
override val samplingRate = 48000 // 122880 // use 122880 to make each tick is 2048 samples
|
||||
override val samplingRate = 48000f // 122880 // use 122880 to make each tick is 2048 samples
|
||||
override val channels = 1
|
||||
|
||||
private val getSample = // usage: getSample(noteNum 0..60)
|
||||
|
||||
@@ -16,29 +16,46 @@ import kotlin.math.log10
|
||||
/**
|
||||
* Created by minjaesong on 2024-07-12.
|
||||
*/
|
||||
open class ActorLobbed : ActorWithBody()
|
||||
open class ActorLobbed(throwPitch: Float) : ActorWithBody() {
|
||||
|
||||
protected constructor() : this(1f)
|
||||
|
||||
@Transient private val whooshSound = MusicContainer(
|
||||
"throw_low_short", ModMgr.getFile("basegame", "audio/effects/throwing/throw_low_short.wav"),
|
||||
toRAM = true,
|
||||
samplingRateOverride = 48000f * throwPitch.coerceIn(0.5f, 2f)
|
||||
)
|
||||
|
||||
init {
|
||||
renderOrder = RenderOrder.FRONT
|
||||
physProp = PhysProperties.PHYSICS_OBJECT()
|
||||
elasticity = 0.34
|
||||
}
|
||||
|
||||
private var soundFired = false
|
||||
|
||||
override fun updateImpl(delta: Float) {
|
||||
super.updateImpl(delta)
|
||||
if (!soundFired) {
|
||||
soundFired = true
|
||||
startAudio(whooshSound, 1.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2024-02-13.
|
||||
*/
|
||||
open class ActorPrimedBomb(
|
||||
throwPitch: Float,
|
||||
@Transient private var explosionPower: Float = 1f,
|
||||
private var fuse: Second = 1f,
|
||||
@Transient private var dropProbNonOre: Float = 0.25f,
|
||||
@Transient private var dropProbOre: Float = 0.75f
|
||||
) : ActorLobbed() {
|
||||
) : ActorLobbed(throwPitch) {
|
||||
|
||||
init {
|
||||
renderOrder = RenderOrder.MIDTOP
|
||||
physProp = PhysProperties.PHYSICS_OBJECT()
|
||||
elasticity = 0.34
|
||||
}
|
||||
|
||||
protected constructor() : this(1f, 1f) {
|
||||
renderOrder = RenderOrder.MIDTOP
|
||||
physProp = PhysProperties.PHYSICS_OBJECT()
|
||||
}
|
||||
protected constructor() : this(1f, 1f, 1f)
|
||||
|
||||
private var explosionCalled = false
|
||||
|
||||
@@ -110,7 +127,10 @@ open class ActorPrimedBomb(
|
||||
/**
|
||||
* Created by minjaesong on 2024-02-14.
|
||||
*/
|
||||
class ActorCherryBomb : ActorPrimedBomb(14f, 4.5f) { // 14 is the intended value; 32 is for testing
|
||||
class ActorCherryBomb(throwPitch: Float) : ActorPrimedBomb(throwPitch, 14f, 4.5f) { // 14 is the intended value; 32 is for testing
|
||||
|
||||
private constructor() : this(1f)
|
||||
|
||||
init {
|
||||
val itemImage = CommonResourcePool.getAsItemSheet("basegame.items").get(0,13)
|
||||
|
||||
@@ -126,7 +146,10 @@ class ActorCherryBomb : ActorPrimedBomb(14f, 4.5f) { // 14 is the intended value
|
||||
/**
|
||||
* Created by minjaesong on 2024-07-12.
|
||||
*/
|
||||
class ActorGlowOrb : ActorLobbed() {
|
||||
class ActorGlowOrb(throwPitch: Float) : ActorLobbed(throwPitch) {
|
||||
|
||||
private constructor() : this(1f)
|
||||
|
||||
val spawnTime = INGAME.world.worldTime.TIME_T
|
||||
|
||||
init {
|
||||
|
||||
@@ -51,6 +51,8 @@ open class Cultivable: FixtureBase {
|
||||
* Created by minjaesong on 2024-02-03.
|
||||
*/
|
||||
open class SaplingBase(val species: Int) : Cultivable(72000) {
|
||||
private constructor() : this(0)
|
||||
|
||||
private val variant = (0..3).random()
|
||||
init {
|
||||
CommonResourcePool.addToLoadingList("basegame/sprites/saplings.tga") {
|
||||
|
||||
@@ -16,13 +16,17 @@ import org.dyn4j.geometry.Vector2
|
||||
/**
|
||||
* Created by minjaesong on 2016-03-15.
|
||||
*/
|
||||
open class DroppedItem : ActorWithBody {
|
||||
class DroppedItem : ActorWithBody {
|
||||
|
||||
companion object {
|
||||
const val NO_PICKUP_TIME = 1f
|
||||
const val MERGER_RANGE = 8.0 * TILE_SIZED // the wanted distance, squared
|
||||
}
|
||||
|
||||
init {
|
||||
renderOrder = RenderOrder.FRONT
|
||||
}
|
||||
|
||||
var itemID: ItemID = ""; private set
|
||||
|
||||
@Transient private var visualItemID = ""
|
||||
|
||||
@@ -33,7 +33,10 @@ open class ItemThrowable(originalID: ItemID, private val throwableActorClassName
|
||||
override fun startPrimaryUse(actor: ActorWithBody, delta: Float): Long = mouseInInteractableRange(actor) { mx, my, mtx, mty ->
|
||||
val (throwPos, throwForce) = getThrowPosAndVector(actor)
|
||||
|
||||
val lobbed = Class.forName(throwableActorClassName).getDeclaredConstructor().newInstance() as ActorWithBody
|
||||
val magnRel = throwForce.magnitude / actor.avStrength * 1000.0
|
||||
val pitch = (magnRel * 0.2).sqrt().toFloat()
|
||||
|
||||
val lobbed = Class.forName(throwableActorClassName).getDeclaredConstructor(pitch.javaClass).newInstance(pitch) as ActorWithBody
|
||||
lobbed.setPositionFromCentrePoint(throwPos)
|
||||
lobbed.externalV.set(throwForce)
|
||||
setupLobbedActor(lobbed)
|
||||
|
||||
Reference in New Issue
Block a user