glow orbs

This commit is contained in:
minjaesong
2024-07-12 04:21:09 +09:00
parent 5a4c300612
commit 92f28887ec
11 changed files with 75 additions and 18 deletions

Binary file not shown.

View File

@@ -53,6 +53,8 @@ id;classname;tags
52;net.torvald.terrarum.modulebasegame.gameitems.ItemLogicSignalSevenSeg;FIXTURE,SIGNAL
53;net.torvald.terrarum.modulebasegame.gameitems.ItemEngravingWorkbench;FIXTURE,CRAFTING
54;net.torvald.terrarum.modulebasegame.gameitems.ItemMechanicalTines;FIXTURE,MUSIC,SIGNAL
55;net.torvald.terrarum.modulebasegame.gameitems.ItemGlowOrb;LIGHT,THROWABLE
# ingots
112;net.torvald.terrarum.modulebasegame.gameitems.IngotCopper;INGOT
1 id classname tags
53 53 net.torvald.terrarum.modulebasegame.gameitems.ItemEngravingWorkbench FIXTURE,CRAFTING
54 54 net.torvald.terrarum.modulebasegame.gameitems.ItemMechanicalTines FIXTURE,MUSIC,SIGNAL
55 # ingots 55 net.torvald.terrarum.modulebasegame.gameitems.ItemGlowOrb LIGHT,THROWABLE
56 # ingots
57 112 net.torvald.terrarum.modulebasegame.gameitems.IngotCopper INGOT
58 112 113 net.torvald.terrarum.modulebasegame.gameitems.IngotCopper net.torvald.terrarum.modulebasegame.gameitems.IngotIron INGOT
59 113 114 net.torvald.terrarum.modulebasegame.gameitems.IngotIron net.torvald.terrarum.modulebasegame.gameitems.ItemCoalCoke INGOT COMBUSTIBLE
60 114 115 net.torvald.terrarum.modulebasegame.gameitems.ItemCoalCoke net.torvald.terrarum.modulebasegame.gameitems.IngotZinc COMBUSTIBLE INGOT

Binary file not shown.

View File

@@ -1,14 +1,19 @@
package net.torvald.terrarum.modulebasegame.gameactors
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.gdx.graphics.Cvec
import net.torvald.spriteanimation.SingleImageSprite
import net.torvald.terrarum.*
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
import net.torvald.terrarum.audio.audiobank.MusicContainer
import net.torvald.terrarum.audio.decibelsToFullscale
import net.torvald.terrarum.gameactors.ActorWithBody
import net.torvald.terrarum.gameactors.PhysProperties
import net.torvald.terrarum.gameactors.*
import net.torvald.terrarum.modulebasegame.ExplosionManager
import java.util.ArrayList
import kotlin.math.log10
/**
* Created by minjaesong on 2024-02-13.
@@ -34,17 +39,17 @@ open class ActorPrimedBomb(
private var explosionCalled = false
@Transient private val boomSound = MusicContainer(
"boom", ModMgr.getFile("basegame", "audio/effects/explosion/bang_bomb.ogg"), toRAM = true
"boom", ModMgr.getFile("basegame", "audio/effects/explosion/bang_bomb.wav"), toRAM = true
) {
this.flagDespawn()
}
@Transient private val fuseSound = MusicContainer(
"fuse", ModMgr.getFile("basegame", "audio/effects/explosion/fuse.ogg"), toRAM = true
"fuse", ModMgr.getFile("basegame", "audio/effects/explosion/fuse.wav"), toRAM = true
) {
this.flagDespawn()
}
@Transient private val fuseSoundCont = MusicContainer(
"fuse_continue", ModMgr.getFile("basegame", "audio/effects/explosion/fuse_continue.ogg"), toRAM = true
"fuse_continue", ModMgr.getFile("basegame", "audio/effects/explosion/fuse_continue.wav"), toRAM = true
) {
this.flagDespawn()
}
@@ -89,6 +94,10 @@ open class ActorPrimedBomb(
}
}
fun updatePhysOnly(delta: Float) {
super.updateImpl(delta)
}
override fun dispose() {
super.dispose()
boomSound.dispose()
@@ -102,7 +111,6 @@ 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
init {
val itemImage = CommonResourcePool.getAsItemSheet("basegame.items").get(0,13)
@@ -112,7 +120,51 @@ class ActorCherryBomb : ActorPrimedBomb(14f, 4.5f) { // 14 is the intended value
avBaseMass = 1.0
density = 1400.0
}
}
/**
* Created by minjaesong on 2024-07-12.
*/
class ActorGlowOrb : ActorPrimedBomb(0f, 0f) { // 14 is the intended value; 32 is for testing
val spawnTime = INGAME.world.worldTime.TIME_T
init {
val itemImage = CommonResourcePool.getAsItemSheet("basegame.items").get(1,13)
setHitboxDimension(7, 7, 2, -2)
sprite = SingleImageSprite(this, itemImage)
spriteEmissive = SingleImageSprite(this, itemImage)
avBaseMass = 1.0
density = 1400.0
}
@Transient private val lifePower = 10000L // charge reaches 0 on timeDelta = 9 * lifePower
@Transient private val lumMult = 0.8f
@Transient private val lumCol = BlockCodex["basegame:215"]
override var lightBoxList = arrayListOf(Lightbox(Hitbox(1.0, 1.0, baseHitboxW - 2.0, baseHitboxH - 2.0), Cvec(0)))
override fun updateImpl(delta: Float) {
updatePhysOnly(delta)
val timeDelta0 = INGAME.world.worldTime.TIME_T - spawnTime
val timeDelta = timeDelta0.coerceIn(0, 9 * lifePower)
val charge = log10((-timeDelta + 10 * lifePower.toFloat()) / lifePower.toFloat())
// set colours
spriteEmissive!!.colourFilter = Color(charge, charge, charge, 1f)
lightBoxList[0].light.set(
lumCol.baseLumColR * charge * lumMult,
lumCol.baseLumColG * charge * lumMult,
lumCol.baseLumColB * charge * lumMult,
lumCol.baseLumColA * charge * lumMult,
)
// remove the actor some time AFTER the chemicals are exhausted
if (timeDelta0 >= 10 * lifePower) {
flagDespawn()
}
}
}

View File

@@ -73,4 +73,16 @@ class ItemCherryBomb(originalID: ItemID) : ItemThrowable(originalID, "net.torval
init {
itemImage = CommonResourcePool.getAsItemSheet("basegame.items").get(0,13)
}
}
/**
* Created by minjaesong on 2024-07-12.
*/
class ItemGlowOrb(originalID: ItemID) : ItemThrowable(originalID, "net.torvald.terrarum.modulebasegame.gameactors.ActorGlowOrb") {
override var originalName = "ITEM_GLOW_ORB"
init {
itemImage = CommonResourcePool.getAsItemSheet("basegame.items").get(1,13)
}
// itemImageEmissive is not set because held glow orb does not glow (they get activated only when thrown)
}